Changing notification user name

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
rajasegar
Posts: 1018
Joined: Sun Mar 30, 2014 10:49 pm

Changing notification user name

Post 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
5 x Nagios 5.6.9 Enterprise Edition
RHEL 6 & 7
rrdcached & ramdisk optimisation
rajasegar
Posts: 1018
Joined: Sun Mar 30, 2014 10:49 pm

Re: Changing notification user name

Post 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
5 x Nagios 5.6.9 Enterprise Edition
RHEL 6 & 7
rrdcached & ramdisk optimisation
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Changing notification user name

Post by lmiltchev »

I'm glad to hear your issue has been resolved! Thanks for the feedback!
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked