How to Integrate Icinga with PagerDuty

Introduction

This guide describes how to integrate your Icinga installation with PagerDuty using a simple Perl-based plugin. As Icinga is a fork of Nagios, we’ll be using PagerDuty’s built in support for Nagios for this integration. Note that you must be logged in as root to complete the installation. You might need to slightly alter these instructions depending on your exact Linux distribution and your Icinga configuration. If you are having trouble completing the installation, please contact us.

Getting Started

If you don’t already have a PagerDuty “Icinga” service, you should create one:

  1. In your account, under the Services tab, click “Add New Service”.
    SL-AddNewServiceButton
  2. Enter a Service Name and select an Escalation Policy.
  3. Start typing “Icinga” under “Integration Type” to filter your choices. Then, click the Add Service button.
    Icinga
  4. Once the service is created, you’ll be taken to the service page. On this page, you’ll see the “Service key”, which will be needed when you configure your Icinga server to send events to PagerDuty.

Setup

  1. Install the necessary Perl dependencies: For Debian, Ubuntu, and other Debian-derived systems:
    aptitude install libwww-perl libcrypt-ssleay-perl

    RHEL, Fedora, CentOS, and other Redhat-derived systems:

    yum install perl-libwww-perl perl-Crypt-SSLeay
  2. Download pagerduty_icinga.cfg from github
    wget https://raw.github.com/PagerDuty/pagerduty-icinga-pl/master/pagerduty_icinga.cfg
  3. Open the file in your favorite editor.
  4. Enter the service key corresponding to your Nagios/Icinga service into the pager field. The service key is a 32 character string that can be found on the service’s detail page.
  5. Copy the Icinga configuration file into place and change owner:
    cp pagerduty_icinga.cfg /usr/local/icinga/etc/objects 
    chown icinga:icinga /usr/local/icinga/etc/objects/pagerduty_icinga.cfg
  6. Add the contact “pagerduty” to your Icinga configuration’s main contact group. If you’re using the default configuration, open /usr/local/icinga/etc/objects/contacts.cfg and look for the “admins” contact group. Then, simply add the “pagerduty” contact.
    define contactgroup{ 
        contactgroup_name admins 
        alias Icinga Administrators 
        members icingaadmin,pagerduty ; <-- Add 'pagerduty' here. 
    }
  7. Download pagerduty_icinga.pl from github and copy it to /usr/local/bin.
    wget https://raw.github.com/PagerDuty/pagerduty-icinga-pl/master/pagerduty_icinga.pl 
    cp pagerduty_icinga.pl /usr/local/bin
  8. Make sure the file is executable by Icinga
    chmod 755 /usr/local/bin/pagerduty_icinga.pl
  9. Enable environment variable macros in /usr/local/icinga/icinga.cfg (if not enabled already)
    enable_environment_macros=1
  10. Edit the icinga user’s crontab
    crontab -u icinga -e
  11. Add the following line to the crontab
    * * * * * /usr/local/bin/pagerduty_icinga.pl flush
  12. Restart Icinga
    /etc/init.d/icinga restart

FAQ

What if a Icinga event happens while my network is down?

If a PagerDuty server can’t be reached for any reason, events will be stored to an on-disk queue. The installed cron job will attempt to re-send the events at one minute interval..

Since Icinga needs my external Internet connection to send failure reports to PagerDuty, how will I receive notification if our site loses external connectivity?

You should configure an external ping check service like Pingdom to monitor your site’s external connectivity. Of course, you can use PagerDuty to forward alerts from these services.

It doesn’t seem to be working. What’s going on?

Check the syslog for messages from “pagerduty_icinga”. On most systems:

grep pagerduty_icinga /var/log/syslog

Please contact us if you’re unable to sort out the difficulty.

What sort of Icinga messages does PagerDuty understand?

PagerDuty can process PROBLEM, ACKNOWLEDGEMENT, and RECOVERY messages. All other messages, including FLAPPINGSTART and FLAPPINGSTOP, are ignored. If you’d like PagerDuty to process additional Icinga messages, please let us know!

What about a 2-way ack integration between Icinga and PagerDuty?

PagerDuty customers have built a bi-directional integration package for Nagios/Icinga and PagerDuty making use of PagerDuty’s generic integration API and webhooks to send notifications from Nagios/Icinga to PagerDuty and to keep alert acknowledgment status in sync. Learn more about it here.