Page 1 of 1
A couple of email items
Posted: Sat Dec 09, 2017 1:10 pm
by kd4pyr
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.
RE: A couple of email items
Posted: Tue Dec 12, 2017 10:00 am
by Robbie Ferguson
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...
Code: Select all
echo '---------' >> /var/log/sendemail
RE: A couple of email items
Posted: Thu Dec 14, 2017 5:39 pm
by kd4pyr
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.
RE: A couple of email items
Posted: Sun Dec 17, 2017 1:04 pm
by Robbie Ferguson
Please run 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.
RE: A couple of email items
Posted: Sun Dec 17, 2017 5:35 pm
by kd4pyr
[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]:~ $