Crontab Change Macro

The crontab_change_alarms_macros.cfg is a script macro to report crontab changes.

crontab_change(u)
 
	init
		status =piktstatus
		level =piktlevel
		task "Report changes in (u) crontabs"
		input proc "if [ -e =hstdir/log/(u).crontab.bak ];
                            then =diff =hstdir/log/(u).crontab.bak
                                       =hstdir/log/(u).crontab 2>/dev/null;
                            else =cat =hstdir/log/(u).crontab 2>/dev/null;
                            fi"
	begin
		doexec wait "=crontab -u (u) -l > =hstdir/log/(u).crontab"

	rule
		output mail $inlin

	end
		doexec wait $lower("=mv =hstdir/log/(u).crontab
                                        =hstdir/log/(u).crontab.bak")
		quit

You might invoke the =crontab_change() macro in your alarms.cfg file thusly:

///////////////////////////////////////////////////////////////////////////////
//
// logs_system_alarms.cfg
//
///////////////////////////////////////////////////////////////////////////////
 
RootCrontabChange
 
        =crontab_change(root)
 
///////////////////////////////////////////////////////////////////////////////
 
ACMECrontabChange
 
        =crontab_change(acme)
 
///////////////////////////////////////////////////////////////////////////////

Output from this script might look like, for example:

NOTICE:
    ACMECrontabChange
        Report changes in acme crontabs
        2c2
        < # (/tmp/crontab.XXXXa3sFgY installed on Wed Sep  5 10:09:46 2007)
        ---
        > # (/tmp/crontab.XXXXZP0hLb installed on Fri Sep  7 15:53:49 2007)
        21c21
        < 16 3 * * 1-5 /usr/local/acme/bin/task.prod/startTaskProd_part7.sh
        ---
        > 01 1 * * 1-5 /usr/local/acme/bin/task.prod/mks_nickname.sh
        23c23
        < 01 3 * * 1-5 /usr/local/acme/bin/task.prod/mks_nickname.sh
        ---
        > 16 3 * * 1-5 /usr/local/acme/bin/task.prod/startTaskProd_part7.sh

For more examples, see Samples.

 
Home | FAQ | News | Intro | Samples | Tutorial | Reference | Software
Developer's Notes | Licensing | Authors | Pikt-Users | Pikt-Workers | Related Projects | Site Index | Privacy Policy | Contact Us
Page best viewed at 1024x768 or greater.   Page last updated 2019-01-12.   This site is PIKT® powered.
Copyright © 1998-2019 Robert Osterlund. All rights reserved.
Home FAQ News Intro Samples Tutorial Reference Software
PIKT Logo
PIKT Page Title
View sample
firewall
macros