Creating Nagios email notifications

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
ehanpaul8
Posts: 1
Joined: Thu Oct 08, 2020 11:28 am

Creating Nagios email notifications

Post 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.
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: Creating Nagios email notifications

Post 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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked