Monitoring Nagios Using Opsgenie

How do you monitor Nagios? Opsgenie has an easy-to-use plugin that sends heartbeat messages to Opsgenie API. Nagios runs this plugin periodically. If Opsgenie does not receive a heartbeat for a configurable time period, it notifies appropriate people via email, iOS & Android push notifications, SMS and phone calls.

Instructions to use Opsgenie Nagios Plugin:

  1. Please create an Opsgenie account if you haven't done already.
  2. Add a heartbeat in Opsgenie Heartbeats page.
  3. Create an Opsgenie Heartbeat integration from Integrations page and copy its Api key.
  4. Download the Nagios Heartbeat plugin from its GitHub release page and put the binary file into your Nagios libexec directory.
  5. Define a command in Nagios like so:
define command{
	command_name	opsgenie_heartbeat
	command_line	/usr/local/Nagios/libexec/heartbeat -apiKey $ARG1$ -name $ARG2$
}
  1. Define a service that will run the command like so:
define service {
    service_description     OpsGenie Heartbeat
    host_name               localhost
    check_interval          10
    check_period            24x7
    max_check_attempts      60
    retry_interval          1
    notification_interval   60
    check_command           opsgenie_heartbeat!API_KEY!HEARTBEAT_NAME
}

where API_KEY is the api key you acquired from Opsgenie Heartbeat integration and HEARTBEAT_NAME is the name of the heartbeat you added.

Troubleshooting

Make sure the binary file heartbeat is executable.