How to Change Nagios alerts sender Email address

How to Change Nagios alerts sender Email address ?

There is a way to change the senders email address using Nagios ,Changing Nagios alerts sender Email ID is needed to assign specific Email ID  to avoid default sender Email ID.  If you have multiple Nagios servers to monitor IT infrastructure resource, it’s difficult to know from server the alert triggered.
To Change Nagios Alerts Sender ID, fallow the steps as indicated below.

Step1

SendEmail is a lightweight, command line SMTP email client. If you have the need to send email from a command line, this free program is perfect:
SendEmail is licensed under the GNU GPL, either version 2 of the License or (at your option) any later version.
[Supported Platforms: Linux, BSD, OS X, Windows 98, Windows NT, Windows 2000, & Windows XP]
You have to download SendEmail software tool from below link

On Linux
# wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz

On Windows

http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz

sendEmail installation instruction  Under Linux (Redhat , Fedora  or Centos)

1) Extract the package
  # tar -zxvf sendEmail-v1.XX.tar.gz
2) Copy the sendEmail script to /usr/local/bin
  #cp -a sendEmail-v1.XX/sendEmail /usr/local/bin
3) Make sure its executable
  #chmod +x /usr/local/bin/sendEmail
4) Run it to check sendEmail is working correctly
#sendEmail
or
#/usr/local/bin/sendEmail -f abc@abc.com -t xyz@abc.com

Step2

Go to /usr/local/nagios/etc/objects
#cd /usr/local/nagios/etc/objects

Edit the file command.cfg  ( replace email notification command  for notify-host-by-email & notify-service-by-email as indicated below.)

# vi commands.cfg

# ‘notify-host-by-email’ command definition
define command{
command_name    notify-host-by-email
command_line    /usr/bin/printf “%b” “***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n” |/usr/local/bin/sendEmail -s $USER7$ -xu $USER5$ -xp $USER6$ -t $CONTACTEMAIL$ -f $USER5$ -l /var/log/sendEmail -u“** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **” $CONTACTEMAIL$
}
# ‘notify-service-by-email’ command definition
define command
command_name    notify-service-by-email
command_line    /usr/bin/printf “%b” “***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService:         $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAddi        tional Info:\n\n$SERVICEOUTPUT$\n” | /usr/local/bin/sendEmail -s $USER7$ -xu $USER5$ -xp $USER6$ -t $CONTACTEMAIL$ -f         $USER5$ -l /var/log/sendEmail -u “** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ *        *” $CONTACTEMAIL$
}

Step3

Go to /usr/local/nagios/etc

#cd /usr/local/nagios/etc

Edit resource.cfg ( add below entries at bottom of the file)

#vi resource.cfg

# Specify Nagios Alerts sender Email ID
$USER5$=abc@xyz.com
#Specify Nagios Alerts sender Email ID password
$USER6$=password
#Specify  SMTP server address
$USER7$=192.168.10.1

Step4

Finally restart the Nagios services changes to take effect  by issue command indicated as below.

#service nagios restart

Both comments and pings are currently closed.

Comments are closed.

Copyright ©Solutions@Experts.com
Copyright © NewWpThemes Techmark Solutions - www.techmarksolutions.co.uk