PIKT

Samples: File Age Limits

PIKT Logo
Home FAQ News Intro Samples Tutorial Reference Software Authors Licensing SiteSearch


This fileages_objects.cfg example specifies file age limits, or modification times beyond which a file is considered to be out of date.

Note in this example the use of virtual #include files by means of the '#include [<proc>]' directives.  An excerpt from the logs_system_objects.cfg file might show:
//      macroname   filepath            days   secs    binary  maxsize
          preproc postproc

          syslog      /var/log/messages   0      10800   0       10000
          .       .
In the fileages_objects.cfg file below, the awk statement in the #include directive says to fetch just the 2nd, 3rd, 4th, and 5th fields (filepath, days, secs, binary) for the purpose of setting file age limits.

Why this virtual #include file trickery?  The idea is so that we don't have to duplicate information.  Specify file (or directory or ...) attributes once in one .cfg file, then grab bits and pieces of those specifications for other purposes by means of virtual #include files.

///////////////////////////////////////////////////////////////////////////////
//
// fileages_objects.cfg
//
///////////////////////////////////////////////////////////////////////////////

FileAges

// for FileAges, the number is the file age, either in days or in seconds,
// beyond which a file is considered to be out of date

// all numeric fields must be actual numbers, not e.g., 2*60*60, but
// rather 7200

//      file                                    days            secs    binary

///////////////////////////////////////////////////////////////////////////////

// log stuff

#include [/pikt/bin/pikts </pikt/lib/configs/objects/adm/logs_system_objects.cfg |
          awk '/^#/ {print; next}; /^[A-Z]/ {print " "; next};
                    {print $2 " " $3 " " $4 " " $5}']

#include [/pikt/bin/pikts < /pikt/lib/configs/objects/adm/logs_pikt_objects.cfg |
          awk '/^#/ {print; next}; /^[A-Z]/ {print " "; next};
                    {print $2 " " $3 " " $4 " " $5}']

#include [/pikt/bin/pikts < /pikt/lib/configs/objects/adm/logs_local_objects.cfg |
          awk '/^#/ {print; next}; /^[A-Z]/ {print " "; next};
                    {print $2 " " $3 " " $4 " " $5}']

///////////////////////////////////////////////////////////////////////////////

// system stuff follows

///////////////////////////////////////////////////////////////////////////////

// pikt stuff follows

#include <objects/adm/fileages_pikt_objects.cfg>

///////////////////////////////////////////////////////////////////////////////

// local stuff follows

#include <objects/adm/fileages_local_objects.cfg>

///////////////////////////////////////////////////////////////////////////////
On the piktmaster system, we would install the FileAges.obj file to each PIKT slave system with the command:
# piktc -iv +O FileAges +H all        [or: ... -H downsys]

[For more examples, see Samples.]

Home | FAQ | News | Intro | Samples | Tutorial | Reference | Software | Authors | Licensing | SiteSearch
Links | SiteIndex | Pikt-Users | Pikt-Workers | Contribute | ContactUs | Top of Page
Page best viewed at 1024x768.   Page last updated 2005-06-22.
This site is PIKT® powered.
PIKT® is a registered trademark of the University of Chicago.
Copyright © 1998-2005 Robert Osterlund.  All rights reserved.

Computer Books at Amazon.com

UNIX System Administration Handbook
UNIX System Administration Handbook

UNIX CD Bookshelf
UNIX CD Bookshelf

Linux Server Hacks
Linux Server Hacks

Beginning SuSE Linux: From Novice To Professional
Beginning SuSE Linux: From Novice To Professional

Red Hat Linux Bible: Fedora and Enterprise Edition
Red Hat Linux Bible: Fedora and Enterprise Edition