Giter Site home page Giter Site logo

check_mk-slack's Introduction

Check_mk notification script for Slack

Introduction

Update 2019-01-02 - Due to no longer working in a check_mk/slack environment I'm not best placed to maintain this - as of this update this script still works AFAIK, but I won't be able to accept any commits/updates going forward unless I land myself back in a similar environment!

This is a script designed to bounce Check_MK/OMD notifications into a Slack Channel, using Slacks Incoming Webhooks API.

HOW TO USE:

  1. Create an incoming webhook integration in your slack and note down the URL.

  2. Put into /usr/(local/)share/check_mk/notifications (or ~/share/check_mk/notifications on OMD/newer check_mk installs) directory and edit configuration variables in the 'slack' script, and make sure that the script is executable (chmod +x slack)

  3. Restart OMD/Check MK with 'omd restart' or 'cmk -R'

  4. Create a user for slack in WATO, use flexible custom notifications and select 'CMK-Slack Websocket integration' as the notifier.

Select option "Call with the following parameters" and set your channel without "#". If you leave the parameter box in blank the channel takes "#monitoring" value.

  1. Wait for something to send an alert or generate a test alert.

Good to know

I haven't tested this with Notification Bulking (In newer cmk releases), I assume it doesn't work. Where it has been used bulk notification setups, bulking for the slack script has been explicitly disabled.

Requires "requests", so apt-get install python-requests or pip install requests

Test it

if you want to test if you have configured the slack script correcty you can try:

export NOTIFY_PARAMETER_1=dennis-test
export NOTIFY_HOSTNAME=TestHost
export NOTIFY_WHAT=""
export NOTIFY_HOSTACKCOMMENT=false
export NOTIFY_NOTIFICATIONAUTHOR=""
export NOTIFY_HOSTSTATE=DOWN
export NOTIFY_NOTIFICATIONTYPE="WARNING"

Mattermost

To use it with the opensource alternative mattermost run those settings:

your api key url slack_path = "/hooks/kderbmy7yjrr9p9qfwzto374sr"

your mattermost domain slack_domain = "mattermost.example.com"

check_mk-slack's People

Contributors

rmblake avatar snooops avatar victormarroquin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

check_mk-slack's Issues

404 error

Followed to the letter, also removed proxies. Getting a 404 response from manually running the script.

Advice?

Graphs in Slack output

Is it possible to have the same graphs from the email output in the Slack Webhook post?

Two scripts?

This works perfect and was very simple to use. However I wonder if there is any way to use two scripts. I would like to forward all events to one channel but just one service to another channel on another slack site..

I need help

Hi,
first I want to thanks for this plugin.

I have problem with installation. I'm earlier use HipChat plugin, and now I setup your plugin but I have error in log.

I'm create slack file here /omd/sites/monitor/local/share/check_mk/notifications/slack. Give +x rights.
Input variable slack_path, /service/T42342XXXXXX/XXXXXXX/XXXXXX

In check_mk I create new user slack. Create new notification with this user and input name of room without #

When I create some custom notification, nothings happend and I see this in notify.log

Got raw notification context with 49 variables
2016-11-21 13:17:40 Preparing rule based notifications
2016-11-21 13:17:40 Found 0 user specific rules
2016-11-21 13:17:40 Global rule 'slack'...
2016-11-21 13:17:40 -> matches!
2016-11-21 13:17:40 - adding notification of slack via slack
2016-11-21 13:17:40 Executing 1 notifications:
2016-11-21 13:17:40 * notifying slack via slack, parameters: operations, bulk: no
2016-11-21 13:17:40 executing /omd/sites/monitor/local/share/check_mk/notifications/slack
2016-11-21 13:17:41 Output:

Please help !

License

Hello,

Can you add a license to it so i can use it in my project ?

Thanks and best regards,
Mihaescu Bogdan

Error in connectionpool.py

Im getting errors sending notifications using this script. I've installed dependencies (requests) but still getting this error. Any idea how I can fix it?

2020-02-28 12:12:04 Executing 1 notifications:
2020-02-28 12:12:04 * notifying slack via slack, parameters: general, bulk: no
2020-02-28 12:12:04 executing /omd/sites/SAURON/share/check_mk/notifications/slack
2020-02-28 12:12:04 Output: Traceback (most recent call last):
2020-02-28 12:12:04 Output: File "/omd/sites/SAURON/share/check_mk/notifications/slack", line 7, in
2020-02-28 12:12:04 Output: import requests
2020-02-28 12:12:04 Output: File "/omd/sites/SAURON/local/lib/python/requests/init.py", line 43, in
2020-02-28 12:12:04 Output: import urllib3
2020-02-28 12:12:04 Output: File "/omd/sites/SAURON/local/lib/python/urllib3/init.py", line 7, in
2020-02-28 12:12:04 Output: from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, connection_from_url
2020-02-28 12:12:04 Output: File "/omd/sites/SAURON/local/lib/python/urllib3/connectionpool.py", line 100
2020-02-28 12:12:04 Output: _blocking_errnos = {errno.EAGAIN, errno.EWOULDBLOCK}
2020-02-28 12:12:04 Output: ^
2020-02-28 12:12:04 Output: SyntaxError: invalid syntax
2020-02-28 12:12:04 Plugin exited with code 1

dont work for me

I'm having trouble getting the plugin to start.

slack file was copied into the directory, made executable.

Since I use it with Mattermost I have adapted the variable slack_path and slack_domain.

I created a new user and then I wanted to create a notification rule with CMK-SLACK Websocket integration.

But he says always: The Webhook-URL must begin with https://hooks.slack.com/services/

where do I think wrong?

matter

Notification comment for host downtimes

Great plugin. Thanks. :-)
I discovered the following: For Downtimes of Services the comment is shown. For Host downtimes only the Author is shown - but twice.

I guess this is because of line 85. It should be like lin 53.

NOW: (the author is two times in the output)
message += "\nTriggered by " + os.environ['NOTIFY_NOTIFICATIONAUTHOR'] + " - " + os.environ['NOTIFY_NOTIFICATIONAUTHOR'] + ""

NEW:
message += "\nTriggered by " + os.environ['NOTIFY_NOTIFICATIONAUTHOR'] + " - " + os.environ['NOTIFY_NOTIFICATIONCOMMENT'] + ""

What do you think?

Webhooks does not allow multiple channels

Hi,

It seems that a webhook can only send to one channel, so even if you set the argument for the plugin, it still sends to the channel the webhook has access to.

Is there any way to configure the script to use token for authentication?

thank you!

How to integrate checkmk with Moogsoft AIOps with script

Hi,

Idea here is to whatever the events are generated in checkMK it should forward those event notifications from CheckMK to Moogsoft AIOps webhook api which will then take care of creating the incidents in ServiceNow. I know this will be done via custom script but I am not aware of that script.

Can someone suggest how this can be implemented? Is there a prewritten custom script from CheckMK to forward the event notifications? I will be glad if someone have that script or can prepare it for me?

restart of omd-site necessary after insert file "slack"

Great notification plugin. Thanks a lot!

I've been trying a bit, to get it run.
For my installation (ubuntu, check_mk 1.4.0p8) I needed to run "omd restart" on the command line after insert the file "slack" in the folder "/opt/omd/sites//share/check_mk/notifications/". Otherwise "CMK-Slack Websocket integration" can not be selected (during notification creation). It always disappeared and saved incorrectly.

Maybe you could add this hint ("omd restart") to the file "README.md" in the chapter "HOW TO USE:"? (After Step 2)
I guess this could help other users.

Thanks.

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.