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
Want to use my company's email id to send the notification
-
- Posts: 10
- Joined: Fri Jan 13, 2017 10:50 am
-
- 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
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:
Please navigate to:
Code: Select all
/usr/local/nagios/etc/objects/
Code: Select all
-r $ADMINEMAIL$
Code: Select all
/usr/local/nagios/etc/
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.
-
- Posts: 10
- Joined: Fri Jan 13, 2017 10:50 am
Re: Want to use my company's email id to send the notificati
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
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
-
- 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
@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:
Then restart nagios with service nagios restart.
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$
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.