Skip to main content
Logo

Nagios Email Notifications with Comments

March 25, 2015
1 min read

If you prefer more detail in the email notification of Nagios here is how to add those comments. For example someone acknowledging a service and you want to see the comment they added during acknowledgement.

# pwd
/usr/local/nagios/etc/objects
# more commands.cfg
[..]
define command{
command_name notify-service-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$\n\nACK Comment: $SERVICEACKCOMMENT$\n\nComment: $NOTIFICATIONCOMMENT$\n" | /usr/bin/mailx -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$

Note: I added SERVICEACKCOMMENTSERVICEACKCOMMENT and NOTIFICATIONCOMMENTNOTIFICATIONCOMMENT but I think in newer versions of Nagios SERVICEACKCOMMENTSERVICEACKCOMMENT is deprecated and you only need NOTIFICATIONCOMMENTNOTIFICATIONCOMMENT.

Link: http://nagios.sourceforge.net/docs/3\_0/macrolist.html