Page 1 of 1

Nagios unable to send email via sendmail

Posted: Mon Oct 22, 2018 7:25 am
by rogerjbos
All,

I am using Nagios 4.4.2 on a Debian machine and I have sendmail configured as a gmail relay. I am able to send email via the CLI, but when I go click on "Send custom host notification" to have Nagios send an email, I don't get any email and I get these errors in the Event Log:

Informational Message[10-22-2018 12:18:30] wproc: stderr line 02: /usr/bin/printf: write error: Broken pipe
Informational Message[10-22-2018 12:18:30] wproc: stderr line 01: /bin/sh: 1: /bin/mail: not found
Informational Message[10-22-2018 12:18:30] wproc: early_timeout=0; exited_ok=1; wait_status=32512; error_code=0;
Informational Message[10-22-2018 12:18:30] wproc: host=orangepione; service=(none); contact=roger
Informational Message[10-22-2018 12:18:30] wproc: NOTIFY job 496 from worker Core Worker 13317 is a non-check helper but exited with return code 127
Host Notification[10-22-2018 12:18:30] HOST NOTIFICATION: roger;orangepione;CUSTOM (DOWN);notify-host-by-email;(Host check timed out after 30.03 seconds);nagiosadmin;test

I have mailutils installed and when I do "which mail", I get the following:

root@ftp:~# which mail
/usr/bin/mail

It seems my mail is in /usr/bin/mail and Nagios is looking in /bin/mail, is that correect? if so, how would I fix that?

Any ideas on what I should do to fix it would be greatly appreciated.

Thanks,

Roger

Re: Nagios unable to send email via sendmail

Posted: Mon Oct 22, 2018 9:00 am
by mcapra
rogerjbos wrote: I have mailutils installed and when I do "which mail", I get the following:

root@ftp:~# which mail
/usr/bin/mail
All this confirms is that the root user's shell has an appropriate link for the mail command to /usr/bin/mail. The Nagios Core daemon doesn't run in a shell and probably shouldn't run as root.

The short answer is always use full paths to binaries in your Nagios Core command definitions. You'll likely need to change your command definitions to use /usr/bin/mail instead of /bin/mail. I think the "sample configs" that get installed as part of the official installation documentation use /bin/mail by default in their "sample commands", which may or may not exist on some systems.

If that's still not quite working, can you share:
  • A link to the documentation/process you used for installing Nagios Core
  • The Nagios Core command definition for your "notify-host-by-email" and "notify-service-by-email" commands
  • The sudoers entry for the Nagios Core daemon user (typically "nagios")
  • The output of cat /etc/passwd | grep nagios
  • The output of ls -al /usr/bin/mail

Re: Nagios unable to send email via sendmail

Posted: Mon Oct 22, 2018 9:02 am
by rogerjbos
I found the problem. It was in commands.cfg. It was using /bin/mail and I had to change to /usr/bin/mail. Now it is working. Getting closer to having Nagios working...

Re: Nagios unable to send email via sendmail

Posted: Mon Oct 22, 2018 9:23 am
by rogerjbos
Thank you mcapra. You were correct about having to update /bin/mail to /usr/bin/mail.

Re: Nagios unable to send email via sendmail

Posted: Mon Oct 22, 2018 2:25 pm
by benjaminsmith
Thanks Matt!
Thank you mcapra. You were correct about having to update /bin/mail to /usr/bin/mail.
Are we ok to close this forum topic?