Page 1 of 1

Changing notification user name

Posted: Wed Apr 30, 2014 5:10 am
by rajasegar
Nagios XI Ent 2012R2.9
Manual Install
Red Hat Enterprise Linux 6.5 64 bit

Can you please advice me how to change the name of the sender for email notifications?

Mine is showing nagios, I want it to show NagiosProdXI1
Did some research and some people advised to change the user name in /etc/passwd.
nagios:x:501:501:NagiosProdXI1:/home/nagios:/bin/bash
Changed it however same thing, rebooted the machine still same.

Sending test email from the GUI works fine.

I am using SMTP relay which is configured at OS level in /etc/mail.rc
Only line added was
set smtp=123.123.188.160

Not using the xi_notify_..., but custom email sending script.

This is the command used to send email for host and service.

/usr/bin/printf "%b" "*** Nagiosprodxi1 *****\n\nNotification Type: $NOTIFICATIONTYPE\nHost: $HOSTNAME\nHost Alias: $HOSTALIAS\nState: $HOSTSTATE\nAddress: $HOSTADDRESS\nInfo: $HOSTOUTPUT\n\nDate/Time: $SHORTDATETIME\n" | /bin/mail -s "** $NOTIFICATIONTYPE Host Alert: $HOSTNAME is $HOSTSTATE **" $CONTACTEMAIL

/usr/bin/printf "%b" "*** Nagiosprodxi1 ****\n\nNotification Type: $NOTIFICATIONTYPE\n\nService: $SERVICEDESC\nHost: $HOSTNAME\nHost Alias: $HOSTALIAS\nAddress: $HOSTADDRESS\nState: $SERVICESTATE\n\nDate/Time: $SHORTDATETIME\n\nAdditional Info:\n\n$SERVICEOUTPUT\n" | /bin/mail -s "** $NOTIFICATIONTYPE Service Alert: $HOSTNAME/$SERVICEDESC is $SERVICESTATE **" $CONTACTEMAIL

Thanks

Re: Changing notification user name

Posted: Wed Apr 30, 2014 5:48 am
by rajasegar
I went through so many suggestions until I finally got a solution that works (tested on RHEL 6.5 only)
Need to add the line in bold

strHost=`hostname`
strUser=`whoami`
strFromEmail="$strHost <$strUser@$strHost>"

echo "testing 123" | /bin/mail -s "** EMail Subject **" -r "$strFromEmail>" [email protected]

Hope this spares some headache for those having the same problem.

Here is the code to dynamically build the sender

Re: Changing notification user name

Posted: Wed Apr 30, 2014 9:37 am
by lmiltchev
I'm glad to hear your issue has been resolved! Thanks for the feedback!