I noticed two issues when testing email on version 1.3. Maybe it is me, but I found:
1) The logging of the email was not working because Nagios did not apparently have sufficient rights to the /var/log/sendemail file. I manually updated the rights and then log entries began to be made.
2) When trying to sending an alert email the log showed the following:
“Dec 08 15:56:36 nems p1.pl[4046]: ERROR => You must specify a 'from' field! Try --help.”
I checked the /etc/nagios3/resource.cfg file and the entries looked OK. See attached image. It is almost as if the USER fields are null as far as Nagios is concerned. I hard coded the email information on the Nagios Notify-Host-By-Email entry and alerts are now working.
A couple of email items
- Robbie Ferguson
- Posting Freak
- Posts: 835
- Joined: Wed Mar 07, 2012 3:23 pm
- Location: Ontario, Canada
- Contact:
RE: A couple of email items
Hey kd4pyr,
Thanks for the notes!
I've looked at my development unit on NEMS 1.3 and the permissions are correct on the log file.
-rw-r--r-- 1 nagios root 52K Dec 12 08:54 /var/log/sendemail
What were you seeing?
It's possible if yours has different permissions that I may have accidentally left a log file behind in the build... but I'd need to re-flash to confirm this.
Since your screenshot has $USER5$ configured, the errors showing that "from" is missing must be an old error (ie., from before you added your email to NEMS SST/resource.cfg). Please try sending a notification again and see if you still see that error.
Add a divider if you'd like, to make it stand out more...
Thanks for the notes!
I've looked at my development unit on NEMS 1.3 and the permissions are correct on the log file.
-rw-r--r-- 1 nagios root 52K Dec 12 08:54 /var/log/sendemail
What were you seeing?
It's possible if yours has different permissions that I may have accidentally left a log file behind in the build... but I'd need to re-flash to confirm this.
Since your screenshot has $USER5$ configured, the errors showing that "from" is missing must be an old error (ie., from before you added your email to NEMS SST/resource.cfg). Please try sending a notification again and see if you still see that error.
Add a divider if you'd like, to make it stand out more...
Code: Select all
echo '---------' >> /var/log/sendemail
Robbie Ferguson // The Bald Nerd
Did I help you out? Appreciate what I do? Please consider saying thanks:
Did I help you out? Appreciate what I do? Please consider saying thanks:
- Throw something in the tip jar: https://donate.category5.tv
- Support Category5 TV on Patreon: https://patreon.com/category5
- Support NEMS Linux on Patreon: https://patreon.com/nems
RE: A couple of email items
Sorry for the delay in getting back to you. Busy time.
For the issue of the sendemail file rights, I think I know what happened. I was not using the file on my old system (it did not exist). So maybe it was deleted by the restore? I know it did not exist until I ran the email test code with SUDO. So maybe the file was created with the incorrect rights.
I am now using the default send email string in NConf:
/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/sendemail -s $USER7$ -xu $USER9$ -xp $USER10$ -t $CONTACTEMAIL$ -f $USER5$ -l /var/log/sendmail -u "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" -m "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n"
And the same email error is being logged.
Dec 14 17:22:42 nems sendemail[3093]: ERROR => You must specify a 'from' field! Try --help.
I know the $USER$ variables are set.
Thanks.
For the issue of the sendemail file rights, I think I know what happened. I was not using the file on my old system (it did not exist). So maybe it was deleted by the restore? I know it did not exist until I ran the email test code with SUDO. So maybe the file was created with the incorrect rights.
I am now using the default send email string in NConf:
/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/sendemail -s $USER7$ -xu $USER9$ -xp $USER10$ -t $CONTACTEMAIL$ -f $USER5$ -l /var/log/sendmail -u "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" -m "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n"
And the same email error is being logged.
Dec 14 17:22:42 nems sendemail[3093]: ERROR => You must specify a 'from' field! Try --help.
I know the $USER$ variables are set.
Thanks.
Rick
- Robbie Ferguson
- Posting Freak
- Posts: 835
- Joined: Wed Mar 07, 2012 3:23 pm
- Location: Ontario, Canada
- Contact:
RE: A couple of email items
Please run this command:
Please post the output of this command.
Code: Select all
date && echo "---" && sudo cat /etc/nagios3/resource.cfg | grep USER5 && echo "---" && sudo tail /var/log/sendemail
Please post the output of this command.
Robbie Ferguson // The Bald Nerd
Did I help you out? Appreciate what I do? Please consider saying thanks:
Did I help you out? Appreciate what I do? Please consider saying thanks:
- Throw something in the tip jar: https://donate.category5.tv
- Support Category5 TV on Patreon: https://patreon.com/category5
- Support NEMS Linux on Patreon: https://patreon.com/nems
RE: A couple of email items
[email=kd4pyr@NEMS]kd4pyr@NEMS[/email]:~ $ date && echo "---" && sudo cat /etc/nagios3/resource.cfg | grep USER5 && echo "---" && sudo tail /var/log/sendemail
Sun 17 Dec 17:31:13 EST 2017
---
[sudo] password for kd4pyr:
[email protected]
---
Dec 14 17:22:42 nems sendemail[3093]: ERROR => You must specify a 'from' field! Try --help.
Dec 14 17:22:52 nems sendemail[3135]: ERROR => You must specify a 'from' field! Try --help.
Dec 16 06:16:22 nems sendemail[23371]: ERROR => You must specify a 'from' field! Try --help.
Dec 16 06:26:22 nems sendemail[28359]: ERROR => You must specify a 'from' field! Try --help.
[email=kd4pyr@NEMS]kd4pyr@NEMS[/email]:~ $
Sun 17 Dec 17:31:13 EST 2017
---
[sudo] password for kd4pyr:
[email protected]
---
Dec 14 17:22:42 nems sendemail[3093]: ERROR => You must specify a 'from' field! Try --help.
Dec 14 17:22:52 nems sendemail[3135]: ERROR => You must specify a 'from' field! Try --help.
Dec 16 06:16:22 nems sendemail[23371]: ERROR => You must specify a 'from' field! Try --help.
Dec 16 06:26:22 nems sendemail[28359]: ERROR => You must specify a 'from' field! Try --help.
[email=kd4pyr@NEMS]kd4pyr@NEMS[/email]:~ $
Rick