summaryrefslogtreecommitdiffstats
path: root/Monitoring/plugins/check_btcguild_miner
diff options
context:
space:
mode:
authorFelix Richter <github@syntax-fehler.de>2011-07-01 10:49:52 +0200
committerFelix Richter <github@syntax-fehler.de>2011-07-01 10:49:52 +0200
commit45370ad5e95333eb919fe945ebc8c4daafe49cbb (patch)
tree8f40ead70e3618c7dd773dd58cd8b7adc65aa2b7 /Monitoring/plugins/check_btcguild_miner
parent2123e259269ef2ff40954d2b8130c284d2ebb0fa (diff)
check_btcguild_miner: added Exception evaluation
Diffstat (limited to 'Monitoring/plugins/check_btcguild_miner')
-rwxr-xr-xMonitoring/plugins/check_btcguild_miner13
1 files changed, 8 insertions, 5 deletions
diff --git a/Monitoring/plugins/check_btcguild_miner b/Monitoring/plugins/check_btcguild_miner
index 102e73da..2e6a8de3 100755
--- a/Monitoring/plugins/check_btcguild_miner
+++ b/Monitoring/plugins/check_btcguild_miner
@@ -1,5 +1,7 @@
#!/usr/bin/python
-import urllib,sys
+
+import sys
+from urllib2 import urlopen
try:
import json
getattr(json,"load")
@@ -16,16 +18,17 @@ WORKER_NAME=sys.argv[2]
LOW_WORKER_SPEED=float(sys.argv[3])
url="http://www.btcguild.com/api.php?api_key=%s" % API_KEY
try:
- result = json.load(urllib.urlopen(url))
-except:
- print "?? cannot parse json or connect to server"
+ fh = urlopen(url)
+ result = json.load(fh)
+except Exception,e:
+ print "?? cannot parse json or connect to server: %s"% str(e)
exit (1)
for k,v in result["workers"].iteritems():
if v["worker_name"] == WORKER_NAME:
curr = v["hash_rate"]
if curr < LOW_WORKER_SPEED:
- print "!! %f is below expected %f" (curr,LOW_WORKER_SPEED)
+ print "!! %f is below expected %f" % (curr,LOW_WORKER_SPEED)
exit (2)
else:
print "++ everything fine, current speed is %f" % curr