RocketChat/rocketchat-nagios

Name: rocketchat-nagios

Owner: Rocket.Chat

Description: Sends Nagios notifications to Rocket.Chat, an Open Source Slack Alternative

Forked from: andrefreitas/rocketchat-nagios

Created: 2016-02-10 20:18:58.0

Updated: 2017-11-21 23:25:30.0

Pushed: 2016-02-09 22:34:53.0

Homepage: null

Size: 34

Language: Python

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Rocketchat Nagios Plugin

Send notifications to a Rocketchat channel from Nagios.

Screenshot

Usage

Assuming you are using Nagios 4, the steps are:

  1. Copy rocketchat.py to /usr/local/nagios/libexec.

  2. Create the notification command (replace WEBHOOK_URL):

    define command {
          command_name notify-service-by-rocketchat
          command_line /usr/local/nagios/libexec/rocketchat.py --url WEBHOOK_URL --hostalias "$HOSTNAME$" --notificationtype "$NOTIFICATIONTYPE$" --servicedesc "$SERVICEDESC$" --servicestate "$SERVICESTATE$" --serviceoutput "$SERVICEOUTPUT$"
    }
    
    define command {
          command_name notify-host-by-rocketchat
          command_line /usr/local/nagios/libexec/rocketchat.py --url WEBHOOK_URL --hostalias "$HOSTNAME$" --notificationtype "$NOTIFICATIONTYPE$" --hoststate "$HOSTSTATE$" --hostoutput "$HOSTOUTPUT$"
    }
    
  3. Create the contact:

    define contact {
      contact_name                             rocketchat
      alias                                    Rocketchat
      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-rocketchat
      host_notification_commands               notify-host-by-rocketchat
    }
    
  4. Add the contact to a contact group:

    define contactgroup{
        contactgroup_name   network-admins
        alias               Network Administrators
        members             email, rocketchat
    }
    

Contributing

  1. Launch a development instance of Rocket with Docker:

    docker-compose up
    
  2. Create a new user and channel by accessing Rocket Chat in your browser.

  3. Create a new channel called nagios.

  4. Create a new incoming webhook integration for that channel.

  5. Create a file url.txt with the complete url of the webhook:

    http://192.168.99.100:32769/hooks/jyfgPbsat6cKYxXWS/rocket.cat/O1%2B5u6L2OzvJJYyH6wcfEYifcbbUvoOVsP37Zd%2Fc3b0%3D
    
  6. Test a notification:

    make test-ok test-critical test-unknown test-warning
    

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.