About Me

My photo
Kalyan Kumar Pasupuleti B-Tech(Information Technology). • AWS Certified Solutions Architect - Associate • RedHat Certified Engineer(RHCE) • Directory Services and Authentication Certificate of Expertise(LDAP) • Red Hat SELinux Policy Administration Certificate of Expertise(SELinux) • Network Services Security Certificate of Expertise (Network Services) • RedHat Certified Virtualization Administrator(RHCVA) • Red Hat Certified Security Specialist (RHCSS) Working as Cloud DevOps engineer

Tuesday, February 11, 2014

How to enable Nagios Serivce Acknowledgement Comments in Emails?

If you would like to see acknowledgement comments in the Nagios email alerts that get sent so that the other admins do not need to login to Nagios GUI and view the comment, You need to do some changes in the commands.cfg file.

What to do?

Modify the command “notify-service-by-email” in the commands.cfg file. 
You just need to add “\nNotes: $SERVICEACKCOMMENT$”  before “/bin/mail” as shown in below command definition:

# vim /usr/local/nagios/etc/objects/commands.cfg
# 'notify-service-by-email' command definition
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\nNotes: $SERVICEACKCOMMENT$" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
        }

 Save and exit.


Thats it, reload nagios service  - /etc/init.d/nagios reload

Now acknowledge any WARNING/CRITICAL alert and check the mail along with the comment/acknowledgement.