The notification script we use for our installation is customized for our needs, but the method is the same. Something similar to the following should work. To get more fancy, consult your local shell scripting guide.
---------------------------- #!/bin/sh CONTACTEMAIL=$1 NOTIFICATIONTYPE=$2 SERVICEDESC=$3 SERVICESTATE=$4 SERVICEACKCOMMENT=$5 SERVICEOUTPUT=$6 [ "NOTIFICATIONTYPE" = "ACKNOWLEDGEMENT" ] && /usr/bin/printf "%b" \ "Service: $SERVICEDESC$\n State: $SERVICESTATE\n Comment: $SERVICEACKCOMMENT" |\ /usr/bin/mail -s "Acknowledged" $CONTACTEMAIL [ "NOTIFICATIONTYPE" = "PROBLEM" ] && /usr/bin/printf "%b" \ "Service: $SERVICEDESC$\n State: $SERVICESTATE\n Info: $SERVICEOUTPUT" |\ /usr/bin/mail -s "Problem" $CONTACTEMAIL [ "NOTIFICATIONTYPE" = "RECOVERY" ] && /usr/bin/printf "%b" \ "Service: $SERVICEDESC$\n State: $SERVICESTATE\n Info: $SERVICEOUTPUT" |\ /usr/bin/mail -s "Ok" $CONTACTEMAIL ------------------------------ -----Original Message----- From: Danny Russell [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 30, 2005 10:48 AM To: Tedman Eng; Deborah Martin; nagios-users@lists.sourceforge.net Subject: RE: [Nagios-users] Manipulation of email notifications Will you share your sample alert-email.sh with us? -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tedman Eng Sent: Wednesday, November 30, 2005 11:46 AM To: 'Deborah Martin'; 'nagios-users@lists.sourceforge.net' Subject: RE: [Nagios-users] Manipulation of email notifications Replace the "one-liner" notification command with an external script. This will let you include any sort of logic you'd like in the script. Pass the nagios variables to the script as arguments. define command{ command_name notify-by-email command_line alert-email.sh $NOTIFICATIONTYPE$ $SERVICEDESC$ $SERVICEACKCOMMENT$... } -----Original Message----- From: Deborah Martin [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 30, 2005 2:04 AM To: 'nagios-users@lists.sourceforge.net' Subject: [Nagios-users] Manipulation of email notifications Hi, Is there a way to manipulate the content of an email by type of email notification ? For example, if I acknowledge a Critical alert with the text 'Under Investigation', I want to include that text in the email notification. However, if I receive a recovery notification I don't need to have the acknowledgement text included. I've configured the following in miscommands.cfg # 'notify-by-email' command definition define command{ command_name notify-by-email command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$ \nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\nAcknowledgements: $SERVICEACKCOMMENT$" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$ } But I do not want ` \nAcknowledgements: $SERVICEACKCOMMENT$ ` on Recovery alerts. The alternative would be to have a default value set of N/A which is overridden with a value if an acknowledgement has been set but I don't see an easy way to do this either. Does anyone have any ideas if it can be done (and how) or that it can't be done like this ? thanks, deborah ************************************************************************ This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. Any unauthorised distribution or copying is strictly prohibited. Whilst Kognitio Limited takes steps to prevent the transmission of viruses via e-mail, we can not guarantee that any email or attachment is free from computer viruses and you are strongly advised to undertake your own anti-virus precautions. Kognitio grants no warranties regarding performance, use or quality of any e-mail or attachment and undertakes no liability for loss or damage, howsoever caused. *********************************************************************** ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click _______________________________________________ Nagios-users mailing list Nagios-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nagios-users ::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. ::: Messages without supporting info will risk being sent to /dev/null ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click _______________________________________________ Nagios-users mailing list Nagios-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nagios-users ::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. ::: Messages without supporting info will risk being sent to /dev/null