summaryrefslogtreecommitdiffstats
path: root/god/Monitoring/nagios/plugins/check_temper
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2013-01-14 14:46:22 +0100
committermakefu <github@syntax-fehler.de>2013-01-14 14:46:22 +0100
commitdbe2d838ba6834788265029162b2dd7d82473335 (patch)
treea4eb38f7fc91d91269b6f83453de62242c6ddc23 /god/Monitoring/nagios/plugins/check_temper
parent5a782f6c8f7923f9f415afd504ce6e71acbc7fef (diff)
parentabf9916bc1add17888308877fa4eb9da330297ef (diff)
Merge branch 'master' of github.com:krebscode/painload
Conflicts: god/temper/Makefile god/temper/collectd-temper.sh
Diffstat (limited to 'god/Monitoring/nagios/plugins/check_temper')
-rwxr-xr-xgod/Monitoring/nagios/plugins/check_temper31
1 files changed, 31 insertions, 0 deletions
diff --git a/god/Monitoring/nagios/plugins/check_temper b/god/Monitoring/nagios/plugins/check_temper
new file mode 100755
index 00000000..95191026
--- /dev/null
+++ b/god/Monitoring/nagios/plugins/check_temper
@@ -0,0 +1,31 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+import sys
+import urllib
+
+if len(sys.argv) < 2 or '-h' in sys.argv:
+ print ("?? usage: %s URL [high-val field 1] [high field 2] ..." % sys.argv[0])
+ print ("?? Server reply should look like this: '2011-07-11T09:00 50.0 40.0'")
+ exit(3)
+
+URL=sys.argv[1]
+thresholds=[ float(i) for i in sys.argv[2:]]
+
+ecode=0
+try:
+ ret = urllib.urlopen(URL).read().split()
+ date = ret[0]
+ temps = [float(i) for i in ret[1:]]
+ print ("** %s : %s" % (date,' '.join([str(i)+"°C" for i in temps])))
+ if len(temps) != len(thresholds):
+ raise Exception("Number of temps != number of given thresholds")
+ for i,temp in enumerate(temps):
+ if temp > thresholds[i]:
+ print ("!! %.2f°°C > %.2f°C (field %d)!" %(temp,thresholds[i],i))
+ ecode=2
+except Exception,e:
+ print("!! Something awful happened: "+str(e))
+ exit (1)
+if not ecode:
+ print ("** Everything is fine!")
+exit(ecode)