Page 1 of 1
Want to use my company's email id to send the notification
Posted: Thu Dec 28, 2017 7:49 am
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
[email protected], 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
Re: Want to use my company's email id to send the notificati
Posted: Thu Dec 28, 2017 12:16 pm
by npolovenko
Hello,
@vimalparikh.
Please navigate to:
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:
. Save and exit. Next, go up one directory:
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
Re: Want to use my company's email id to send the notificati
Posted: Fri Dec 29, 2017 5:55 am
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=
[email protected]
Re: Want to use my company's email id to send the notificati
Posted: Fri Dec 29, 2017 12:42 pm
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.