Page 3 of 3

Re: E-mail question during Trial

Posted: Fri May 21, 2010 1:04 pm
by mmestnik
e-mail filters applied by email servers work by default on envelope, not headers. I should have been more insistent to get this information from you.

by mmestnik ยป Mon May 10, 2010 1:54 pm

Also note that you can't effect the Envelope, only the email's Headers.

Re: Sending notifications emails problem

Posted: Fri May 21, 2010 1:16 pm
by mikemasters
So what is the point of having a "send mail from" option in the mail settings if all the alerts are going to be coming from nagios@hostname. No matter what you put in the field.?

Re: Sending notifications emails problem

Posted: Fri May 21, 2010 1:23 pm
by mmestnik
This field sets the email Headers. This counts as a much better configuration option.

The value here is not supposed to be an email address, it should be a contact label like this:
"This is a message from Nagios XI" <[email protected]>

The backend email address used to send messages as part of the envelope is of vastly less concern, changing it would only effect mail servers. The far simpler solution to your problem is to change the mail server to accept any mail coming from this IP as long as it's only destined for one of your domains or a small list of your users(if they choose to use there yahoo account.). That's the rule I'd put into place.

Re: Sending notifications emails problem

Posted: Fri May 21, 2010 1:39 pm
by mikemasters
Not suppose to be a e-mail address ??????

Here are the headers from the 2 different e-mails.

When sent from the Web-interface...If you see the reply to address is what the value is in the web interface.

Received: (from apache@localhost)
by hv-nagios (8.13.8/8.13.8/Submit) id o4LIHUj5005909;
Fri, 21 May 2010 13:17:30 -0500
X-Authentication-Warning: hv-nagios: apache set sender to [email protected] using -f
To: [email protected]
Subject: Nagios XI Email Test
Date: Fri, 21 May 2010 13:17:30 -0500
From: [email protected]
Reply-to: [email protected]
----------------------------------------------------------------------------------------------------------------------------------------------------
When there is an alarm condition, header from that message....

Received: (from nagios@localhost)
by hv-nagios (8.13.8/8.13.8/Submit) id o4L5Q8jR008427
for [email protected]; Fri, 21 May 2010 00:26:08 -0500
Date: Fri, 21 May 2010 00:26:08 -0500
From: nagios@hv-nagios
Message-Id: <201005210526.o4L5Q8jR008427@hv-nagios>
To: [email protected]
Subject: ** RECOVERY Host Alert:
----------------------------------------------------------------------------------------------------------------------------------------------------

The first one is sent from Apache, is why it comes thru correctly, and nagios is sending the e-mail from command line so it comes thru as the user......
Is this how it was setup to work? And the only time you would get a e-mail from the "send from address" is when you send notifications thru Apache Web interface.? all the alerts will come thru as the nagios user.? There is no way to change this?

The e-mails come thru fine, but I have filters that sort e-mail on the server by where/who they come from, (I.E. prod,Dev,test,hotsite.) I just did not want to add another filter just for nagios, because if I put in 2 XI servers, on for Prod, one for Hotsite, I want be able to filter the e-mails. and not see all of them come in from nagios.
Sorry for the long message. but trying to save myself time setting up new filters. and have not had this issue with anything else.

Re: Sending notifications emails problem

Posted: Fri May 21, 2010 3:12 pm
by mikemasters
OK, I finally figured it out...... I first changed the template as suggested for the contact to xi_contact_generic, and that did not work still got e-mails as nagios@hostname....

I looked at the host commands and service commands under common settings, and they were set to notify-host-by-email, and that used the Linux mail command. I see where the commands xi_host_notification_handler uses PHP to send e-mail.
I changed the host commands and service commands to use xi_host_notification_handler and xi_service_notification_handler and the e-mails now come thru as hotsite@domainname.


Sorry if that is what you were trying to tell me, I thought you wanted me to just change the template for the contact, not the commands.... I thought by changing the settings in the web interface mail settings to SMTP I was changing all e-mail to use PHP. But you have to change each contact.... so you could have one contact using senmail, and another using PHP, it is not a global setting.

Thanks for sticking with me on this...

Re: Sending notifications emails problem

Posted: Sat May 22, 2010 10:26 pm
by mmestnik
This is the first time any one has reported needing to change anything other then the template for nagiosadmin.

Could you speculate as to how things got to be that way?

Host and service commands take on a different meaning in Nagios. Command Objects are used to restrict Nagios from ruining arbitrary commands, there are two+ varieties Check and Notification. A Service Object or Host Object references what commands it uses. The notification command should be set using the xi_generic_service or xi_generic_host template. If your objects were using the generic templates instead of the xi_generic templates, that would account for this problem.

Re: Sending notifications emails problem

Posted: Mon May 24, 2010 3:40 pm
by mikemasters
So if that value is in the template then i don't need to put anything in host and service commands? And from what I found out is that what ever is in the host and service commands fields take priority over whats in the template? I assumed that since the command field was marked with a asterick then I had to have something in there.

Below is how I was able to fix my issue.

this was a straight XI virtual deploy, nagiosadmin is the default user, I put in my e-mail address as nagios admin and change the host commands and the service commands to the first ones that were on the list, notify-host-by-email and notify-service-by-email. At first it was set to use the generic template, Changed the template to the Xi template did not resolve.

Pre-fix
Under contacts, nagios admin user is set under Misc settings to be using the xi_contact-generic template....... under common settings it was set to use notify-host-by-email, and notify-service-by-email..... When these were set this way e-mails came thru as nagios@localhost....... Which uses the /bin/mail command to send e-mails:
/usr/bin/printf "%b" "***** Nagios Monitor XI Alert *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$




after-fix
I changed the settings under common, host command and service command to use xi_host_notification_handler and xi_service _notification_handler, and the e-mails now come thru with the sender that I put in the web interface.... [email protected]. There commands use the PHP mailer script

/usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php --notification-type=host --contact="$CONTACTNAME$" --contactemail="$CONTACTEMAIL$" --type=$NOTIFICATIONTYPE$ --escalated="$NOTIFICATIONISESCALATED$" --author="$NOTIFICATIONAUTHOR$" --comments="$NOTIFICATIONCOMMENT$" --host="$HOSTNAME$" --hostaddress="$HOSTADDRESS$" --hostalias="$HOSTALIAS$" --hoststate=$HOSTSTATE$ --hoststateid=$HOSTSTATEID$ --lasthoststate=$LASTHOSTSTATE$ --lasthoststateid=$LASTHOSTSTATEID$ --hoststatetype=$HOSTSTATETYPE$ --currentattempt=$HOSTATTEMPT$ --maxattempts=$MAXHOSTATTEMPTS$ --hosteventid=$HOSTEVENTID$ --hostproblemid=$HOSTPROBLEMID$ --hostoutput="$HOSTOUTPUT$" --longhostoutput="$LONGHOSTOUTPUT" --datetime="$LONGDATETIME$"

Re: Sending notifications emails problem

Posted: Mon May 24, 2010 3:49 pm
by mmestnik
mikemasters wrote:So if that value is in the template then i don't need to put anything in host and service commands? And from what I found out is that what ever is in the host and service commands fields take priority over whats in the template? I assumed that since the command field was marked with a asterick then I had to have something in there.
It's odd, I'm not sure why they have '*'. The point of templates is to make sure there is never anything left out, think of templates as a way of having a default set of values. Templates are often made of templates, much like CSS.
Cont mikemasters wrote:Below is how I was able to fix my issue.

this was a straight XI virtual deploy, nagiosadmin is the default user, I put in my e-mail address as nagios admin and change the host commands and the service commands to the first ones that were on the list, notify-host-by-email and notify-service-by-email. At first it was set to use the generic template, Changed the template to the Xi template did not resolve.
This is the wrong setting for XI. Let the notification settings be set by the Xi template. They should be something like xi_event_handler.

Re: Sending notifications emails problem

Posted: Mon May 24, 2010 3:59 pm
by mikemasters
Thanks I think I understand, i will have to check it out, let the templates do the event handling, and leave the command section blank,
I guess this is good to know that the commands will take precedence over the templates in case i see the issue again.