Module: check_mk
Branch: master
Commit: b586c2bcd947b7eada35adf1a75879f4171f13d0
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b586c2bcd947b7…
Author: Bernd Stroessenreuther <bs(a)mathias-kettner.de>
Date: Wed Apr 30 08:22:42 2014 +0200
notify_multitech.py: new treasures script for notifying via MultiTech SMS Gateway
donated by Stadt Regensburg
---
.werks/900 | 8 +++++
ChangeLog | 3 +-
doc/treasures/notify_multitech.py | 61 +++++++++++++++++++++++++++++++++++++
3 files changed, 71 insertions(+), 1 deletion(-)
diff --git a/.werks/900 b/.werks/900
new file mode 100644
index 0000000..ce87c05
--- /dev/null
+++ b/.werks/900
@@ -0,0 +1,8 @@
+Title: notify_multitech.py: new treasures script for notifying via MultiTech SMS Gateway
+Level: 2
+Component: notifications
+Version: 1.2.5i3
+Date: 1398838893
+Class: feature
+
+donated by Stadt Regensburg
diff --git a/ChangeLog b/ChangeLog
index 1273e28..c93bcb8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -56,9 +56,9 @@
* 0810 FIX: fritz.link: Not inventorizing "unconfigured" interfaces
anymore
* 0154 FIX: zfsget: Fixed inventory of filesystems
* 0155 FIX: mssql_counters: harded check agains odd agent output
- * 0157 FIX: apc_symmetra_test: Fixed case of unkown last test date
* 0907 FIX: windows agent: register_service: fixed ImagePath registry entry...
* 0608 FIX: oracle_asm_diskgroup: check now also handles older oracle version 11.1.0
+ * 0157 FIX: apc_symmetra_test: Fixed case of unkown last test date
* 0910 FIX: brocade.power: fixed an error where the check reports an UNKNOWN on power
supply failure...
Multisite:
@@ -81,6 +81,7 @@
* 0754 Allow users to disable their notifications completely...
* 0755 Added variables LASTHOSTUP_REL and LASTSERVICEOK_REL to notification
context...
* 0883 Added Date / Time to HTML notification email
+ * 0900 notify_multitech.py: new treasures script for notifying via MultiTech SMS
Gateway...
* 0752 FIX: FIX: compute correct state transitions for notifications...
* 0753 FIX: FIX: correctly show original state in HTML notification mails...
* 0609 FIX: mail notification script now uses 6 digit hex codes for colors to be
better compatible with web based mail browsers
diff --git a/doc/treasures/notify_multitech.py b/doc/treasures/notify_multitech.py
new file mode 100755
index 0000000..8c9c2c0
--- /dev/null
+++ b/doc/treasures/notify_multitech.py
@@ -0,0 +1,61 @@
+#!/usr/bin/python
+# Send SMS via MultiTech SMS-Gateway # encoding: utf-8
+#
+# This notification script can be put below share/check_mk/notifications. It sends
+# SMS via a MultiTech SMS-Gateway. Please add your personal configuration directly in
this
+# script. The target phone number is take from the contact's pager address.
+# You can override this by specifying it as a parameter
+import sys, os, urllib
+
+# This does not need to be changed
+to = os.environ.get("NOTIFY_CONTACTPAGER")
+fromname = "Check_MK"
+user = "nagios"
+passwd = "test123"
+url = "http://isms.example.com/sendmsg?"
+
+
+if len(sys.argv) > 1:
+ to = sys.argv[1]
+
+if not to:
+ sys.stderr.write("NOTIFY_CONTACTPAGER is not set.\n")
+ sys.exit(1)
+
+
+max_len = 160
+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']
+
+# constructing a url like
+#
http://isms.example.com/sendmsg?user=nagios&passwd=test123&cat=1&am…
+url += urllib.urlencode([
+ ( "user", user ),
+ ( "passwd", passwd ),
+ ( "cat", "1" ),
+ ( "to", to ),
+ ( "text", message )
+])
+
+
+try:
+ handle = urllib.urlopen(url)
+ response = handle.read().strip()
+ print response
+ if response.startswith("ID:"):
+ sys.stdout.write("Successfully sent SMS to %s\n" % to)
+ else:
+ sys.stderr.write("Error sending SMS to %s: %s\n" % (to, response))
+ sys.stderr.write("URL was %s\n" % url)
+except Exception, e:
+ sys.stderr.write("Error sending SMS to %s. Exception: %s%s\n" % e)
+