This question pops up from time to time and it looks like people are for some reason lurking in dark.  Not sure why, but I decided to shine on some light on this at most basic level.  People wish to have email notifications based on some rules.  I base my approach on AIX, HPUX, Solaris and Linux.  In short, this s not tested only under Windows.  Example I will discuss is on Linux, but in essence it is the same on other UNIX flavors (changes mostly come from different paths used).


OK, here is example.  I use script which I called nsrcli where I put in all that I can think of that I would (or could) use one day.  Specific functions are called via specific switches.  For savegrp notification I have:




One of them, failure one I believe, is default one.  This one sends email to localhost to root account.  I have that one.  Then we have savegrp completion which I modified and instructed to write onto /nsr/logs/savegrp.log.  You can use whatever you want of course.  I never use this log and from time to time it will grow huge so trim it.


savegrp failure however I duplicated (because I could not modify original one, at least in NW8) and there I instructed NW to call /usr/sbin/nsrcli -G -N -sf  (which in my world is my swiss knife script; -G means operations with groups, -N is for notification management and -sf is savegroup failures).  There are two kinds of failures as far as I'm concerned:

  • failed groups (one or more clients)
  • group already running


I always wanted to get some sort of email where from subject I could see what failed as that would be kind of modern beeper to me.  So, I simply made this simple approach.  If we look at the script and part of the code where this is called we see:




It makes sense to do it in similar fashion if this is part of multipurpose script - if not you don't need it this way nor you need to call separate functions.  In my case, this is handled by function called sgroup_fail_ntfc.  The function itself is quite simple:




cat $* > $OUT_TEMP

GROUP1=`cat $OUT_TEMP | grep "(alert)" | cut -f2 -d\) | $AWK '{print $1}'`

GROUP2=`cat $OUT_TEMP | grep "(alert)" | cut -f2 -d\) | $AWK '{print $2}'`

CLIENT=`cat $OUT_TEMP | grep Failed: | $AWK 'BEGIN {FS="Failed: "};{print $2}' | sed 's/.<domain1>//g;s/.<domain2>//g;s/.<domain3>//g;s/.<domain4>//g;s/.<domain5>//g'`

ARC=`cat $OUT_TEMP | grep "aborted, savegrp is already running" | wc -l`

if [ "$ARC" -ne "0" ]; then

        cat $OUT_TEMP | mail_sn_ar


        cat $OUT_TEMP | mail_sn_fail




My clients can be part of 5 domains.  In report, as client failed is part of subject line for email, I do not wish to see domain as line might just be to big.  So, I simply cut off those so that line listing host(s) would only have. Next, depending on if this is real failure (fail) or group already running (ar), I have two actions/functions: mail_sn_ar and mail_sn_fail.  Here they are:



$MAIL -r -s "$(/usr/bin/uname -n): Group $GROUP2 is already running - check email and logs"




$MAIL -r -s "$(/usr/bin/uname -n): Group $GROUP1 has failed for client(s) $CLIENT - check email and logs"



Obviously $MAIL here will depend on which mail program you use (in my case I use case statement to determine OS and based on that I set number of variables where mail is just one of them).  Also, your organization might not have requirement for return address to be be noreply@whatever, but most companie use this to control emails sent from intranet machines and to make sure no return to the address is possible.


In the end, you get something like:



You can extend this further with use of imagination, but try not to complicate too much.


Inevitable question is if this will also work with NW9 and I doubt it will as savegrp is no longer what it used to be.  I didn't check NW9 notification yet, but certainly I will have to adjust this once I go there.