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.

Open Hand 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 2008-03-27.   This site is PIKT® powered.
PIKT® is a registered trademark of the University of Chicago.   Copyright © 1998-2008 Robert Osterlund. All rights reserved.
Home FAQ News Intro Samples Tutorial Reference Software
PIKT Logo
PIKT Page Title
View sample
search links
script macro