summaryrefslogtreecommitdiffstats
path: root/Monitoring
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2011-07-11 18:46:07 +0200
committermakefu <github@syntax-fehler.de>2011-07-11 18:46:07 +0200
commitf1a50c9f15e23df2f367123c32a26a8c725f5cc7 (patch)
treee681f52477931592450efca572b65b2e641a6e94 /Monitoring
parente6320f45061f8ee8214a4e69603f1ff8e1275423 (diff)
Monitoring: added temper and speed files
these scripts need to be consolidatet somehow, added TODO to check_speed scripts provide a way to monitor speed and temperature which is replied by a web-server. This web server collected the informations before of that and tidies up the output
Diffstat (limited to 'Monitoring')
-rwxr-xr-xMonitoring/plugins/check_speed32
-rwxr-xr-xMonitoring/plugins/check_temper31
2 files changed, 63 insertions, 0 deletions
diff --git a/Monitoring/plugins/check_speed b/Monitoring/plugins/check_speed
new file mode 100755
index 00000000..8c2975cd
--- /dev/null
+++ b/Monitoring/plugins/check_speed
@@ -0,0 +1,32 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+#TODO check_speed is nearly the same as check_temper, consolidate both scripts, probably by giving HIGH:LOW as params
+import sys
+import urllib
+
+if len(sys.argv) < 2 or '-h' in sys.argv:
+ print ("usage: %s URL [low-mhashes] ..." % sys.argv[0])
+ print (" Server reply should look like this: '2011-07-11T09:00 400.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:]]
+ 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 ("Warning: %.2f Mhash < %.2f Mhash ! (field %d)" %(temp,thresholds[i],i))
+ ecode=2
+except Exception,e:
+ print("!! Something aweful happened: "+str(e))
+ exit (1)
+if not ecode:
+ print ("Success: Everything is fine!")
+print ("Info: %s Current Mhash: %s" % (date,' '.join([str(i) for i in temps])))
+exit(ecode)
diff --git a/Monitoring/plugins/check_temper b/Monitoring/plugins/check_temper
new file mode 100755
index 00000000..dc006307
--- /dev/null
+++ b/Monitoring/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]
+ speeds = [float(i) for i in ret[1:]]
+ if len(speeds) != len(thresholds):
+ raise Exception("Number of speeds != number of given thresholds")
+ for i,speed in enumerate(speeds):
+ if speed > thresholds[i]:
+ print ("Warning: %f°C > %f°C (field %d)!" %(speed,thresholds[i],i))
+ ecode=2
+except Exception,e:
+ print("!! Something aweful happened: "+str(e))
+ exit (1)
+if not ecode:
+ print ("Success: Everything is fine!")
+print ("Info: %s Current speeds: %s" % (date,' '.join([str(i) for i in speeds])))
+exit(ecode)