Module: check_mk
Branch: master
Commit: e58cd3d1b46fe0bb572cbc84e290a7d406100c49
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e58cd3d1b46fe0…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Dec 16 16:23:37 2013 +0100
sms: now searching PATH for sendsms and smssend commands
In previous versions the notification plugin only used the sendsms
command and was only searching in /usr/bin and /usr/local/bin.
This is more flexible now.
---
.werks/362 | 12 ++++++++++++
ChangeLog | 1 +
notifications/sms | 16 +++++++++-------
3 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/.werks/362 b/.werks/362
new file mode 100644
index 0000000..c93f3b0
--- /dev/null
+++ b/.werks/362
@@ -0,0 +1,12 @@
+Title: sms: now searching PATH for sendsms and smssend commands
+Level: 1
+Component: notifications
+Class: feature
+State: unknown
+Version: 1.2.5i1
+Date: 1387207352
+Targetversion: future
+
+In previous versions the notification plugin only used the sendsms
+command and was only searching in /usr/bin and /usr/local/bin.
+This is more flexible now.
diff --git a/ChangeLog b/ChangeLog
index f4acf3e..a722b8a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -58,6 +58,7 @@
* 0361 FIX: The page linked by "new rule" can now be bookmarked again
Notifications:
+ * 0362 sms: now searching PATH for sendsms and smssend commands...
* 0108 FIX: Prevent service notification on host alerts...
* 0058 FIX: Fix email notifications containing non-ASCII characters in some
situtations...
diff --git a/notifications/sms b/notifications/sms
index 3820672..7fdcf17 100755
--- a/notifications/sms
+++ b/notifications/sms
@@ -4,14 +4,16 @@
# Note: You have to add the side user to the sendsms group
# and restart the site
-import os
+import os, sys
-send_path = '/usr/bin/sendsms'
-if not os.path.exists(send_path):
- send_path = '/usr/local/bin/sendsms'
- if not os.path.exists(send_path):
- print "SMS Tools not found"
- os._exit(1)
+send_path = None
+for binary in [ 'sendsms', 'smssend' ]:
+ if os.system('which %s >/dev/null' % binary) == 0:
+ send_path = binary
+
+if not send_path:
+ sys.stderr.write('Error: SMS Tools binaries (sendsms or smssend) not
found\n')
+ sys.exit(1)
max_len = 160
message = os.environ['NOTIFY_HOSTNAME'] + " "