Das Nagios- Benachrichtigungssystem Grundlagen, Eskalationen, Dependencies, Workflow Nürnberg, 2009-10-29 Open Source Monitoring Conference 2009 Wolfgang Barth 1
Agenda Grundlagen Eskalationen, Dependencies Einflussfaktoren: Flapping, Downtime, Acknowledgements Custom Notifications Open Source Monitoring Conference 2009 Wolfgang Barth 2
Benachrichtigungen Direkte Information von Verantwortlichen (push statt pull wie bei der Weboberfläche Auslöser für eine Benachrichtigung: Ein Hard State wechselt in einen anderen Hard State Ein Hard State mit Fehlerzustand besteht weiterhin > notification_period > is_volatile Open Source Monitoring Conference 2009 Wolfgang Barth 3
Einflussmöglichkeiten statisch: Konfiguration System Host, Service Kontakt Eskalationen dynamisch: Acknowledgements Downtime Flapping Dependencies Open Source Monitoring Conference 2009 Wolfgang Barth 4
Konfigurationsmöglichkeiten System enable_notfications=1 Host/ Service Kontakt notfications_enabled=1 Filter (was, wann, wer, wie oft) host/service_notfications_enabled=1 Filter (was, wann, wie) Command E-Mail, SMS, Ampel,...... alles, was sich mit einem Programm ansteuern lässt... tactical overview Open Source Monitoring Conference 2009 Wolfgang Barth 5
Notifications: Parameter Host notification_period notification_options notification_interval first_notification_delay Service host_notification_period host_notification_options Contact/ -group service_notification_period service_notification_options Command externes Programm, z.b. E- Mail, SMS, Webservice,... Open Source Monitoring Conference 2009 Wolfgang Barth 6
Notifications: Was Host notification_period notification_options notification_interval first_notification_delay Service host_notification_period host_notification_options Contact/ -group service_notification_period service_notification_options Command externes Programm, z.b. E- Mail, SMS, Webservice,... Open Source Monitoring Conference 2009 Wolfgang Barth 7
notification_options Host: d: down u: unreachable r: recovery f: flapping s: scheduled downtime n: none a: all (*) Service: w: warning u: unknown c: critical r: recovery f: flapping s: scheduled downtime n: none a: all (*) (*) undokumentiert Open Source Monitoring Conference 2009 Wolfgang Barth 8
Notifications: Wann Host notification_period notification_options notification_interval first_notification_delay Service host_notification_period host_notification_options Contact/ -group service_notification_period service_notification_options Command externes Programm, z.b. E- Mail, SMS, Webservice,... Open Source Monitoring Conference 2009 Wolfgang Barth 9
n*_period, n*_interval notification_period: timeperiod-objekt Zeitraum, in dem die Benachrichtigungen generiert (Host/Service) oder gefiltert (Kontakt) werden notification_interval: Wiederholungsintervall delay_first_notification: Verzögert die erste Nachricht Open Source Monitoring Conference 2009 Wolfgang Barth 10
Timing-Beispiel (I) define service {... check_interval = 15 ; (min) max_check_attempts = 1 ; notification_period = 9x5 ; (8h-17h) notification_interval = 120 ; (min)... } 7h 8h 9h 10h 7h30 Fehler 1. Nachricht 2. Nachricht Open Source Monitoring Conference 2009 Wolfgang Barth 11
Timing-Beispiel (II) define service {... notification_period = 7x24 ; (immer)... } define contact { notification_period = 9x5 ; (8h-17h) } 7h 8h 9h 10h 7h30 9h30 Fehler 1. Nachricht 2. Nachricht Open Source Monitoring Conference 2009 Wolfgang Barth 12
Timing-Beispiel (III) define service {... notification_period = 7x24 ; (immer) first_notification_delay = 15 ; (min)... } define contact { notification_period = 9x5 ; (8h-17h) } 7h 8h 9h 10h 7h30 9h45 Fehler 1. Nachricht 2. Nachricht Open Source Monitoring Conference 2009 Wolfgang Barth 13
Notifications: Wer Host contactgroups contacts Service host_notification_period host_notification_options Contact/ -group service_notification_period service_notification_options Command externes Programm, z.b. E- Mail, SMS, Webservice,... Open Source Monitoring Conference 2009 Wolfgang Barth 14
Generiert/gefiltert Host Service Nachricht ist generiert Contact/ -group Nachricht ist gefiltert Command Open Source Monitoring Conference 2009 Wolfgang Barth 15
is_volatile=1 nur bei Services vorhanden Benachrichtigung bei jedem Non-OK Hard State Ergebnis notification_interval = deaktiviert sinnvoll bei Services, die sich selbst zurücksetzen: Counter in aktiven Netzwerkkomponenten Logfile-Überwachung Open Source Monitoring Conference 2009 Wolfgang Barth 16
Notifications: Wie Host Service host_notification_commands Contact/ -group service_notification_commands Command externes Programm, z.b. E- Mail, SMS, Webservice,... Open Source Monitoring Conference 2009 Wolfgang Barth 17
*_notification_commands (I) wie jedes andere command-objekt: define command{ command_name notify-by-email command_line /usr/bin/printf "%b" \ "***** Nagios *****\n\n\ Notification Type: $NOTIFICATIONTYPE$\n\n\ Service: $SERVICEDESC$\n\ Host: $HOSTNAME$\n\ Address: $HOSTADDRESS$\n\ State: $SERVICESTATE$\n\n\ Date/Time: $LONGDATETIME$\n\ Duration: $SERVICEDURATION$\n\n\ Additional Info:\n\n\ $SERVICEOUTPUT$" \ /usr/bin/mail -s "$NOTIFICATIONTYPE$ alert - \ $HOSTNAME$/$SERVICEDESC$ is $SERVICESTATE$" $CONTACTEMAIL$ } Open Source Monitoring Conference 2009 Wolfgang Barth 18
*_notification_commands (II) Alternative: externes Skript, das Environment-Variablen verwendet: $HOSTNAME$ -> $NAGIOS_HOSTNAME wichtig: enable_environment_macros = 1 Open Source Monitoring Conference 2009 Wolfgang Barth 19
Eskalationen & Dependencies Open Source Monitoring Conference 2009 Wolfgang Barth 20
Eskalationen (I) Wann wird welcher Kontakt informiert? wann = Anzahl der Benachrichtigungen..3 4..8 7..10 GF admins, secondlevel admins 1 2 3 4 5 6 7 8 9 10 11 Anzahl der Nachrichten Open Source Monitoring Conference 2009 Wolfgang Barth 21
Eskalationen (II) serviceescalation { host_name web01 service_description HTTP first_notification 4 last_notification 8 notification_interval 60 contact_groups admins,secondlevel escalation_period 7x24 escalation_options c,r ; w,u...} Überlappungen Open Source Monitoring Conference 2009 Wolfgang Barth 22
Service-Dependencies (I) web01 Disks web01 Users web01 Load dependent_host_name dependent_service_desc* web01 NRPE host_name service_description Nagios Open Source Monitoring Conference 2009 Wolfgang Barth 23
Service-Dependencies (II) service_dependency { host_name web01 ;master service_description NRPE ;master dependent_host_name web01 dependent_service_description Disks notification_failure_criteria o,w,u,c,p,n } unterbindet eine Benachrichtigung Bezug: Zustand des Master-Services Open Source Monitoring Conference 2009 Wolfgang Barth 24
Same Host Dependency service_dependency { hostgroup_name WEB ;master service_description NRPE ;master dependent_host_name web01 dependent_service_description Disks notification_failure_criteria w,u,c } durch Weglassen des Client-Hosts ist ab Nagios 3.0 der sinnvolle Einsatz von Hostgruppen möglich Open Source Monitoring Conference 2009 Wolfgang Barth 25
Service-Dependencies: weitere Parameter dependency_period zeitliche Einschränkung der Abhängigkeit inherit_parents=0 bei Dependency-Verkettungen: normalerweise gilt die Dependency nur unmittelbar und wird nicht vererbt execution_failure_criteria zur Unterbindung weiterer Checks für Notifications nur indirekt relevant Open Source Monitoring Conference 2009 Wolfgang Barth 26
Host-Dependencies (I) pc01 pc02 pc03 srv01 srv02 nagios pc04 switch1 UP 4 pc05 switch2 DOWN 3 pc06 proxy UNREACHABLE DNS CRITICAL 2 1 gate UNREACHABLE 5 Firewall internetserver 6 UNREACHABLE http://www.swobspace.de Abbildung entnommen aus: Nagios System und Netzwerk-Monitoring, 2. Auflage, Open Source Press, Seite 92 Open Source Monitoring Conference 2009 Wolfgang Barth 27
Host-Dependencies (II) einfachste Lösung: parents builtin ohne zusätzlichen Aufwand Host-Dependencies erlauben Abhängigkeiten außerhalb der normalen Topologie Predictive Dependency Checks enable_predictive_host_dependency_checks enable_predictive_service_dependency_checks Open Source Monitoring Conference 2009 Wolfgang Barth 28
Weitere Einflussgrößen: Flapping Acknowledgements Scheduled Downtime Open Source Monitoring Conference 2009 Wolfgang Barth 29
Flapping OK WARNING CRITICAL UNKNOWN 12/20=60% gewichtet: =62,21% 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Nagios speichert die letzten 21 Zustände Flapping ein: > high_*flap_threshold (20.0) Flapping aus: < low_*flap_threshold (5.0) Bei Beginn/Ende eine eigene Nachricht vom Typ FLAPPINGSTART, FLAPPINGSTOP bei: notification_options = f Open Source Monitoring Conference 2009 Wolfgang Barth 30
Scheduled Downtime Unterbindet Benachrichtigungen während der Downtime notification_options = s Beim Start (DOWNTIMESTART) Beim Ende (DOWNTIMEEND) bei Abbruch (DOWNTIMECANCELLED) Open Source Monitoring Conference 2009 Wolfgang Barth 31
Acknowledgements (I) verhindern weitere Benachrichtigungen zu Fehlerzuständen Nachricht vom Typ ACKNOWLEDGEMENT beim Setzen des ACKs notification_options =... zur Zeit nicht implementiert Open Source Monitoring Conference 2009 Wolfgang Barth 32
Acknowledgements (II) Benachrichtigung heißt: es hat noch niemand reagiert Differenzierung bereits bestätigter Fehler über die Weboberfläche: status.cgi?host=all&type=detail\ &hoststatustypes=3&serviceprops=42\ &servicestatustypes=28 Open Source Monitoring Conference 2009 Wolfgang Barth 33
status.cgi servicestatustypes = 28 4: WARNING 8: UNKNOWN 16: CRITICAL serviceprops = 42 2: keine geplante Downtime 8: kein Acknowledgement 32: Service-Check aktiviert Open Source Monitoring Conference 2009 Wolfgang Barth 34
Custom Notifications SEND_CUSTOM_HOST_NOTIFICATION;host;opts;who;comment SEND_CUSTOM_SVC_NOTIFICATION;host;svc;opts;who;comment External Command File -Schnittstelle ermöglicht zusätzliche Notifications weiterhin an Host/Service gebunden Optionen ( Bitmaske): 0: keine Option 1: Broadcast: normale + eskalierte Kontakte 2: Force: unabhängig von zeitlichen Schranken 4: erhöht den Notification Counter (muss explizit mit angegeben werden!) Open Source Monitoring Conference 2009 Wolfgang Barth 35
External Command File #!/bin/sh now=`date +%s` commandfile='/var/lib/nagios3/rw/nagios.cmd' cmd='set_host_notification_number;web01;0' /bin/printf "[%lu] $cmd\n, $now > $commandfile Beispielskripte unter old.nagios.org/developerinfo/externalcommands/ Open Source Monitoring Conference 2009 Wolfgang Barth 36
das wars... Vielen Dank für Ihre Aufmerksamkeit. Fragen? Open Source Monitoring Conference 2009 Wolfgang Barth 37
timeperiod-objekt 2008-06-09 00:00-24:00 june 1 00:00-24:00 day 2 00:00-24:00 monday 1 00:00-24:00 monday 2 june 00:00-24:00 monday 00:00-24:00 2008-06-09-2008-06-12 00:00-24:00 2008-06-09-2008-06-15 / 2 00:00-24:00 exclude tp1,tp2,tp3 Open Source Monitoring Conference 2009 Wolfgang Barth 38