Page 1 of 1

How to change the sender's name in Notification

Posted: Fri Jun 12, 2020 12:15 am
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.

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

Posted: Fri Jun 12, 2020 4:10 pm
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

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

Posted: Mon Jun 15, 2020 12:55 am
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.

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

Posted: Wed Jun 17, 2020 4:56 pm
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.

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

Posted: Thu Jun 18, 2020 10:56 pm
by Pratapa
This did not work.