[icinga-users] Icinga 2 PagerDuty Integration

Dan Wardle lets.troop at gmail.com
Fri Aug 22 08:41:38 CEST 2014


Hi folks

I'm trying to get my Icinga 2 server to play nicely with my PagerDuty
account. The PagerDuty/Icinga integration guide on the PD website is for
Icinga 1, so I've been using the suggested configuration from this post
https://lists.icinga.org/pipermail/icinga-users/2014-May/008201.html

So far, all of my attempts to get events to be accepted by the PagerDuty
server using this configuration have failed. I have, however, been able to
have events accepted when I try to run pagerduty_icinga.pl from the
terminal, but only if I specify the HOSTSTATE AND NOTIFICATIONTYPE values
in uppercase:

/usr/local/bin/pagerduty_icinga.pl enqueue -f pd_nagios_object=host -f
HOSTNAME=pagerduty_test -f HOSTSTATE=DOWN -f NOTIFICATIONTYPE=PROBLEM -f
CONTACTPAGER=<apikey>

The same command with HOSTSTATE and NOTIFICATIONTYPE values in lowercase
causes the event to be rejected by the server. From the syslog on the
Icinga 2 server:

Aug 21 23:36:03 mon-icinga2 pagerduty_icinga[15416]: Icinga event in file
/tmp/pagerduty_icinga/pd_1408689363_15416.txt REJECTED by the PagerDuty
server.  Server says: The NOTIFICATIONTYPE field must be present and must
be one of: PROBLEM, ACKNOWLEDGEMENT, RECOVERY, NOP.

Is there a way to get Icinga 2 to pass the variable values in uppercase
rather than lowercase?

Thanks in advance for any assistance!
Dan

pagerduty.conf:

object NotificationCommand "notify-service-by-pagerduty" {
   import "plugin-notification-command"
   command = "/usr/local/bin/pagerduty_icinga.pl enqueue -f
pd_nagios_object=service -f NOTIFICATIONTYPE=$NOTIFICATIONTYPE$ -f
HOSTNAME=$HOSTNAME$ -f SERVICEDESC=$SERVICEDESC$ -f
SERVICESTATE=$SERVICESTATE$"

   env = {
     "CONTACTPAGER" = "$user.pager$"
     "NOTIFICATIONTYPE" = "$notification.type$"
     "SERVICEDESC" = "$service.name$"
     "HOSTNAME" = "$host.name$"
     "HOSTALIAS" = "$host.display_name$"
     "SERVICESTATE" = "$service.state$"
     "SERVICEOUTPUT" = "$service.output$"
   }

}

object NotificationCommand "notify-host-by-pagerduty" {
   import "plugin-notification-command"
   command = "/usr/local/bin/pagerduty_icinga.pl enqueue -f
pd_nagios_object=host -f HOSTNAME=$HOSTNAME$ -f HOSTSTATE=$HOSTSTATE$ -f
NOTIFICATIONTYPE=$NOTIFICATIONTYPE$"

   env = {
     "CONTACTPAGER" = "$user.pager$"
     "NOTIFICATIONTYPE" = "$notification.type$"
     "HOSTNAME" = "$host.name$"
     "HOSTALIAS" = "$host.display_name$"
     "HOSTSTATE" = "$host.state$"
     "HOSTOUTPUT" = "$host.output$"
   }
}

object User "pagerduty" {
   display_name = "PagerDuty Notification User"
   pager = "<apikey>"
}

apply Notification "pagerduty-service" to Service {
   command = "notify-service-by-pagerduty"
   states = [ OK, Warning, Critical, Unknown ]
   types = [ Problem, Acknowledgement, Recovery, Custom ]
   period = "24x7"
   users = [ "pagerduty" ]

   assign where service.vars.enable_pagerduty == true
}

apply Notification "pagerduty-host" to Host {
   command = "notify-host-by-pagerduty"
   states = [ Up, Down ]
   types = [ Problem, Acknowledgement, Recovery, Custom ]
   period = "24x7"
   users = [ "pagerduty" ]

   assign where host.vars.enable_pagerduty == true
}

object Service "pagerduty-test-service" {
   import "generic-service"
   check_command = "ping4"
   host_name = "pagerduty-test-host"

   vars.enable_pagerduty = true
}

object Host "pagerduty-test-host" {
   import "generic-host"
   address = "127.0.0.1"

   vars.enable_pagerduty = true
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.icinga.org/pipermail/icinga-users/attachments/20140821/4b87e5d8/attachment.html>


More information about the icinga-users mailing list