We've moved to a new support system!

The Nagios Answer Hub is a place where you can get help with technical questions from our experts. There, you can quickly open tickets and join discussion boards.

Request Nagios Answer Hub access here: https://info.nagios.com/answer-hub-access-new-users

After completing the access form, you will be given access to a portal where new tickets can be created. We will keep the old customer forum sections and ticket system available for current cases to be resolved.

Go to the Answer Hub

Email FROM address

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

Email FROM address

Postby dwtuggle » Tue Jul 03, 2018 3:31 pm

I have a customer running Nagios Core and for the life of me I cannot get the email just right... Everything works except the server is sending alerts as nagios@nagios.domain.com (adding the server name I think) instead of nagios@domain.com and our relay can't handle this.

I've found in other forums where folks say to add the -r nagios@domain.com to the /usr/local/nagios/etc/objects/commands.cfg file and this works but they say at that pint some alerts are missing. Below is what that file looks like after modifications.

Code: Select all
'notify-host-by-email' command definition
define command{
        command_name    notify-host-by-email
        command_line    /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/mail -r nagios@ves.org -s  "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
        }

# 'notify-service-by-email' 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$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /usr/bin/mail -r nagios@ves.org -s  "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
        ]


I see the messages hit my relay and it forcing the FROM address to nagios@ves.org but why does this mess up the alerts (they said they got an alert for UP but not DOWN status on a host) - Have tried editing contacts file and many others to no avail. any input is appreciated.

Here is the nagios.cfg parts to this I think - willing to send anything you might need.


Code: Select all
# 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@ves.org
admin_pager=pagenagios@localhost
Last edited by lmiltchev on Thu Jul 05, 2018 11:57 am, edited 2 times in total.
Reason: Please use [code][/code] tags around long output
dwtuggle
 
Posts: 2
Joined: Tue Jul 03, 2018 3:16 pm

Re: Email FROM address

Postby scottwilkerson » Thu Jul 05, 2018 10:35 am

dwtuggle wrote:I've found in other forums where folks say to add the -r nagios@domain.com to the /usr/local/nagios/etc/objects/commands.cfg file and this works but they say at that pint some alerts are missing. Below is what that file looks like after modifications.


This sounds like the correct fix, are you sure the missing alerts weren't from before the change?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
scottwilkerson
DevOps Engineer
 
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: Email FROM address

Postby dwtuggle » Thu Jul 05, 2018 11:55 am

scottwilkerson,

That was in fact the correct fix if anyone else stumbles upon this thread... Apparently I was given bad information by the customer during testing or something else was off as it is the exact same config as far as I can tell.

If anyone else gets this and wants to change the FROM address for notifications the following DOES work (Nagios Core Version 4.0.8). In the commands.cfg (on this server the path is: /usr/local/nagios/etc/objects/commands.cfg) I modified the sections below and added "-r nagios@domain.com" (minus the quotes) AFTER /usr/bin/mail and BEFORE the -s on both notify-host-by-email AND notify-service-by-email as shown below...


# 'notify-host-by-email' command definition
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/mail -r nagios@domain.com -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}

# 'notify-service-by-email' 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$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /usr/bin/mail -r nagios@domain.com -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}



You will know this is working by looking at /var/log/maillog and should see something like the below: Nagios.domain.com: nagios set sender to nagios@domain.com using -r

Jul 5 11:57:03 Nagios sendmail[24515]: w65Fv3in024515: Authentication-Warning: Nagios.domain.com: nagios set sender to nagios@domain.com using -r
Jul 5 11:57:03 Nagios sendmail[24515]: w65Fv3in024515: from=nagios@domain.com, size=530, class=0, nrcpts=1, msgid=<5b3e3fce.+t3S3BaOtg1HCGEg%nagios@domain.com>, relay=nagios@localhost
Jul 5 11:57:03 Nagios sendmail[24516]: w65Fv3IS024516: from=<nagios@domain.com>, size=763, class=0, nrcpts=1, msgid=<5b3e3fce.+t3S3BaOtg1HCGEg%nagios@domain.com>, proto=ESMTP, daemon=MTA, relay=localhost [127.0.0.1]
Jul 5 11:57:03 Nagios sendmail[24515]: w65Fv3in024515: to=nagios@domain.com, ctladdr=nagios@domain.com (1001/1001), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30530, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (w65Fv3IS024516 Message accepted for delivery)
Jul 5 11:57:03 Nagios sendmail[24518]: w65Fv3IS024516: to=<nagios@domain.com>, delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=120763, relay=relay.domain.com. [192.168.3.254], dsn=2.0.0, stat=Sent ( <5b3e3fce.+t3S3BaOtg1HCGEg%nagios@domain.com> Queued mail for delivery)


Thanks for the assist and confirmation Scott! This can now be marked as resolved. There might be a better way to do it directly through SendMail/PostFix/whatever but hopefully this might help the next person that comes along.

dt
dwtuggle
 
Posts: 2
Joined: Tue Jul 03, 2018 3:16 pm


Return to Community Support

Who is online

Users browsing this forum: No registered users and 14 guests