Module: check_mk
Branch: master
Commit: 4652adf5366e1eff29b9bdcb4e81b8312413c656
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4652adf5366e1e…
Author: Bastian Kuhn <bk(a)mathias-kettner.de>
Date: Thu Oct 23 15:54:48 2014 +0200
#1189 sms notification: also send information about Downtimes, Acknowledgments and
Fallping now
---
.werks/1189 | 9 +++++++++
ChangeLog | 1 +
notifications/sms | 38 +++++++++++++++++++++++++++++++-------
3 files changed, 41 insertions(+), 7 deletions(-)
diff --git a/.werks/1189 b/.werks/1189
new file mode 100644
index 0000000..1497efa
--- /dev/null
+++ b/.werks/1189
@@ -0,0 +1,9 @@
+Title: sms notification: also send information about Downtimes, Acknowledgments and
Fallping now
+Level: 1
+Component: notifications
+Compatible: compat
+Version: 1.2.5i6
+Date: 1414072375
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index d5b1e7c..1c45197 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -164,6 +164,7 @@
* 1400 Added example notification script for Pushover to
doc/treasures/notifications...
* 1123 Rule based notifications: New condition "Match Service Groups"
* 1186 RBN: It's now possible to Filter for contactgroups...
+ * 1189 sms notification: also send information about Downtimes, Acknowledgments and
Fallping now
* 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)...
* 1407 FIX: Fix exception in rule based notification on non-Ascii characters in log
message
diff --git a/notifications/sms b/notifications/sms
index 6156fa1..89e2119 100755
--- a/notifications/sms
+++ b/notifications/sms
@@ -49,17 +49,41 @@ if not send_path and not spool_dir:
max_len = 160
message = os.environ['NOTIFY_HOSTNAME'] + " "
+notification_type = os.environ["NOTIFICATIONTYPE"]
+
+# Prepare Default information and Type PROBLEM, RECOVERY
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]
+ if notification_type in [ "PROBLEM", "RECOVERY" ]:
+ 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 += os.environ['NOTIFY_SERVICEDESC']
else:
- message += "is " + os.environ['NOTIFY_HOSTSTATE']
+ if notification_type in [ "PROBLEM", "RECOVERY" ]:
+ message += "is " + os.environ['NOTIFY_HOSTSTATE']
+
+# Ouput the other State
+if notification_type.startswith("FLAP"):
+ if "START" in notification_type:
+ message += " Started Flapping"
+ else:
+ message += " Stopped Flapping"
+
+elif notification_type.startswith("DOWNTIME"):
+ what = notification_type[8:].title()
+ message += " Downtime " + what
+
+elif notification_type == "ACKNOWLEDGEMENT":
+ message += " Acknowledged"
+
+elif notification_type == "CUSTOM":
+ message += " Custom Notification"
-recipient = os.environ['NOTIFY_CONTACTPAGER'].replace( " ",
"")
+recipient = os.environ['NOTIFY_CONTACTPAGER'].replace(" ",
"")
if send_path:
if os.system("%s %s '%s'" % (send_path, recipient, message[:160]))
>> 8 != 0: