Nagios unable to send email via sendmail

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
rogerjbos
Posts: 6
Joined: Sun Oct 21, 2018 3:49 pm

Nagios unable to send email via sendmail

Post 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
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Nagios unable to send email via sendmail

Post 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
Last edited by mcapra on Mon Oct 22, 2018 9:03 am, edited 1 time in total.
Former Nagios employee
https://www.mcapra.com/
rogerjbos
Posts: 6
Joined: Sun Oct 21, 2018 3:49 pm

Re: Nagios unable to send email via sendmail

Post 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...
rogerjbos
Posts: 6
Joined: Sun Oct 21, 2018 3:49 pm

Re: Nagios unable to send email via sendmail

Post by rogerjbos »

Thank you mcapra. You were correct about having to update /bin/mail to /usr/bin/mail.
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: Nagios unable to send email via sendmail

Post 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?
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!
Locked