summaryrefslogtreecommitdiffstats
path: root/god/Monitoring/nagios/plugins/check_speed
diff options
context:
space:
mode:
authoreuer <root@euer.krebsco.de>2012-12-23 00:21:25 +0100
committereuer <root@euer.krebsco.de>2012-12-23 00:21:25 +0100
commit9456cfffea015812acf5dcdd2d074e98ca54e720 (patch)
treee57111b7d1499bb6f1ef49937f5f62de158ae5db /god/Monitoring/nagios/plugins/check_speed
parent3649aff46c8bace238c3cf22abcfbfe8be9dce8a (diff)
//Monitoring -> //god/Monitoring
Diffstat (limited to 'god/Monitoring/nagios/plugins/check_speed')
-rwxr-xr-xgod/Monitoring/nagios/plugins/check_speed34
1 files changed, 34 insertions, 0 deletions
diff --git a/god/Monitoring/nagios/plugins/check_speed b/god/Monitoring/nagios/plugins/check_speed
new file mode 100755
index 00000000..14a5b612
--- /dev/null
+++ b/god/Monitoring/nagios/plugins/check_speed
@@ -0,0 +1,34 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+#TODO check_speed is nearly the same as check_speeder, 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]
+ speeds = [float(i) for i in ret[1:]]
+ print ("** %s : %s Mhashes" % (date,' '.join([str(i) for i in speeds])))
+ 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 ("!! %.2f Mhash < %.2f Mhash ! (field %d)" %(speed,thresholds[i],i))
+ ecode=2
+except Exception,e:
+ print("!! Something aweful happened: "+str(e))
+ exit (1)
+#TODO return WARNING if date is too old
+if not ecode:
+ print ("** Everything is fine!")
+
+exit(ecode)