System File Updates
In this example, we report the failure of system file updates (for example, log files).
The FileUpdates script might send an alert message like the following:
PIKT ALERT Mon Oct 20 11:44:18 2003 nantes CRITICAL: FileUpdates Report if various files are not being updated /var/log/syslog is outdated, is 14967 seconds old
FileUpdates makes reference to the =fileages_obj macro, which resolves to the name of the FileAges.obj file. The script follows.
FileUpdates init status =piktstatus level =piktlevel task "Report if various files are not being updated" input file "=fileages_obj" dat $name 1 dat #maxdays 2 dat #maxsecs 3 rule // if the indicated time threshold is in days only, // check in FileUpdatesWarning instead if #maxsecs == 0 next endif rule // report missing files other than lock files if ! -e $name if $name !~ "\\.lock$" =outputmail "$name not found!" endif next endif rule // squelch pikt logfile messages on weekends if $name =~ "pikt" && =weekend next endif rule set #maxage = #maxdays * =secs_in_day + #maxsecs set $ll = $command("=ll $name") =set_lineage($ll) if #lineage > #maxage set $msg = "$name is outdated, is $text(#lineage) seconds old" if $name =~ "pikt" =output_other_mail(MAIL, 'PIKT Alert on $hostname(): Critical', =piktadmin, $msg) else output mail $msg endif endif
This is just one program example. You could add rules, or write new scripts, for example to report: if log file entries are outdated, if files are being updated when they shouldn't be, etc.
For more examples, see Samples.