Page 2 of 4

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

Posted: Wed Jun 04, 2014 8:57 am
by eloyd
This might be messing things up:

Code: Select all

127.0.0.1       localhost
127.0.0.1       backups
Try changing it to:

Code: Select all

127.0.0.1       localhost backups

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

Posted: Wed Jun 04, 2014 3:54 pm
by slansing
I agree, having the same definition on separate lines may cause a problem with resolving hosts. Let us know if you continue to see the issue after making the change.

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

Posted: Thu Jun 05, 2014 12:21 am
by dreamboy_sivak
Hi aleks1,

Just modify the following line in your 'notify-host-email' command definition

/usr/bin/mail instead of this replace with /usr/bin/mailx


pls reply me your status

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

Posted: Thu Jun 05, 2014 3:15 am
by aleks1
127.0.0.1 localhost backups
@slansing @eloyd
i've tried this configuration but the mail.log changes the name localhost instead of backups:

Code: Select all

Jun  5 07:41:01 backups sm-msp-queue[14637]: unable to qualify my own domain name (localhost) -- using short name
Jun  5 08:00:01 backups sm-msp-queue[15668]: My unqualified host name (localhost) unknown; sleeping for retry
Jun  5 08:01:01 backups sm-msp-queue[15668]: unable to qualify my own domain name (localhost) -- using short name
Jun  5 08:20:01 backups sm-msp-queue[16712]: My unqualified host name (localhost) unknown; sleeping for retry
Jun  5 08:21:01 backups sm-msp-queue[16712]: unable to qualify my own domain name (localhost) -- using short name
Jun  5 08:40:01 backups sm-msp-queue[17748]: My unqualified host name (localhost) unknown; sleeping for retry
Jun  5 08:41:04 backups sm-msp-queue[17748]: unable to qualify my own domain name (localhost) -- using short name
Jun  5 09:00:01 backups sm-msp-queue[18785]: My unqualified host name (localhost) unknown; sleeping for retry
Jun  5 09:01:01 backups sm-msp-queue[18785]: unable to qualify my own domain name (localhost) -- using short name
Jun  5 09:20:01 backups sm-msp-queue[19835]: My unqualified host name (localhost) unknown; sleeping for retry
Jun  5 09:21:01 backups sm-msp-queue[19835]: unable to qualify my own domain name (localhost) -- using short name
hi @dreamboy_sivak... i have modified the line in commands.cfg
but anything changes.. no notifications :(
commands.cfg:

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/mailx -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$
        }
nagios.log:

Code: Select all

[1401953661] Event broker module 'NERD' deinitialized successfully.
[1401953661] Nagios 4.0.2 starting... (PID=20934)
[1401953661] Local time is Thu Jun 05 09:34:21 CEST 2014
[1401953661] LOG VERSION: 2.0
[1401953661] qh: Socket '/usr/local/nagios/var/rw/nagios.qh' successfully initialized
[1401953661] qh: core query handler registered
[1401953661] nerd: Channel hostchecks registered successfully
[1401953661] nerd: Channel servicechecks registered successfully
[1401953661] nerd: Channel opathchecks registered successfully
[1401953661] nerd: Fully initialized and ready to rock!
[1401953661] wproc: Successfully registered manager as @wproc with query handler
[1401953661] wproc: Registry request: name=Core Worker 20935;pid=20935
[1401953661] wproc: Registry request: name=Core Worker 20936;pid=20936
[1401953661] wproc: Registry request: name=Core Worker 20937;pid=20937
[1401953661] wproc: Registry request: name=Core Worker 20939;pid=20939
[1401953661] wproc: Registry request: name=Core Worker 20938;pid=20938
[1401953661] wproc: Registry request: name=Core Worker 20940;pid=20940
[1401953662] Successfully launched command file worker with pid 20941
[1401953997] SERVICE ALERT: posta;PING;CRITICAL;SOFT;1;PING CRITICAL - Packet loss = 60%, RTA = 19.99 ms
[1401954171] SERVICE ALERT: posta;PING;OK;SOFT;2;PING OK - Packet loss = 0%, RTA = 0.49 ms

is a hard problem! :(

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

Posted: Thu Jun 05, 2014 5:26 am
by Stuart Watts
What does /var/log/maillog show when:
1) you send a manual mail (su to nagios, run "echo "test" | mail -s "test mail" [email protected]")
2) when Nagios attempts to send you a mail

Also, double check the command the service is configured to use, just in case! Nagios can still report a notification event, but if the command it's running fails (bad command name in service config, or bad commandline in the command), it won't log it.

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

Posted: Thu Jun 05, 2014 5:52 am
by aleks1
1) you send a manual mail (su to nagios, run "echo "test" | mail -s "test mail" [email protected]")
"echo "test" | mail -s "test mail" [email protected]" with root and nagios user and the test mails arrived to my address :

Code: Select all

Jun  5 12:00:01 backups sm-msp-queue[30678]: My unqualified host name (localhost) unknown; sleeping for retry
Jun  5 12:01:01 backups sm-msp-queue[30678]: unable to qualify my own domain name (localhost) -- using short name
Jun  5 12:14:48 backups sendmail[31519]: My unqualified host name (localhost) unknown; sleeping for retry
Jun  5 12:15:29 backups sendmail[31542]: My unqualified host name (localhost) unknown; sleeping for retry
Jun  5 12:16:29 backups sendmail[31542]: unable to qualify my own domain name (localhost) -- using short name
Jun  5 12:16:29 backups sendmail[31542]: s55AGTq2031542: from=root, size=96, class=0, nrcpts=1, msgid=<201406051016.s55AGTq2031542@localhost>, relay=root@localhost
Jun  5 12:16:29 backups sm-mta[31599]: s55AGT4B031599: from=<root@localhost>, size=333, class=0, nrcpts=1, msgid=<201406051016.s55AGTq2031542@localhost>, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
Jun  5 12:16:29 backups sendmail[31542]: s55AGTq2031542: to=<[email protected]>, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30096, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (s55AGT4B031599 Message accepted for delivery)
Jun  5 12:16:30 backups sm-mta[31601]: STARTTLS=client, relay=intra.deaconsulenze.eu., version=TLSv1/SSLv3, verify=FAIL, cipher=ECDHE-RSA-AES256-SHA, bits=256/256
Jun  5 12:16:30 backups sm-mta[31601]: s55AGT4B031599: to=<[email protected]>, ctladdr=<root@localhost> (0/0), delay=00:00:01, xdelay=00:00:01, mailer=esmtp, pri=120333, relay=intra.deaconsulenze.eu. [144.76.118.183], dsn=2.0.0, stat=Sent (Ok: queued as E84C120C5C)
Jun  5 12:16:59 backups sendmail[31634]: My unqualified host name (localhost) unknown; sleeping for retry
Jun  5 12:17:59 backups sendmail[31634]: unable to qualify my own domain name (localhost) -- using short name
Jun  5 12:17:59 backups sendmail[31634]: s55AHxXW031634: from=nagios, size=96, class=0, nrcpts=1, msgid=<201406051017.s55AHxXW031634@localhost>, relay=nagios@localhost
Jun  5 12:17:59 backups sm-mta[31695]: s55AHxp2031695: from=<nagios@localhost>, size=330, class=0, nrcpts=1, msgid=<201406051017.s55AHxXW031634@localhost>, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
Jun  5 12:17:59 backups sendmail[31634]: s55AHxXW031634: to=<[email protected]>, ctladdr=nagios (1006/1006), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30096, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (s55AHxp2031695 Message accepted for delivery)
Jun  5 12:18:00 backups sm-mta[31697]: STARTTLS=client, relay=intra.deaconsulenze.eu., version=TLSv1/SSLv3, verify=FAIL, cipher=ECDHE-RSA-AES256-SHA, bits=256/256
Jun  5 12:18:00 backups sm-mta[31697]: s55AHxp2031695: to=<[email protected]>, ctladdr=<nagios@localhost> (1006/1006), delay=00:00:01, xdelay=00:00:01, mailer=esmtp, pri=120330, relay=intra.deaconsulenze.eu. [144.76.118.183], dsn=2.0.0, stat=Sent (Ok: queued as C871520C5C)
Jun  5 12:20:01 backups sm-msp-queue[31811]: My unqualified host name (localhost) unknown; sleeping for retry
Jun  5 12:21:01 backups sm-msp-queue[31811]: unable to qualify my own domain name (localhost) -- using short name
when Nagios attempts to send you a mail
i think that Nagios doesn't try to send alerts to me! because if i don't try to send me a mail manually.. the mail.log remains:

Code: Select all

Jun  5 07:41:01 backups sm-msp-queue[14637]: unable to qualify my own domain name (localhost) -- using short name
Jun  5 08:00:01 backups sm-msp-queue[15668]: My unqualified host name (localhost) unknown; sleeping for retry
Jun  5 08:01:01 backups sm-msp-queue[15668]: unable to qualify my own domain name (localhost) -- using short name
Jun  5 08:20:01 backups sm-msp-queue[16712]: My unqualified host name (localhost) unknown; sleeping for retry
Jun  5 08:21:01 backups sm-msp-queue[16712]: unable to qualify my own domain name (localhost) -- using short name
Jun  5 08:40:01 backups sm-msp-queue[17748]: My unqualified host name (localhost) unknown; sleeping for retry
Jun  5 08:41:04 backups sm-msp-queue[17748]: unable to qualify my own domain name (localhost) -- using short name
Jun  5 09:00:01 backups sm-msp-queue[18785]: My unqualified host name (localhost) unknown; sleeping for retry
Jun  5 09:01:01 backups sm-msp-queue[18785]: unable to qualify my own domain name (localhost) -- using short name
Jun  5 09:20:01 backups sm-msp-queue[19835]: My unqualified host name (localhost) unknown; sleeping for retry
Jun  5 09:21:01 backups sm-msp-queue[19835]: unable to qualify my own domain name (localhost) -- using short name

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

Posted: Thu Jun 05, 2014 6:16 am
by Stuart Watts
In that case it is a Nagios configuration problem (I thought Nagios had tried to send you mail - my bad!).

Can you show us the service and contact configurations?

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

Posted: Thu Jun 05, 2014 7:10 am
by aleks1
I thought Nagios had tried to send you mail - my bad!
ehehe no problem! :)
Can you show us the service and contact configurations?
contacts.cfg:

Code: Select all

define contact{
        contact_name                    supporto
        alias                           Supporto Clienti DEA
        service_notification_period     24x7
        host_notification_period        24x7
        service_notification_options    w,u,c,r
        host_notification_options       d,r
        service_notification_commands   notify-service-by-email
        host_notification_commands      notify-host-by-email
        email                           [email protected]
        }
###############################################################################
###############################################################################
#
# CONTACT GROUPS
#
###############################################################################
###############################################################################

# We only have one contact in this simple configuration file, so there is
# no need to create more than one contact group.

define contactgroup{
        contactgroup_name       admins
        alias                   Nagios Administrators
        members                 supporto
        }
generic-service.cfg:

Code: Select all

# generic service template definition
define service{
        name                            generic-service ; The 'name' of this service template
        active_checks_enabled           1       ; Active service checks are enabled
        passive_checks_enabled          1       ; Passive service checks are enabled/accepted
        parallelize_check               1       ; Active service checks should be parallelized (disabling this can lead to major performance problems)
        obsess_over_service             1       ; We should obsess over this service (if necessary)
        check_freshness                 0       ; Default is to NOT check service 'freshness'
        notifications_enabled           1       ; Service notifications are enabled
        event_handler_enabled           1       ; Service event handler is enabled
        flap_detection_enabled          1       ; Flap detection is enabled
#        failure_prediction_enabled      0       ; Failure prediction is enabled
        process_perf_data               1       ; Process performance data
        retain_status_information       1       ; Retain status information across program restarts
        retain_nonstatus_information    1       ; Retain non-status information across program restarts
                notification_interval           0               ; Only send notifications on status change by default.
                is_volatile                     0
                check_period                    24x7
                normal_check_interval           5
                retry_check_interval            3
                max_check_attempts              4
                notification_period             24x7
                notification_options            w,u,c,r
                contact_groups                  admins
        register                        0       ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
        }
generic-host.cfg:

Code: Select all

define host{
        name                            generic-host    ; The name of this host template
        notifications_enabled           1       ; Host notifications are enabled
        event_handler_enabled           1       ; Host event handler is enabled
        flap_detection_enabled          1       ; Flap detection is enabled
#        failure_prediction_enabled      0       ; Failure prediction is enabled
        process_perf_data               1       ; Process performance data
        retain_status_information       1       ; Retain status information across program restarts
        retain_nonstatus_information    1       ; Retain non-status information across program restarts
                check_command                   check-host-alive_4
                max_check_attempts              15
                notification_interval           0
                notification_period             24x7
                notification_options            d,u,r
                contact_groups                  admins
        register                        0       ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
        }
i'll post everything you want!:)

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

Posted: Thu Jun 05, 2014 8:23 am
by aleks1
i've created another hard state in my nagios (for trying notification emails)
and this error appear in nagios.log:

Code: Select all

    SERVICE ALERT: ipcop-mi;HTTP;CRITICAL;HARD;4;HTTP CRITICAL: HTTP/1.0 504 Gateway Time-out - 1937 bytes in 0,183 second response time
    [1401972670] SERVICE NOTIFICATION: supporto;ipcop-mi;HTTP;CRITICAL;notify-service-by-email;HTTP CRITICAL: HTTP/1.0 504 Gateway Time-out - 1937 bytes in 0,183 second response time
    [1401972700] wproc: Core Worker 7247: job 49 (pid=7852) timed out. Killing it
    [1401972700] wproc: NOTIFY job 49 from worker Core Worker 7247 timed out after 30.01s
    [1401972700] wproc:   command: /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: PROBLEM\n\nService: HTTP\nHost: IpCop Milano ESA\nAddress: 192.168.33.1\nState: CRITICAL\n\nDate/Time: Thu Jun 5 14:51:10 CEST 2014\n\nAdditional Info:\n\nHTTP CRITICAL: HTTP/1.0 504 Gateway Time-out - 1937 bytes in 0,183 second response time\n" | /usr/bin/mail -s "** PROBLEM Service Alert: IpCop Milano ESA/HTTP is CRITICAL **" [email protected]
    [1401972700] wproc:   host=ipcop-mi; service=HTTP; contact=supporto
    [1401972700] wproc:   early_timeout=1; exited_ok=0; wait_status=0; error_code=62;
    [1401972700] wproc:   stderr line 01: mail: cannot stat `/root/.mail': permission denied
    [1401972700] wproc:   stderr line 02: Cannot open `/root/.mailrc': permission denied
    [1401972700] Warning: Notifying contact 'supporto' of service 'HTTP' on host 'ipcop-mi' by command '/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: PROBLEM\n\nService: HTTP\nHost: IpCop Milano ESA\nAddress: 192.168.33.1\nState: CRITICAL\n\nDate/Time: Thu Jun 5 14:51:10 CEST 2014\n\nAdditional Info:\n\nHTTP CRITICAL: HTTP/1.0 504 Gateway Time-out - 1937 bytes in 0,183 second response time\n" | /usr/bin/mail -s "** PROBLEM Service Alert: IpCop Milano ESA/HTTP is CRITICAL **" [email protected]' timed out after 0.00 seconds
    [1401972700] wproc: Core Worker 7247: tv.tv_sec is currently 1401972700
    [1401972700] wproc: Core Worker 7247: Failed to reap child with pid 7852. Next attempt @ 1401972705.461657
    [1401972705] wproc: Core Worker 7247: job 49 (pid=7852): Dormant child reaped 
OMG what is it? :(

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

Posted: Thu Jun 05, 2014 2:52 pm
by sreinhardt
It seems that nagios and or the system mailer is unable to resolve the domain deaconsulenze.eu. Can you run the following command and send back the output:

Code: Select all

nslookup -querytype=any deaconsulenze.eu
It may also be due to nagios being unable to read /root/.mail and /root/.mailrc which likely contain the mailers settings on your system and are causing the mail binary to fail any sort of sending