Benutzer-Werkzeuge

Webseiten-Werkzeuge


nagiosnotification

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen Revision Vorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
nagiosnotification [2018/04/03 14:20]
dh3wr [Define DAPNET Username and Password]
nagiosnotification [2018/04/05 17:16]
dh3wr [Notification to Pager from Nagios via DAPNET-Core]
Zeile 1: Zeile 1:
-====== Notification to Pager from Nagios ======+====== Notification to Pager from Nagios ​via DAPNET-Core ​======
  
-By default, Nagios can send emails to registered contact. Fortunately,​ there is also a contact property names ''​pager''​ which can be used very conveniently. Two things have to be added to your nagios config in order to reveice ​the Nagios notifications via DAPNET.+By default, Nagios can send emails to registered contact. Fortunately,​ there is also a contact property names ''​pager''​ which can be used very conveniently. Two things have to be added to your nagios config in order to receive ​the Nagios notifications via DAPNET
 + 
 +If you want to send the notifications directly via [[unipager|UniPager]],​ use this solution: [[nagiosnotificationunipager|Notification to Pager from Nagios via UniPager]].
  
 ===== Define commands to send paging calls ===== ===== Define commands to send paging calls =====
Zeile 10: Zeile 12:
 define command{ define command{
         command_name ​   notify-host-by-pager         command_name ​   notify-host-by-pager
-        command_line ​   /​usr/​bin/​curl -H "​Content-Type:​ application/​json"​ -X POST -u $USER12$:​$USER13$ -d '{ "​text":​ "​NAGIOS $NOTIFICATIONTYPE$:​ $HOSTNAME$ $$+        command_line ​   /​usr/​bin/​curl -H "​Content-Type:​ application/​json"​ -X POST -u $USER12$:​$USER13$ -d '{ "​text":​ "​NAGIOS $NOTIFICATIONTYPE$:​ $HOSTNAME$ $HOSTSTATE$", "​callSignNames":​ ["​$CONTACTPAGER$"​],​ "​transmitterGroupNames":​ ["​$CONTACTADDRESS1$"​],​ "​emergency":​ false }' $USER11$/​calls
         }         }
  
Zeile 16: Zeile 18:
 define command{ define command{
         command_name ​   notify-service-by-pager         command_name ​   notify-service-by-pager
-        command_line ​   /​usr/​bin/​curl -H "​Content-Type:​ application/​json"​ -X POST -u $USER12$:​$USER13$ -d '{ "​text":​ "​NAGIOS $NOTIFICATIONTYPE$:​ $HOSTNAME$ $$+        command_line ​   /​usr/​bin/​curl -H "​Content-Type:​ application/​json"​ -X POST -u $USER12$:​$USER13$ -d '{ "​text":​ "​NAGIOS $NOTIFICATIONTYPE$:​ $HOSTNAME$ $SERVICEDESC$SERVICESTATE$",​ "​callSignNames":​ ["​$CONTACTPAGER$"​],​ "​transmitterGroupNames":​ ["​$CONTACTADDRESS1$"​],​ "​emergency":​ false }' $USER11$/​calls
         }         }
 +
 </​code>​ </​code>​
  
-===== Define DAPNET ​Username ​and Password ​===== +===== Define DAPNET ​API-URL, username ​and password ​===== 
-As you see, there are macros ''​$USER12$'' ​and ''​$USER13$''​ used. They should contain your DAPNET username and password. Define them in the ''​resource.cfg'':​+As you see, there are macros ''​$USER11$'' ​to ''​$USER13$''​ used. They should contain ​the API-URL, ​your DAPNET username and password. Define them in the ''​resource.cfg'':​
 <​code>​ <​code>​
 +$USER11$=http://​dapnet.db0sda.ampr.org:​8080
 $USER12$=dl1abc $USER12$=dl1abc
 $USER13$=VERYSCECRETPASSWORD $USER13$=VERYSCECRETPASSWORD
 </​code>​ </​code>​
 +
 +If you don't have HAMNET access to dapnet.db0sda.ampr.org,​ use ''​http://​hampager.de/​api''​ without port (default 80 is right) or use your own DAPNET Core's API.
 +
 +===== Setup contacts =====
 +Edit ''​contacts.cfg''​ and add the pager subscriber as set in DAPNET and the notification commands:
 +<​code>​
 +define contact{
 +        contact_name ​                   dh3wr
 +        alias                           Ralf Wilke
 +        service_notifications_enabled ​  1
 +        host_notifications_enabled ​     1
 +        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,​notify-service-by-pager
 +        host_notification_commands ​     notify-host-by-email,​notify-host-by-pager
 +        email                           ​spam@myemail.cl
 +        pager                           dh3wr
 +        address1 ​                       dl-nw
 +        }
 +
 +</​code>​
 +The ''​pager''​ entry defines the subscriber on DAPNET, the ''​address1''​ defines the transmitter group. Remember to add the commands just created.
 +
 +{{:​icons:​warning.png?​nolink |}}{{ :​icons:​warning.png?​nolink|}}Attention:​ In order to minimize traffic on the DAPNET, please select a transmitter group just big enough to fulfill your requirements. Not whole Europe wants to be informed, that you disk space is below 10%.
 +
 +===== Assign the contact to the host or service =====
 +Either use the template or define at each host and service the contacts you want to notify.
 +<​code>​
 +define host{
 +        name                            generic-host-rwthafu ​   ; 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 ​             10
 +        notification_interval ​          0
 +        notification_period ​            24x7
 +        notification_options ​           d,u,r
 +        contacts ​                       rwthafu,​dh3wr
 +        register ​                       0       ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
 +        }
 +</​code>​
 +
 +===== Example =====
 +This is how the result looks like:
 +{{ :​swissphone:​swissphone2_300.jpg?​direct |}}
  
nagiosnotification.txt · Zuletzt geändert: 2018/04/05 17:16 von dh3wr