Page 1 of 4

[SOLVED] i don't receive mail notification...

Posted: Fri May 30, 2014 9:31 am
by aleks1
Hi everybody! I'm back :)
I'm at the last step! configuring commands.cfg for sending mail notification... in nagios core 4 on ubuntu 12.04
but i'm encountering a problem!
the path for the mail programm (in command .cfg) it's ok! ( i think xD)
but i don't receive any mail notification! :(
and in the nagios.log file there is a strange error...
nagios.log:

Code: Select all

[1401456713] Successfully launched command file worker with pid 8277
[1401456878] SERVICE ALERT: backups;Total Processes;WARNING;SOFT;1;PROCS WARNING: 263 processes
[1401457058] SERVICE ALERT: backups;Total Processes;WARNING;SOFT;2;PROCS WARNING: 263 processes
[1401457238] SERVICE ALERT: backups;Total Processes;WARNING;SOFT;3;PROCS WARNING: 269 processes
[1401457418] SERVICE ALERT: backups;Total Processes;WARNING;HARD;4;PROCS WARNING: 263 processes
[1401457418] SERVICE NOTIFICATION: supporto;backups;Total Processes;WARNING;notify-service-by-email;PROCS WARNING: 263 processes
[1401457448] wproc: Core Worker 8272: job 51 (pid=8937) timed out. Killing it
[1401457448] wproc: NOTIFY job 51 from worker Core Worker 8272 timed out after 30.01s
[1401457448] wproc:   command: /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: PROBLEM\n\nService: Total Processes\nHost: backups\nAddress: 10.10.2.8\nState: WARNING\n\nDate/Time: Fri May 30 15:43:38 CEST 2014\n\nAdditional Info:\n\nPROCS WARNING: 263 processes\n" | /usr/sbin/sendmail -s "** PROBLEM Service Alert: backups/Total Processes is WARNING **" [email protected]
[1401457448] wproc:   host=backups; service=Total Processes; contact=supporto
[1401457448] wproc:   early_timeout=1; exited_ok=0; wait_status=0; error_code=62;
[1401457448] Warning: Notifying contact 'supporto' of service 'Total Processes' on host 'backups' by command '/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: PROBLEM\n\nService: Total Processes\nHost: backups\nAddress: 10.10.2.8\nState: WARNING\n\nDate/Time: Fri May 30 15:43:38 CEST 2014\n\nAdditional Info:\n\nPROCS WARNING: 263 processes\n" | /usr/sbin/sendmail -s "** PROBLEM Service Alert: backups/Total Processes is WARNING **" [email protected]' timed out after 0.00 seconds
[1401457448] wproc: Core Worker 8272: job 51 (pid=8937): Dormant child reaped
i don't know how i can resolve this issue! :(
any help be appreciate! :)
thanks in advance! :)

Re: i don't receive mail notification...

Posted: Fri May 30, 2014 10:26 am
by eloyd
In this line:

Code: Select all

[1401457448] wproc:   command: /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: PROBLEM\n\nService: Total Processes\nHost: backups\nAddress: 10.10.2.8\nState: WARNING\n\nDate/Time: Fri May 30 15:43:38 CEST 2014\n\nAdditional Info:\n\nPROCS WARNING: 263 processes\n" | /usr/sbin/sendmail -s "** PROBLEM Service Alert: backups/Total Processes is WARNING **" [email protected]
I don't know why you have "/usr/bin/sendmail" when I would expect it to be "/bin/mail" or maybe "/usr/bin/mail"

Try changing that in your command.cfg (or appropriate Nagios config file) and see if that works. I think you're trying to send mail incorrectly.

Re: i don't receive mail notification...

Posted: Fri May 30, 2014 3:17 pm
by lmiltchev
Also, you can try sending a test email from the CLI:

Code: Select all

echo "test" | mail -s "test mail"  [email protected]

Re: i don't receive mail notification...

Posted: Tue Jun 03, 2014 3:26 am
by aleks1
Hi! and sorry for later answer! :)
when i try to use this command:

Code: Select all

echo "test" | mail -s "test mail"  [email protected]
i got this:

Code: Select all

echo "test" | mail -s "test mail"  [email protected]        
sh: 1: mail: not found
but with this:

Code: Select all

echo "test" | sendmail -s "test mail" [email protected]
i got this:

Code: Select all

WARNING: RunAsUser for MSP ignored, check group ids (egid=1006, want=116)
can not chdir(/var/spool/mqueue-client/): Permission denied
Program mode requires special privileges, e.g., root or TrustedUser.
with a root user this last command the test mail... work!

how can i fix this permission denied issue? :(
or i must install a programm for example mail?

thanks in advance! :)

Re: i don't receive mail notification...

Posted: Tue Jun 03, 2014 7:04 am
by aleks1
I have tried to install mail (apt-get install mailutils)
Try changing that in your command.cfg (or appropriate Nagios config file) and see if that works. I think you're trying to send mail incorrectly.
and now i have changed the path in command .cfg in:
# 'notify-host-by-email' command definition

Code: Select all

define command{
        command_name    notify-host-by-email
        command_line    /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
        }

# 'notify-service-by-email' command definition
define command{
        command_name    notify-service-by-email
        command_line    /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
        }
i have tried to execute this command with nagios user:

Code: Select all

echo "test" | mail -s "test mail"  [email protected]
and the test mail..work!
but unfortunatly no automatically mail notification from nagios yet :(

Any help be appreciate! :)

Re: i don't receive mail notification...

Posted: Tue Jun 03, 2014 2:45 pm
by scottwilkerson
Can we verify what the full path to mail is

Code: Select all

which mail
also, you would need to make sure you restarted the nagios process after changing the commands ad you had.

Re: i don't receive mail notification...

Posted: Wed Jun 04, 2014 2:30 am
by aleks1
thank you for reply! :)
the command which mail returns:

Code: Select all

which mail

/usr/bin/mail
the right path! in command.cfg there is this path...
yeah i have restarted 3 times the nagios process ehehe
but i don't receive any notification mails yet :(

Re: i don't receive mail notification...

Posted: Wed Jun 04, 2014 2:59 am
by aleks1
In /var/log/mail.log

i have this:

Code: Select all

Jun  4 07:41:01 backups sm-msp-queue[29966]: unable to qualify my own domain name (backups) -- using short name
Jun  4 08:00:01 backups sm-msp-queue[31022]: My unqualified host name (backups) unknown; sleeping for retry
Jun  4 08:01:01 backups sm-msp-queue[31022]: unable to qualify my own domain name (backups) -- using short name
Jun  4 08:20:01 backups sm-msp-queue[32094]: My unqualified host name (backups) unknown; sleeping for retry
Jun  4 08:21:01 backups sm-msp-queue[32094]: unable to qualify my own domain name (backups) -- using short name
Jun  4 08:40:01 backups sm-msp-queue[696]: My unqualified host name (backups) unknown; sleeping for retry
Jun  4 08:41:01 backups sm-msp-queue[696]: unable to qualify my own domain name (backups) -- using short name
Jun  4 09:00:01 backups sm-msp-queue[1808]: My unqualified host name (backups) unknown; sleeping for retry
Jun  4 09:01:01 backups sm-msp-queue[1808]: unable to qualify my own domain name (backups) -- using short name
Jun  4 09:20:02 backups sm-msp-queue[3423]: My unqualified host name (backups) unknown; sleeping for retry
Jun  4 09:21:02 backups sm-msp-queue[3423]: unable to qualify my own domain name (backups) -- using short name
and in nagios.log... after i have restarted the nagios process

Code: Select all

[1401867037] Caught SIGTERM, shutting down...
[1401867037] wproc: Socket to worker Core Worker 2802 broken, removing
[1401867037] Caught SIGTERM, shutting down...
[1401867037] wproc: Socket to worker Core Worker 2799 broken, removing
[1401867037] wproc: Socket to worker Core Worker 2801 broken, removing
[1401867037] wproc: Socket to worker Core Worker 2800 broken, removing
[1401867037] wproc: Socket to worker Core Worker 2798 broken, removing
[1401867037] Successfully shutdown... (PID=2796)
[1401867037] Event broker module 'NERD' deinitialized successfully.
[1401867037] Nagios 4.0.2 starting... (PID=4281)
[1401867037] Local time is Wed Jun 04 09:30:37 CEST 2014
[1401867037] LOG VERSION: 2.0
[1401867037] qh: Socket '/usr/local/nagios/var/rw/nagios.qh' successfully initialized
[1401867037] qh: core query handler registered
[1401867037] nerd: Channel hostchecks registered successfully
[1401867037] nerd: Channel servicechecks registered successfully
[1401867037] nerd: Channel opathchecks registered successfully
[1401867037] nerd: Fully initialized and ready to rock!
[1401867037] wproc: Successfully registered manager as @wproc with query handler
[1401867037] wproc: Registry request: name=Core Worker 4283;pid=4283
[1401867037] wproc: Registry request: name=Core Worker 4286;pid=4286
[1401867037] wproc: Registry request: name=Core Worker 4285;pid=4285
[1401867037] wproc: Registry request: name=Core Worker 4287;pid=4287
[1401867037] wproc: Registry request: name=Core Worker 4282;pid=4282
[1401867037] wproc: Registry request: name=Core Worker 4284;pid=4284
[1401867037] Successfully launched command file worker with pid 4288
[1401867513] SERVICE ALERT: backups;Nagios Status;WARNING;SOFT;1;NAGIOS WARNING: 34 processes, status log updated 476 seconds ago
any idea? :(

any help be appreciate :)

Re: i don't receive mail notification...

Posted: Wed Jun 04, 2014 8:35 am
by eloyd
My unqualified host name (backups) unknown; sleeping for retry
Your machine is not set up to properly recognize itself. You need to add your IP address and name to /etc/hosts or a DNS server.

Re: i don't receive mail notification...

Posted: Wed Jun 04, 2014 8:49 am
by aleks1
hi eloyd! and thanks for reply!
Your machine is not set up to properly recognize itself. You need to add your IP address and name to /etc/hosts or a DNS server.
in /etc/hosts i have these lines:

Code: Select all

127.0.0.1       localhost
127.0.0.1       backups

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
what i should add?
sorry for my unexperience! :)

~