Giter Site home page Giter Site logo

check_opsgenie_hb's Introduction

check_opsgenie_hb

Nagios/Icinga plugin to send a heartbeat to OpsGenie.

OpsGenie is a service that handles notifications, on-call schedules & escalations. It integrates with Nagios/Icinga(2).

An OpsGenie heartbeat expects to be called every x minutes. If not, it will expire and alerts you.

This is a great way to monitor your Icinga/Nagios server, if it's not able to execute the heartbeat, it is probably not monitoring anything else either.

Create an OpsGenie heartbeat

From your OpsGenie account, setup a heartbeat:

  • Create a Heartbeat Integration from Integrations page, copy the API Key from that page
  • Add your heartbeat from the Heartbeats page, define a unique name and select your desired interval. Without adding heartbeat you are not able to send heartbeat. There can be more than one heartbeat per API key, so the plugin needs this name to identify the heartbeat to call.

The Icinga2 config sample included below sends the Icinga2 constant NodeName as the name of the heartbeat to check. By default that constant contains the full server FQDN as returned by hostname --fqdn. Check for the exact value of it in /etc/icinga2/constants.conf. You can modify the config to send any name you prefer though.

http://i.imgur.com/qEJspVP.png

Add plugin to Nagios / Icinga(2)

Put the plugin on your server in the usual plugin directory.

For Icinga2 you can check for the location in /etc/icinga2/constants.conf:

const PluginDir = "/opt/monitoring-plugins/libexec"

Icinga2 config example

Add an your OpsGenie API key to the constant OpsGenieAPIKey. The constant is used because if you have more OpsGenie configuration (for notifications), you can use that API key constant too instead of repeating it.

The config includes a CheckCommand to call the heartbeat and applies a service to the host who's hostname matches the NodeName constant, which should be your local Icinga2 server.

Make sure your checks run faster than the expire interval of the heartbeat you configured at OpsGenie.

const OpsGenieAPIKey = "your-api-key"

object CheckCommand "opsgenie-hb" {
    import "plugin-check-command"
    command = [ PluginDir + "/check_opsgenie_hb" ]
    arguments = {
        "-a" = {
            required = true
            value = ApiKey
        }
        "-n" = {
            required = true
            value = NodeName
        }
        "-w" = "$expiration_warn$"
        "-c" = "$expiration_crit$"
    }
}

apply Service "opsgenie-hb" {
    import "generic-service"
    check_command = "opsgenie-hb"

    vars.expiration_warn = "60"
    // Warning when the heartbeat runs <= 60 seconds before expiration
    vars.expiration_crit = ""

    assign where host.name == NodeName
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.