How to change the sender's name in Notification

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Pratapa
Posts: 144
Joined: Tue Oct 01, 2019 1:33 am

How to change the sender's name in Notification

Post by Pratapa »

In the notification which users receive, the sender's name is nagios@asadinf.ae.corp

where asadinf.ae.corp is the Nagios production server.

User wants the sender's name as Nagios instead of nagios@asadinf.ce.corp

How can this be achieved. We are using Nagios core.
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: How to change the sender's name in Notification

Post by benjaminsmith »

Hi Pratapa,

After doing some research on this, you should be able to set this in the notification commands for hosts and services by adding -r $ADMINEMAIL$ to the command string.

Take a look at the following thread for more details and let us know how it goes.

how to change the default sender of nagios mail notification
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
Pratapa
Posts: 144
Joined: Tue Oct 01, 2019 1:33 am

Re: How to change the sender's name in Notification

Post by Pratapa »

Following is the service command definition in notifications.cfg

define command {
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nHostname: $HOSTNAME$\nAddress: $HOSTADDRESS$\nResolver Group: $_SERVICERESOLVER_GROUP$\nService Notes: $SERVICENOTESURL$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTNAME$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}


and following is the one which is defined in nagios.cfg file


# ADMINISTRATOR EMAIL/PAGER ADDRESSES
# The email and pager address of a global administrator (likely you).
# Nagios never uses these values itself, but you can access them by
# using the $ADMINEMAIL$ and $ADMINPAGER$ macros in your notification
# commands.

admin_email=nagios@localhost


how should I append $ADMINEMAIL$ in service command definition


I think I should change admin_email=nagios@localhost to admin_email=Nagios in nagios.cfg file.

and I should append $ADMINEMAIL$ as follows in service 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$\nHostname: $HOSTNAME$\nAddress: $HOSTADDRESS$\nResolver Group: $_SERVICERESOLVER_GROUP$\nService Notes: $SERVICENOTESURL$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTNAME$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$ -r $ADMINEMAIL$
}


correct me if I am wrong.
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: How to change the sender's name in Notification

Post by cdienger »

Yes, I believe that should do the trick. From the manual page for the mail command:
-r address
Sets the From address. Overrides any from variable specified in
environment or startup files. Tilde escapes are disabled. The
-r address options are passed to the mail transfer agent unless
SMTP is used. This option exists for compatibility only; it is
recommended to set the from variable directly instead.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Pratapa
Posts: 144
Joined: Tue Oct 01, 2019 1:33 am

Re: How to change the sender's name in Notification

Post by Pratapa »

This did not work.
Locked