Mail Macros

[posted 2001/06/07]

Recently, we had an episode where, due to some NIS failures, also a downage of our GNU Mailman list server, some crucial PIKT alert e-mail was not delivered in a timely fashion.

We had configured our mail macros, in macros.cfg, this way (which should be familiar to you if you've ever looked closely at the configs_samples):

// pikt-emergency, for example, is an NIS alias set to various sysadmins;
// we could make such addresses PIKT macros, i suppose

brahms          brahms\@hamburg
bach            bach\@moscow
bruch           bruch\@moscow
liszt           liszt\@moscow
schubert        franz.schubert\@egbdf.uppity.edu

// for emergency alerts (and similarly, for all following), if we have
// #define'd test (we are running in test mode), send alerts to brahms, else
// if the current host is a newsys or a testsys, send alerts to brahms, else
// if the current host is a db (phd) machine, send alerts to the
// pikt-emergency addressees (the unix sysadmins) and also the pikt-db
// (pikt-phd) addressees (the dbadmins (the phdadmins)), else for all other
// machines just send to the pikt-emergency addressees (the unix sysadmins)

#  ifdef test
piktemergency
        =brahms
#  elsedef
piktemergency
#    if newsys | testsys
        =brahms
#    else
#      if phd
        pikt-emergency // pikt-phd
#      elif db
        pikt-emergency pikt-db
#      else
        pikt-emergency
#      endif
#    endif
#  endifdef

#  ifdef test
pikturgent
        =brahms
#  elsedef
pikturgent
...                     [much more of the same]

Then, as the first comment above indicates, we set the various pikt NIS aliases in a separate /etc/NIS/aliases file on our NIS server:

# these are pikt aliases
pikt-admin: brahms@hamburg.uppity.edu
pikt-test: brahms@hamburg.uppity.edu
pikt-debug: brahms@hamburg.uppity.edu

pikt-emergency: systems@egbdf.uppity.edu, borodin@egbdf.uppity.edu
pikt-urgent: systems@egbdf.uppity.edu
pikt-critical: systems@egbdf.uppity.edu
#pikt-emergency: brahms@hamburg.uppity.edu
#pikt-urgent: brahms@hamburg.uppity.edu
#pikt-critical: brahms@hamburg.uppity.edu
pikt-warning: systems@egbdf.uppity.edu
pikt-notice: brahms@hamburg.uppity.edu, johann.bach@egbdf.uppity.edu
pikt-info: brahms@hamburg.uppity.edu, johann.bach@egbdf.uppity.edu
pikt-security: systems@egbdf.uppity.edu, piktm@bayreuth.uppity.edu
pikt-db: franz.schubert@egbdf.uppity.edu, bedrich.smetana@egbdf.uppity.edu,
  alexander.borodin@egbdf.uppity.edu, ruggero.leoncavallo@egbdf.uppity.edu
#pikt-db: brahms@hamburg.uppity.edu

If we had this mailcmd statement in alerts.cfg

        mailcmd         "=mailx -s 'PIKT Alert on =pikthostname:
                                    EMERGENCY' =piktemergency"

=piktemergency might resolve to pikt-emergency in piktd.conf like this

10,25,40,55 * * * * 5 /usr/bin/nice --5 /pikt/bin/pikt +M "/usr/bin/mailx -s
  'PIKT Alert on vienna: EMERGENCY' pikt-emergency" +L "/bin/lp -d w309ps"
  +A EMERGENCY

where pikt-emergency is an NIS alias resolving to

systems@egbdf.uppity.edu, borodin@egbdf.uppity.edu

where systems@egbdf was a GNU Mailman mailing list.

Confusing, no?  Moreover, there are at least two points of failure there: NIS, and GNU Mailman.  Furthermore, I found myself constantly fiddling with the NIS aliases file (which is not yet under PIKT management), commenting and uncommenting and changing entries, then remaking the NIS alias map.

There had to be a better way, and of course there is.  This is how we now do it:

// try to use actual addresses, not NIS aliases or references to GNU Mailman
// lists, just in case of NIS or GNU Mailman breakdown

// systems
brahms          brahms\@hamburg         // johannes.brahms\@egbdf
bach            bach\@moscow            // johann.bach\egbdf
bruch           bruch\@moscow           // max.bruch\@egbdf
liszt           liszt\@moscow           // franz.liszt\@egbdf
purcell         purcell\@moscow         // henry.purcell\@egbdf

systems         =brahms =bach =bruch =liszt =purcell

piktadmin       =brahms                 // pikt head honcho

// dbas
leoncavallo     leoncavallo\@moscow     // ruggero.leoncavallo\@egbdf
smetana         smetana\@moscow         // bedrich.smetana\@egbdf
borodin         borodin\@moscow         // alexander.borodin\@egbdf

// dba emeritus
schubert        schubert\@moscow        // franz.schubert\@egbdf

dbas            =leoncavallo =smetana =borodin

dbadmin         =leoncavallo            // dba head honcho

// the various pikt- macros, the addresses that the alerts.cfg mailcmd sends to

pikt-admin      =piktadmin
pikt-debug      =piktadmin
pikt-test       =piktadmin

#ifndef test

#  if ! ( newsys | testsys )

pikt-emergency  =systems
#    if db
                         =dbas
#    endif

pikt-urgent     =systems
#    if db
                         =dbadmin
#      if milan
                                  =borodin
#      endif
#    endif

pikt-critical   =systems
#    if athens2 | athens4
                         =dbadmin
#    endif

pikt-warning    =systems
#    if athens2 | athens4
                         =dbadmin
#    endif

pikt-notice     =brahms =bach =bruch
pikt-info       =brahms =bach =bruch

pikt-security   =systems

pikt-db         =dbas

#  else  // ! ( newsys | testsys )

pikt-emergency  =piktadmin
pikt-urgent     =piktadmin
pikt-critical   =piktadmin
pikt-warning    =piktadmin
pikt-notice     =piktadmin
pikt-info       =piktadmin
pikt-security   =piktadmin
pikt-db         =piktadmin

#  endif  // ! ( newsys | testsys )

#elsedef  // test

pikt-emergency  =piktadmin
pikt-urgent     =piktadmin
pikt-critical   =piktadmin
pikt-warning    =piktadmin
pikt-notice     =piktadmin
pikt-info       =piktadmin
pikt-security   =piktadmin
pikt-db         =piktadmin

#endifdef  // test

The mailcmd statement in alerts.cfg is now

        mailcmd         "=mailx -s 'PIKT Alert on =pikthostname:
                                    EMERGENCY' =pikt-emergency"

(See the slight difference?  =piktemergency was changed to (hyphenated) =pikt-emergency.)

=pikt-emergency might resolve, on vienna, in piktd.conf like this

10,25,40,55 * * * * 5 /usr/bin/nice --5 /pikt/bin/pikt +M "/usr/bin/mailx -s
  'PIKT Alert on vienna: EMERGENCY' brahms\@hamburg bach\@moscow bruch\@moscow
  liszt\@moscow purcell\@moscow" +L "/bin/lp -d w309ps" +A EMERGENCY

On the athens2 machine, =pikt-emergency would add the appropriate addresses:

10,25,40,55 * * * * 5 /usr/bin/nice --5 /pikt/bin/pikt +M "/usr/bin/mailx -s
  'PIKT Alert on athens2: EMERGENCY' brahms\@hamburg bach\@moscow bruch\@moscow
  liszt\@moscow purcell\@moscow leoncavallo\@moscow
  smetana\@moscow borodin\@moscow"
  +L "/bin/lp -d w309ps" +A EMERGENCY

The new advantages:

  • piktd.conf now routes alert e-mail directly to the appropriate mailboxes, not indirectly through NIS and GNU Mailman, thereby removing two potential points of failure.
  • We no longer have to worry about maintaining pikt aliases in the NIS aliases file (they have all been removed).
  • For PIKT purposes, we no longer have to worry about maintaining the correct GNU Mailman list memberships.
  • The mail macros setup in the new macros.cfg is, I think, easier to understand and maintain than the old.
  • I can easily slip into test mode everywhere (with all alert e-mail going to =piktadmin, i.e., =brahms, i.e., me) simply with
      # piktc -erv +D test +H all
    
    Before, I would have to edit and remake the NIS aliases maps.  Now, I can manage everything in the PIKT config and with the appropriate piktc commands.

In short, we now have a much more reliable and maintainable setup than previously.

In your setup, maybe this sort of sophistication and complexity is overkill. Okay, but at least you have the choice to Have It Your Way.  I have demonstrated two radically different ways of organizing the alert e-mail addresses.  Maybe Your Way is radically simpler, or radically different in some other complex way. As always, PIKT gives you choice.

Open Hand For more examples, see Developer's Notes.

 
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-02-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
Mailman list
membership changes
Pikt script