How to change the sender's name in Notification

Engage with the community of users including those using the open source solutions.
Includes Nagios Core, Plugins, and NCPA

How to change the sender's name in Notification

Postby Pratapa » Fri Jun 12, 2020 12:15 am

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.
Pratapa
 
Posts: 97
Joined: Tue Oct 01, 2019 1:33 am

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

Postby benjaminsmith » Fri Jun 12, 2020 4:10 pm

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!
User avatar
benjaminsmith
 
Posts: 2866
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

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

Postby Pratapa » Mon Jun 15, 2020 12:55 am

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.
Pratapa
 
Posts: 97
Joined: Tue Oct 01, 2019 1:33 am

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

Postby cdienger » Wed Jun 17, 2020 4:56 pm

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.
User avatar
cdienger
Support Tech
 
Posts: 4436
Joined: Tue Feb 07, 2017 11:26 am

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

Postby Pratapa » Thu Jun 18, 2020 10:56 pm

This did not work.
Pratapa
 
Posts: 97
Joined: Tue Oct 01, 2019 1:33 am


Return to Community Support

Who is online

Users browsing this forum: penukulak and 15 guests