Page 1 of 2

Changing from address in email notification

Posted: Wed Nov 16, 2016 7:08 am
by yunushaikh
I am trying to change the "send from" address from the manage email alerts option. When I test the email after updating the settings it sends email correctly using that email id. But when the notification comes from host or service it is coming by default email id of the server "nagios@ipaddress"
Can you please help me in troubleshooting this problem?

Re: Changing from address in email notification

Posted: Wed Nov 16, 2016 11:37 am
by rkennedy
It sounds like you may have notify-host-by-email assigned to your contact, instead of xi_host_notification_handler. (and also the same service reciprocals)

You'll want to adjust this, as xi_host_notification_handler is what respects the Manage Email Settings page, where as the notify-host-by-email just uses sendmail.

If that doesn't help, please post the contact definition for us to look at.

Re: Changing from address in email notification

Posted: Thu Nov 17, 2016 7:11 am
by yunushaikh
rkennedy wrote: please post the contact definition for us to look at.
define contact {
contact_name <Name>
alias <Name >
host_notifications_enabled 1
service_notifications_enabled 1
host_notification_period 24x7
service_notification_period 24x7
host_notification_options d,u,r,f,s,
service_notification_options w,u,c,r,f,s,
host_notification_commands xi_host_notification_handler
service_notification_commands xi_service_notification_handler
can_submit_commands 1
retain_status_information 1
retain_nonstatus_information 1
email <here it is a company email id>
use xi_contact_generic
}

I configured this with xi notification handler but still it does not work. I did 1 more thing, I created only a contact and set the notification command to notify-service-by-email and edited the command with -r option for /bin/mail. That option is sending an email from the email id which I want.
But I need this to work from the Nagios XI email setting feature. Please help and let me know if you need any more information. I can send you the service definition also which I am using for monitoring.
define service {
host_name localhost
service_description Service Status - ntpd
use local-service
check_command check_xi_service_status!ntpd!!!!!!!
initial_state o
max_check_attempts 1
check_interval 2
retry_interval 1
active_checks_enabled 1
check_period 24x7
event_handler nagios_otrs
event_handler_enabled 1
flap_detection_enabled 0
flap_detection_options o,w,c,u,
process_perf_data 1
notification_interval 5
notification_period 24x7
notification_options w,c,u,r,f,s,
notifications_enabled 1
contacts <Contact is present which is configured>
register 1
}

Re: Changing from address in email notification

Posted: Thu Nov 17, 2016 7:22 am
by yunushaikh
One more thing I would like to highlight is that I tried to check maillog when the alert gets triggered but there is nothing triggered in maillog for sending an email when I configure xi-service-notification-handler
Hope this will help you for some troubleshooting.

Re: Changing from address in email notification

Posted: Thu Nov 17, 2016 11:29 am
by rkennedy
Can you show us a screenshot of the manage email settings page? I believe it will need to be modified here for the xi_host_notification_handler commands.

The notify-host-by-email works because it's sending right to /bin/mail with your specified options.

Re: Changing from address in email notification

Posted: Thu Nov 17, 2016 12:25 pm
by yunushaikh
Please check the screenshot and let me know if any changes needs to be done

Re: Changing from address in email notification

Posted: Thu Nov 17, 2016 5:21 pm
by ssax
Please send the output of this command:

Code: Select all

alternatives --display mta
Also, please go to Admin > Manage Email Settings
- Check the Debug Log option
- Click the Update Settings button

Then generate some test emails and send us the contents of /usr/local/nagiosxi/tmp/phpmailer.log.

Thank you

Re: Changing from address in email notification

Posted: Thu Nov 17, 2016 5:40 pm
by avandemore
Please attach /var/log/maillog after one of these failed send attempts.

Re: Changing from address in email notification

Posted: Thu Nov 17, 2016 11:56 pm
by yunushaikh
ssax wrote:Please send the output of this command:

Code: Select all

alternatives --display mta
alternatives --display mta
mta - status is auto.
link currently points to /usr/sbin/sendmail.sendmail
/usr/sbin/sendmail.postfix - priority 30
slave mta-pam: /etc/pam.d/smtp.postfix
slave mta-mailq: /usr/bin/mailq.postfix
slave mta-newaliases: /usr/bin/newaliases.postfix
slave mta-rmail: /usr/bin/rmail.postfix
slave mta-sendmail: /usr/lib/sendmail.postfix
slave mta-mailqman: /usr/share/man/man1/mailq.postfix.1.gz
slave mta-newaliasesman: /usr/share/man/man1/newaliases.postfix.1.gz
slave mta-aliasesman: /usr/share/man/man5/aliases.postfix.5.gz
slave mta-sendmailman: /usr/share/man/man1/sendmail.postfix.1.gz
/usr/sbin/sendmail.sendmail - priority 90
slave mta-pam: /etc/pam.d/smtp.sendmail
slave mta-mailq: /usr/bin/mailq.sendmail
slave mta-newaliases: /usr/bin/newaliases.sendmail
slave mta-rmail: /usr/bin/rmail.sendmail
slave mta-sendmail: /usr/lib/sendmail.sendmail
slave mta-mailqman: /usr/share/man/man1/mailq.sendmail.1.gz
slave mta-newaliasesman: /usr/share/man/man1/newaliases.sendmail.1.gz
slave mta-aliasesman: /usr/share/man/man5/aliases.sendmail.5.gz
slave mta-sendmailman: /usr/share/man/man8/sendmail.sendmail.8.gz
Current `best' version is /usr/sbin/sendmail.sendmail.


I enabled debug log and there is no log getting generated in phpmailer.log. I think the command is not able to send the email itself.
avandemore wrote:/var/log/maillog
Logs are also not getting generated in maillog file as the mail is not getting triggered from xi_service_notification_command

Re: Changing from address in email notification

Posted: Fri Nov 18, 2016 12:01 pm
by ssax
Please run this command and see if it resolves the issue:

Code: Select all

alternatives --set mta /usr/sbin/sendmail.postfix

If that doesn't fix it, revert with this command:

Code: Select all

alternatives --set mta /usr/sbin/sendmail.sendmail
Let us know the results.


Thank you