Page 1 of 1

Creating Nagios email notifications

Posted: Thu Oct 08, 2020 12:52 pm
by ehanpaul8
Hey there! I need to set up nagios email notifications and I just need pointed in the right direction on how to configure the email server. Everytime I try to research how to get this done it seems as if every article/website I read is different commands, or different approaches. I am running Nagios on a raspberry Pi. Any information would be really appreciated Im kind of stuck on this and need to get this machine deployed to a local hotel.

Re: Creating Nagios email notifications

Posted: Thu Oct 08, 2020 5:21 pm
by benjaminsmith
Hi,
Hey there! I need to set up nagios email notifications and I just need pointed in the right direction on how to configure the email server.
Nagios Core will just use the default MTA on the Linux system. The generic notification handlers are as follows.

HOSTS

Code: Select all

/usr/bin/printf "%b" "***** Nagios Monitor XI Alert *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
SERVICES

Code: Select all

/usr/bin/printf "%b" "***** Nagios Monitor XI Alert *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
Those handler are assigned to the contact objects. Since mail serer is outside of Nagios software, we do not have any docs on configuring Sendmail, Postfix, Exim or other MTAs.

Example Test Notificaiton

Code: Select all

su nagios
/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: CUSTOM\nHost: TESTEMAIL\nState: DOWN\nAddress: 10.1.17.17\nInfo: CRITICAL - Host Unreachable (10.1.17.17)\n\nDate/Time: Fri Nov 22 15:27:11 CST 2019\n" | /usr/bin/mail -s "** CUSTOM Host Alert: TESTEMAIL is DOWN **" ****@***.com
Hope that helps get you started.

Benjamin