Module: check_mk
Branch: master
Commit: 8c8553ad5746428cfd8935089bedceb8de60f08e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8c8553ad574642…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Sep 15 09:10:17 2014 +0200
#1400 Added example notification script for Pushover to doc/treasures/notifications
This plugin can send notifications via
pushover.net. You need to edit your keys
directly in the script. There is not yet a WATO integration.
---
.werks/1400 | 10 +++
ChangeLog | 1 +
doc/treasures/notifications/README | 8 +++
.../{notify_mobilant.py => notifications/mobilant} | 0
.../multitech} | 0
doc/treasures/notifications/pushover | 67 ++++++++++++++++++++
.../{notify_trap => notifications/snmp_trap} | 0
7 files changed, 86 insertions(+)
diff --git a/.werks/1400 b/.werks/1400
new file mode 100644
index 0000000..19314e5
--- /dev/null
+++ b/.werks/1400
@@ -0,0 +1,10 @@
+Title: Added example notification script for Pushover to doc/treasures/notifications
+Level: 2
+Component: notifications
+Compatible: compat
+Version: 1.2.5i6
+Date: 1410764966
+Class: feature
+
+This plugin can send notifications via
pushover.net. You need to edit your keys
+directly in the script. There is not yet a WATO integration.
diff --git a/ChangeLog b/ChangeLog
index dbf911a..b222317 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -117,6 +117,7 @@
Notifications:
* 1151 Add variables (HOST/SERVICE)ACK(AUTHOR/COMMENT) to notification context...
* 1394 HTML notifications have a new content field for debugging variables...
+ * 1400 Added example notification script for Pushover to
doc/treasures/notifications...
* 1156 FIX: Graphs in HTML mails are now sent again where they where missing...
* 1157 FIX: Fixed SMS plugin on at least debian (distrs which have no
sendsms/smssend)...
diff --git a/doc/treasures/notifications/README b/doc/treasures/notifications/README
new file mode 100644
index 0000000..103dbc9
--- /dev/null
+++ b/doc/treasures/notifications/README
@@ -0,0 +1,8 @@
+These are notifications plugins for Check_MK. You can put them
+in the notifications/ directory of your Check_MK installations.
+OMD-based users put this into their site in to.
+local/share/check_mk/notifications/
+
+These scripts to not yet have a WATO integration. You might
+need to update keys, passwords, etc. directly within these
+scripts currently.
diff --git a/doc/treasures/notify_mobilant.py b/doc/treasures/notifications/mobilant
similarity index 100%
rename from doc/treasures/notify_mobilant.py
rename to doc/treasures/notifications/mobilant
diff --git a/doc/treasures/notify_multitech.py b/doc/treasures/notifications/multitech
similarity index 100%
rename from doc/treasures/notify_multitech.py
rename to doc/treasures/notifications/multitech
diff --git a/doc/treasures/notifications/pushover b/doc/treasures/notifications/pushover
new file mode 100755
index 0000000..521704f
--- /dev/null
+++ b/doc/treasures/notifications/pushover
@@ -0,0 +1,67 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2014 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at
http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# ails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+# Send notification to Pushover
+#
+# This notification script can be put below share/check_mk/notifications. It sends
+# notifications to Pushover. Note: this currently is just a simple test. The device
+# should probably be set to a user name or similar.
+
+import sys, os, urllib, httplib
+
+# Enter your keys and tokens here. For details about what that's
+# about please refer to the Pushover documentation.
+user_key = "XXXXXXXXXXXXXXXXXXXXXXXXXXX"
+app_token = "XXXXXXXXXXXXXXXXXXXXXXXXXXX"
+device = "XXXXX"
+
+message = os.environ['NOTIFY_HOSTNAME'] + " "
+
+if os.environ['NOTIFY_WHAT'] == 'SERVICE':
+ message += os.environ['NOTIFY_SERVICESTATE'][:2] + " "
+ avail_len = max_len - len(message)
+ message += os.environ['NOTIFY_SERVICEDESC'][:avail_len] + " "
+ avail_len = max_len - len(message)
+ message += os.environ['NOTIFY_SERVICEOUTPUT'][:avail_len]
+
+else:
+ message += "is " + os.environ['NOTIFY_HOSTSTATE']
+
+
+conn = httplib.HTTPSConnection("api.pushover.net:443")
+conn.request("POST", "/1/messages.json",
+urllib.urlencode({
+ "token" : app_token,
+ "user" : user_key,
+ "message" : message,
+}), { "Content-type": "application/x-www-form-urlencoded" })
+response = conn.getresponse()
+headers = dict(response.getheaders())
+status = headers.get('status')
+code, explanation = status.split(None, 1)
+if code != "200":
+ print "Failed to notify via Pushover: %s, HTTP status is %s" %
(explanation, status)
+ sys.exit(1)
diff --git a/doc/treasures/notify_trap b/doc/treasures/notifications/snmp_trap
old mode 100644
new mode 100755
similarity index 100%
rename from doc/treasures/notify_trap
rename to doc/treasures/notifications/snmp_trap