Page 2 of 2

Re: not getting email notification

Posted: Mon Apr 08, 2019 4:58 pm
by tgriep
The nagios.log file is typically in the following folder.

Code: Select all

/usr/local/nagios/var

I want to see the sendemail log file which is here.

Code: Select all

/var/log/sendemail

Re: not getting email notification

Posted: Tue Apr 09, 2019 2:49 am
by seliimgnc
@seliimgnc, if you login the Nagios web interface, and go the Process Info menu, are Notifications enabled?
If you go to the Reports > Notification menu, is the system trying to send the notifications to a contact?
Do you see any errors or entries in this log file?

Code: Select all

/var/log/sendemail
[/quote]

if you login the Nagios web interface, and go the Process Info menu, are Notifications enabled?
- Yes, Notifications are enabled .

If you go to the Reports > Notification menu, is the system trying to send the notifications to a contact?

- Yes, system is the trying to send the contact. This is my /usr/local/nagios/var/nagios.log file:

root@ubuntu:/usr/local/nagios/libexec# tail -40 /usr/local/nagios/var/nagios.log
[1554791443] wproc: early_timeout=0; exited_ok=1; wait_status=256; error_code=0;
[1554791443] wproc: stdout line 01: Apr 09 09:30:43 ubuntu sendemail[23887]: ERROR => You must specify a 'from' field! Try --help.
[1554792867] HOST NOTIFICATION: nagiosadmin;JIRA;DOWN;notify-host-by-email;CRITICAL - Host Unreachable (192.168.10.115)
[1554792867] wproc: NOTIFY job 2806 from worker Core Worker 35984 is a non-check helper but exited with return code 1
[1554792867] wproc: host=JIRA; service=(none); contact=nagiosadmin
[1554792867] wproc: early_timeout=0; exited_ok=1; wait_status=256; error_code=0;
[1554792867] wproc: stdout line 01: Apr 09 09:54:27 ubuntu sendemail[24903]: ERROR => You must specify a 'from' field! Try --help.
[1554793243] HOST NOTIFICATION: nagiosadmin;KPI_VPC;DOWN;notify-host-by-email;PING CRITICAL - Packet loss = 100%
[1554793243] wproc: NOTIFY job 2820 from worker Core Worker 35983 is a non-check helper but exited with return code 1
[1554793243] wproc: host=KPI_VPC; service=(none); contact=nagiosadmin
[1554793243] wproc: early_timeout=0; exited_ok=1; wait_status=256; error_code=0;
[1554793243] wproc: stdout line 01: Apr 09 10:00:43 ubuntu sendemail[25172]: ERROR => You must specify a 'from' field! Try --help.
[1554794210] Auto-save of retention data completed successfully.
[1554794586] EXTERNAL COMMAND: DISABLE_NOTIFICATIONS;1554794586
[1554794715] EXTERNAL COMMAND: RESTART_PROCESS;1554794715
[1554794715] PROGRAM_RESTART event encountered, restarting...
[1554794715] Nagios 4.4.2 starting... (PID=35981)
[1554794715] Local time is Tue Apr 09 10:25:15 +03 2019
[1554794715] LOG VERSION: 2.0
[1554794715] qh: Socket '/usr/local/nagios/var/rw/nagios.qh' successfully initialized
[1554794715] qh: core query handler registered
[1554794715] qh: echo service query handler registered
[1554794715] qh: help for the query handler registered
[1554794715] wproc: Successfully registered manager as @wproc with query handler
[1554794715] wproc: Registry request: name=Core Worker 26251;pid=26251
[1554794715] wproc: Registry request: name=Core Worker 26250;pid=26250
[1554794715] wproc: Registry request: name=Core Worker 26249;pid=26249
[1554794715] wproc: Registry request: name=Core Worker 26248;pid=26248
[1554794955] EXTERNAL COMMAND: ENABLE_HOST_SVC_NOTIFICATIONS;CLOGGER
[1554795289] EXTERNAL COMMAND: ENABLE_NOTIFICATIONS;1554795289
[1554795345] HOST NOTIFICATION: nagiosadmin;KPI_VPC;DOWN;notify-host-by-email;PING CRITICAL - Packet loss = 100%
[1554795345] wproc: NOTIFY job 24 from worker Core Worker 26250 is a non-check helper but exited with return code 1
[1554795345] wproc: host=KPI_VPC; service=(none); contact=nagiosadmin
[1554795345] wproc: early_timeout=0; exited_ok=1; wait_status=256; error_code=0;
[1554795345] wproc: stdout line 01: Apr 09 10:35:45 ubuntu sendemail[26823]: ERROR => You must specify a 'from' field! Try --help.
[1554795502] HOST NOTIFICATION: nagiosadmin;JIRA;DOWN;notify-host-by-email;CRITICAL - Host Unreachable (192.168.10.115)
[1554795502] wproc: NOTIFY job 29 from worker Core Worker 26248 is a non-check helper but exited with return code 1
[1554795502] wproc: host=JIRA; service=(none); contact=nagiosadmin
[1554795502] wproc: early_timeout=0; exited_ok=1; wait_status=256; error_code=0;
[1554795502] wproc: stdout line 01: Apr 09 10:38:22 ubuntu sendemail[26942]: ERROR => You must specify a 'from' field! Try --help.


Do you see any errors or entries in this log file?

Code: Select all

/var/log/sendemail
[/quote][/b]

My /var/log/sendemail log file is empty :?

Re: not getting email notification

Posted: Tue Apr 09, 2019 8:20 am
by tgriep
Here is the error from the nagios.log file that shows what is preventing the emails from sending. The command is missing a From address.

Code: Select all

[1554795345] wproc: NOTIFY job 24 from worker Core Worker 26250 is a non-check helper but exited with return code 1
[1554795345] wproc: host=KPI_VPC; service=(none); contact=nagiosadmin
[1554795345] wproc: early_timeout=0; exited_ok=1; wait_status=256; error_code=0;
[1554795345] wproc: stdout line 01: Apr 09 10:35:45 ubuntu sendemail[26823]: ERROR => You must specify a 'from' field! Try --help.
The -f option sets the from address for the email.
-f ADDRESS
from (sender) email address
In your command definition, you are using the $USER5$ macro as the from address.
Make sure you have setup an email address in the /usr/local/nagios/etc/resource.cfg file for the $USER5$ macro and restart nagios if you change it.
Then, wait for another notification to be generated and check the nagios.log file to see if it was sent or not.

Re: not getting email notification

Posted: Wed Apr 10, 2019 2:14 am
by seliimgnc
I already have from mail adress in /usr....../resource.cfg file.
They are like that ;
$USER5$=[email protected] # mail address
$USER7$=smtp.mydomain.com:587 # stmp server and port






~

Re: not getting email notification

Posted: Wed Apr 10, 2019 8:57 am
by tgriep
I setup a email command like your notify-host-by-email command and it worked on my system.

The only difference is that I put it all on one line like this.

Code: Select all

command_line /usr/bin/printf "%b%b%b%b%b%b%b" "***** Nagios *****\n\n" "Notification Type: $NOTIFICATIONTYPE$\n" "Host: $HOSTNAME$\n" "State: $HOSTSTATE$\n" "Address: $HOSTADDRESS$\n" "Info: $HOSTOUTPUT$\n\n" "Date/Time: $LONGDATETIME$\n" | /usr/bin/sendemail -s $USER7$ -l /var/log/sendemail -f $USER5$ -t $CONTACTEMAIL$ -u "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **"
I think that is the issue as the sendemail command may not be processing the from line.

Couple of other things, make sure the resource.cfg file setting is in the nagios.cfg file.

Code: Select all

resource_file=/usr/local/nagios/etc/resource.cfg
Restart the nagios process to make sure it loads the settings.

Re: not getting email notification

Posted: Thu Apr 11, 2019 3:34 am
by seliimgnc
tgriep wrote:I setup a email command like your notify-host-by-email command and it worked on my system.

The only difference is that I put it all on one line like this.

Code: Select all

command_line /usr/bin/printf "%b%b%b%b%b%b%b" "***** Nagios *****\n\n" "Notification Type: $NOTIFICATIONTYPE$\n" "Host: $HOSTNAME$\n" "State: $HOSTSTATE$\n" "Address: $HOSTADDRESS$\n" "Info: $HOSTOUTPUT$\n\n" "Date/Time: $LONGDATETIME$\n" | /usr/bin/sendemail -s $USER7$ -l /var/log/sendemail -f $USER5$ -t $CONTACTEMAIL$ -u "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **"
I think that is the issue as the sendemail command may not be processing the from line.

Couple of other things, make sure the resource.cfg file setting is in the nagios.cfg file.

Code: Select all

resource_file=/usr/local/nagios/etc/resource.cfg
Restart the nagios process to make sure it loads the settings.
I ve resource.cfg file setting is in tje nagios.cfg file.
I can't solve the problem ...

Re: not getting email notification

Posted: Thu Apr 11, 2019 8:44 am
by tgriep
Are you still receiving the same error in the nagios.log file that says the From address is missing?
Try this, edit the command and replace the macro with the actual email address and see if that works.