Skip to content
This repository has been archived by the owner on Jan 12, 2020. It is now read-only.

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

License

Notifications You must be signed in to change notification settings

andrefreitas/rocketchat-nagios

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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$" --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$" --hoststate "$HOSTSTATE$" --hostoutput "$HOSTOUTPUT$"
     }
    

You can also specify a Nagios URL parameter in order to get a valid URL to your alert in the Rocket Chat message (replace NAGIOS_URL):

    define command {
          command_name notify-service-by-rocketchat
          command_line /usr/local/nagios/libexec/rocketchat.py --url WEBHOOK_URL --hostalias "$HOSTNAME$" --servicedesc "$SERVICEDESC$" --servicestate "$SERVICESTATE$" --serviceoutput "$SERVICEOUTPUT$" --nagiosurl "NAGIOS_URL"
    }
  1. 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
     }
    
  2. 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 -d
    
  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
    

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published