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.