Git Product home page Git Product logo

nagios-slack-notifications's Introduction

Nagios Slack Notifications

Overview

The official Nagios Slack plugin is terrible, requiring multiple random perl dependencies. This uses a simple curl script in conjunction with a Webhook to post notifications directly.

This method is far simpler and allows you to maintain your Nagios configuration in a single location. The way it's set up also allows the script to be re-used for multiple channels if necessary.

Screenshot

Screenshot of Notifications

Installation

Slack

  1. Go to the Apps and Integrations page within Slack, search for Incoming Webhooks and hit Add Configuration
  2. Select the channel you wish to post alerts to and hit Add Incoming Webhook Integration
  3. Make a note of the Webhook URL (You'll need the part past the https://hooks.slack.com/services/ bit. e.g - T07B2S2CC/B1HDDQ83A/naizPgXARIlUSixE0RUL93Oy)
  4. Change the Customize Name field to: nagios-alerts
  5. Change the icon to the icon.png image in this repository.
  6. Hit Save Settings

Nagios

Add the following line to your Nagios configuration and modify the details:

define command {
  command_name		notify-host-slack-mychannel1 
  command_line		/bin/bash /path/to/nagios-monitoring-scripts/notification_slack.sh -a "$NOTIFICATIONTYPE$" -b "$HOSTNAME$" -c "$HOSTSTATE$" -d "$HOSTOUTPUT$" -y "CHANNEL_NAME_HERE" -z "WEBHOOK_ADDRESS_HERE"
}

define command {
  command_name		notify-service-slack-mychannel1 
  command_line		/bin/bash /path/to/nagios-monitoring-scripts/notification_slack.sh -a "$NOTIFICATIONTYPE$" -b "$HOSTNAME$" -e "$SERVICEDESC$" -f "$SERVICESTATE$" -g "$SERVICEOUTPUT$"  -y "CHANNEL_NAME_HERE" -z "WEBHOOK_ADDRESS_HERE"
}

notification_slack.sh

Open the notification_slack.sh script and modify the SLACK_HOSTNAME and MONITORING_URL variables to your environment.

Other Information

This script has been tested on multiple servers with different versions of curl. The script accounts for older versions of curl with another command.

Please fork and contribute if you find any bugs.

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.