Want to use my company's email id to send the notification

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
vimalparikh
Posts: 10
Joined: Fri Jan 13, 2017 10:50 am

Want to use my company's email id to send the notification

Post by vimalparikh »

Dear Team,

MY nagios version is 4.1.1 and I am using centos 7

My problem is that right now I am able to get notification from nagios@localhost.localdomain, but i want to chnage it to my officail email id as this address gets blocked on my official mail-server.

Please suggest the necessary steps to do the needful.

Regards,
Vimal Parikh
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Want to use my company's email id to send the notificati

Post by npolovenko »

Hello, @vimalparikh.
Please navigate to:

Code: Select all

/usr/local/nagios/etc/objects/
Open the commands.cfg file. Two commands that we need to chnage are notify-host-by-email and notify-service-by-email. After /usr/bin/print part add the following:

Code: Select all

-r $ADMINEMAIL$
. Save and exit. Next, go up one directory:

Code: Select all

/usr/local/nagios/etc/
And open: nagios.cfg file. Find the line that says: admin_email and chnage the value to whatever you want it to be.
Save and exit.
Restart Nagios with:

Code: Select all

service nagios restart
service httpd restart
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
vimalparikh
Posts: 10
Joined: Fri Jan 13, 2017 10:50 am

Re: Want to use my company's email id to send the notificati

Post by vimalparikh »

Hello @npolovenko,

I have did as you suggested still Email_ID is not got chnaged , its remained as it is. Please suggest

Output of /usr/local/nagios/etc/objects/command.cfg
'notify-host-by-email' command definition
define command{command_name notify-host-by-emailcommand_line /usr/bin/printf -r $ADMINEMAIL$ "%b" "***** Nagios *****\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$}

# 'notify-service-by-email' command definition
define command{command_name notify-service-by-emailcommand_line /usr/bin/printf -r $ADMIEMAIL$ "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETTIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **"

Output of /usr/local/nagios/etc/nagios.cfg

admin_email=xxx@gmail.com
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Want to use my company's email id to send the notificati

Post by npolovenko »

@vimalparikh, I told you to put it in a wrong spot. Please remove -r $ADMINEMAIL$ after /usr/bin/printf and add it after /bin/mail. Like this:

Code: Select all

    /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -r $ADMINEMAIL$ -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
Then restart nagios with service nagios restart.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked