macros.cfg

(NOTE:  Some of the techniques shown or described on this page--marked in purple--require new features in the latest official PIKT 1.19.0 release (pikt-current.tar.gz) that are unavailable in any previous version.)

macros.cfg specifies preprocessor text substitutions. Use macros to hide lower-level implementation details, also to write all-purpose, one-size-fits-all higher-level configurations.  For ease of management, we have modularized this file into various #include files.

This is an elaborate samples macros.cfg file, with many specialized macros.  A typical macros.cfg might be much simpler than this.

///////////////////////////////////////////////////////////////////////////////
// 
// PIKT macros.cfg -- preprocessor text substitutions
//
///////////////////////////////////////////////////////////////////////////////
// 
// PIKT supports several pre-defined, built-in macros:
// 
//      =piktdir                resolves to the PIKT home directory
//
//      host and operating system macros:
//
//      =pikthostname           resolves to the active host in the current
//                              piktc action
//      =piktmaster             resolves to the PIKT master control machine
//      =pikthosts              resolves to the list of PIKT host systems
//                              defined in systems.cfg
//      =piktopsystems          resolves to the list of operating systems
//                              specified in systems.cfg
//
//      as piktc does its processing:
//
//      =piktalert              the current alert stanza (in alerts.cfg)
//      =piktalarm              the current alarm stanza (in alarms.cfg)
//      =piktprogram            the current program stanza (in programs.cfg)
//      =piktfile               the current file stanza (in files.cfg)
//      =piktobject             the current objects stanza (in objects.cfg)
//
//      alarm specifications:
//
//      =piktstatus             the alert-wide alarm status (set in alerts.cfg)
//      =piktlevel              the alert-wide alarm level (set in alerts.cfg)
//
//      alerts.cfg timings:
//
//      =piktnever              resolves to a special timing string that
//                              signals piktd to bypass the current alert
//      =piktalways             resolves to a special timing string that
//                              signals piktd to run the current alert
//                              every minute of every day
// 
// the following built-in macros are intended for PIKT.conf management:
//
//      =piktuid                resolves to the uid (as specified in keys.conf)
//                              for the current host
//      =piktgid                resolves to the gid (as specified in keys.conf)
//                              for the current host
//      =piktprivate_key        resolves to the private_key (as specified in
//                              keys.conf) for the current host
//
// the following built-in macros are useful for document formatting (and
// are especially important when defining other macros):
// 
//      =piktnullchar           resolves to the null character
//                              (also:  )
//      =piktspacechar          resolves to the space character
//      =pikttabchar            resolves to the tab character
//      =piktnewlinechar        resolves to the newline character
// 
//
//  a general built-in macro useful in any of the config files:
//
//      =pikttest               resolves to the string 'test' when
//                              used with 'piktc -T' (for test mode),
//                              otherwise the null string
//
// these pre-defined, built-in macro identifiers are reserved and cannot be
// overridden
// 
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// these macrodefs are all standard; leave them unchanged

bindir          =piktdir/bin
etcdir          =piktdir/etc
lokdir          =piktdir/etc
cfgdir          =piktdir/lib/configs
altdir          =piktdir/lib/alerts
prgdir          =piktdir/lib/programs
objdir          =piktdir/lib/objects
hstdir          =piktdir/var/histories
logdir          =piktdir/var/log

stgdir          =cfgdir/staging
difdir          =cfgdir/diffing

piktfiltyp      bin etc lok cfg alt prg fil obj hst log

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

// standard includes; modify the individual include files in the macros
// directory as needed/indicated

#include <macros/adm/files_pikt_macros.cfg>

#include <macros/adm/unixcmds_macros.cfg>

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

// pikt mail macros - pikt mail routing

#include <macros/adm/pikt_mail_macros.cfg>

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

// standard constants macros

KB              1024

MB              (=KB * =KB)

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

// edit everything that follows as needed

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

// debug macros

tracerule(S)
#ifdef debug
                "rule $text(#rule()): " . (S)
#elsedef
                (S)
#endifdef

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

// exec process macros - process execution

#include <macros/adm/exec_process_macros.cfg>

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

// output macros - script output

#include <macros/adm/output_macros.cfg>

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

// output scheduling macros - script output scheduling

#include <macros/adm/output_scheduling_macros.cfg>

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

// script abort macros - script quit situations

#include <macros/adm/script_abort_macros.cfg>

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

// input macros - script input

#include <macros/adm/input_macros.cfg>

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

// data input macros - script data input

#include <macros/adm/data_input_macros.cfg>

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

// date & time macros - date & time shortcuts

#include <macros/adm/date_time_macros.cfg>

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

// scheduling macros - scheduling script operation

#include <macros/adm/scheduling_macros.cfg>

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

// text macros - text shortcuts

#include <macros/adm/text_macros.cfg>

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

// counting macros

// assume 0 (zero) default value

incr(N)         if ! #defined((N))
                        set (N) = 1
                else
                        set (N) += 1
                fi

decr(N)         if ! #defined((N))
                        set (N) = -1
                else
                        set (N) -= 1
                fi

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

// conditional macros - logical conditions

#include <macros/adm/condition_macros.cfg>

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

// process macros - process shortcuts

#include <macros/adm/process_macros.cfg>

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

// network macros - host-address conversions, subnets, dns, etc.

#include <macros/adm/network_macros.cfg>

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

// network service test macros - testing whether a network service is available

#include <macros/adm/network_service_test_macros.cfg>

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

// logfile macros -- log file outputs, dates & times

#include <macros/adm/logfile_macros.cfg>

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

// file & disk macros - file & disk management

#include <macros/adm/file_disk_macros.cfg>

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

// path macros - directory & file paths

#include <macros/adm/path_macros.cfg>

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

// nis macros

nismaster       nantes

nisserver
#include <systems/nisserver_systems.cfg>

domain_name     egbdf.uppity.edu        // so as not to conflict with
                                        // =domainname def in
                                        // unixcmds_*_macros.cfg file

ypservers       /var/yp/binding/=domain_name/ypservers

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

// accts macros

sysadmins       brahms|bach|soler|purcell3

dbadmins        leoncavallo|schubert|smetana|borodin
compsys         schubert|smetana

nobody          nobody|nobody4|noaccess

lockouts        staff|faculty|student|gift|ftp|ph|class|http|gopher|operator

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

// priority macros

#include <macros/adm/priority_macros.cfg>

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

// pager macros - emergency messaging

#include <macros/adm/pager_macros.cfg>

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

// alerts & scripts macros

#include <macros/adm/alerts_scripts_macros.cfg>

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

// logfile regexp macros -- log file regular expressions, things to watch
//                          out for, things to ignore

#include <macros/adm/logfile_regexp_macros.cfg>

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

// backup macros

backup_alarms   DumpDatesProblemsWarning
                DumpDatesOutdatedWarning

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

// systems macros

// since we reference these in many of the '#verbatim [] directives
// that follow, we want to specify them as early in systems.cfg as
// possible so that subsequent references are most up-to-date

missioncritical
#include <systems/missioncritical_systems.cfg>

sick                    // set '-H sick' for these
        =piktnullchar   // placeholder to ensure stanza content even if
                        // the following #include/#verbatim file is empty
#verbatim <systems/sick_systems.cfg>

down                    // set '-H down' for these
        =piktnullchar   // placeholder to ensure stanza content even if
                        // the following #include/#verbatim file is empty
#verbatim <systems/down_systems.cfg>

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

// script macros

#include <macros/logs_system_alarms_macros.cfg>
#include <macros/logs_pikt_alarms_macros.cfg>
#include <macros/files_alarms_macros.cfg>
#include <macros/script_alarms_macros.cfg>
#include <macros/network_alarms_macros.cfg>
#include <macros/downage_alarms_macros.cfg>
#include <macros/process_alarms_macros.cfg>

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

// web server macros

#include <macros/doc_macros.cfg>
#include <macros/html_macros.cfg>

#include <macros/adm/httpd_macros.cfg>

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

(A note about page layout:  In the interest of readability, we have added artificial line wraps in many examples.  Even though displayed here broken up across several screen lines, in general quoted strings, preprocessor directives, macro definitions, .log & .conf entries, and so on should all be unbroken on a single line.)

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
View sample
syslog scan
Pikt script