Stale Files Macro

The stale_files_alarms_macros.cfg is a script macro to report stale, or unchanged, files.

stale_files(DIR, FILTYP, TYP, EXT, DAYS, BYPASS1, BYPASS2)
 
        init
                status =piktstatus
                level =piktlevel
                task "Report any stale (FILTYP) files"
                // currently, only show files more than d+1 days old;
                // for finer granularity, with precision to hours or minutes,
                // we would have to code a much more complex script
                input proc "=find (DIR) (TYP) -name \\*.(EXT) -mtime +(DAYS) -exec ls -ld {} \\;
                            2>/dev/null"
        rule
                if $inline =~~ "(BYPASS1)"
                        next
                endif

        rule
                if $inline !~~ "(BYPASS2)"
                        output mail $inlin
                endif

        end
                quit

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

///////////////////////////////////////////////////////////////////////////////
//
// admin_pikt_alarms.cfg
//
///////////////////////////////////////////////////////////////////////////////
 
StalePIKTLockFiles
 
                =stale_files(=etcdir, PIKT lock, -type f, lock, 0,
                             piktd\\\\.lock|piktc_svc\\\\.lock, =nonesuch)
 
///////////////////////////////////////////////////////////////////////////////
 
StalePIKTLogFiles
 
                =stale_files(=logdir, PIKT log, -type f, log, 0,
                             piktc_svc\\\\.log|piktc\\\\.log|piktx\\\\.log, syslog|
                             red|scriptchange|acmeprocess|test|downsystems|downrpc|
                             sysreboots|scandmesg|scansyslogcritical|scansyslogkernel|
                             scriptchanges|loadaverages|processes|zombies|
                             runaway|lpchk|checkpoint|dmesgscan|nightlyupdates)
 
///////////////////////////////////////////////////////////////////////////////
 
StalePIKTHstFiles
 
                =stale_files(=hstdir, PIKT hst, -type f, hst, 0,
                             =nonesuch,
                             acmeprocess|test|downsystems|downrpc|sysreboots|
                             scandmesg|scansyslogcritical|scansyslogkernel|
                             scriptchanges|loadaverages|processes|zombies|
                             runaway|debug)
 
///////////////////////////////////////////////////////////////////////////////

Output from the StalePIKTLogFiles script might look like, for example:

DEBUG:
    StalePIKTLogFiles
        Report any stale PIKT log files
 
        -rw------- 1 root root 1235127 Sep 10 18:29 /pikt/var/log/SysAdminsCritical.log
        -rw------- 1 root root 589075 Sep 10 18:02 /pikt/var/log/CodersCritical.log
        -rw------- 1 root root 934608 Sep 10 17:17 /pikt/var/log/SysAdminsUrgent.log
        -rw------- 1 root root 164849 Sep 10 20:31 /pikt/var/log/CodersNotice.log
        -rw------- 1 root root 27896 Sep 10 21:38 /pikt/var/log/CodersWarning.log
        -rw------- 1 root root 28250 Sep 10 21:20 /pikt/var/log/SysAdminsWarning.log
        -rw------- 1 root root 911754 Sep 10 22:34 /pikt/var/log/PiktAdminInfo.log

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
Learn about
Pikt script
numerical
functions