Portál AbcLinuxu, 31. října 2025 04:36
Debian GNU/Linux 7 (wheezy)
Zdravím mám problém Nedaří se mi nastavit notifikace nevíte kde bych mohl mít chybu, nebo co bych ještě měl zkontrolovat ?
V logu nagios debug je -
[1442037278.130342] [032.1] [pid=9083] We shouldn't notify about DOWN states for this host.
[1442037278.130352] [032.0] [pid=9083] Notification viability test failed.  No notification will be sent out.
[1442037278.130373] [032.0] [pid=9083] ** Service Notification Attempt ** Host: 'server21', Service: 'server21', Type: 0, Options: 0, Current State: 2, Last Notification: Thu Jan  1 01:00:00 1970
[1442037278.130390] [032.1] [pid=9083] The host is either down or unreachable, so we won't notify contacts about this service.
[1442037278.130415] [032.0] [pid=9083] Notification viability test failed.  No notification will be sent out.
Když si pošlu z cmd mail tak projde
čas je nastavený správně
generic-host_nagios2
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      1       ; 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
 max_check_attempts              60
 notification_interval           1
 notification_period             24x7
 notification_options            u
 contact_groups                  admins
 register                        0       ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
 }
contacts_nagios2
# In this simple config file, a single contact will receive all alerts.
define contact{
 contact_name                    root
 alias                           root
 service_notification_period     24x7
 host_notification_period        24x7
 service_notification_options    w,u,c,r,f,s
 host_notification_options       d,u,r,f,s
 service_notification_commands   notify-service-by-email
 host_notification_commands      notify-host-by-email
 email                           info@pchlavka.eu
 }
define contactgroup{
 contactgroup_name       admins
 alias                   Nagios Administrators
 members                 root
 }
commands
# 'notify-host-by-email' command definition
Řešení dotazu:
commands
# 'notify-host-by-email' command definition
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$
 }
Tak jsem to snad pochopil a zacalo to nejak chodit
Pouze me neprijde mail ani do spamu
mail-log tohle neprijde
Sep 13 08:40:03 localhost postfix/pickup[24690]: 211A72A021AC: uid=111 from=<nagios>
Sep 13 08:40:03 localhost postfix/cleanup[5572]: 211A72A021AC: message-id=<20150913064003.211A72A021AC@pchlavka.eu>
Sep 13 08:40:03 localhost postfix/qmgr[2818]: 211A72A021AC: from=<nagios@pcxxx.eu>, size=532, nrcpt=1 (queue active)
Sep 13 08:40:03 localhost postfix/smtp[5574]: 211A72A021AC: to=<kamil@xxx.cz>, relay=smtp.o2isp.cz[194.228.2.82]:25, delay=0.36, delays=0/0/0.26/0.1, dsn=2.0.0, status=sent (250 ok:  Message 204351263 accepted)
Sep 13 08:40:03 localhost postfix/qmgr[2818]: 211A72A021AC: removed
tohle prijde
Sep 13 08:47:19 localhost postfix/pickup[6498]: 4EBC32A021AC: uid=0 from=<root>
Sep 13 08:47:19 localhost postfix/cleanup[5572]: 4EBC32A021AC: message-id=<20150913064719.4EBC32A021AC@pchlavka.eu>
Sep 13 08:47:19 localhost postfix/qmgr[2818]: 4EBC32A021AC: from=<root@pchlavka.eu>, size=331, nrcpt=1 (queue active)
Sep 13 08:47:19 localhost postfix/smtp[5574]: 4EBC32A021AC: to=<info@xxx.eu>, relay=smtp.o2isp.cz[194.228.2.82]:25, delay=0.31, delays=0.01/0/0.18/0.12, dsn=2.0.0, status=sent (250 ok:  Message 723159164 accepted)
Sep 13 08:47:19 localhost postfix/qmgr[2818]: 4EBC32A021AC: removed
        Tiskni
            
                Sdílej:
                 
                 
                 
                 
                 
                 
            
    
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.