summaryrefslogtreecommitdiffstats
path: root/Monitoring/plugins/check_btcguild_miner
blob: 102e73da88b1e69133d928bbbc3a6c571e73f554 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/python
import urllib,sys
try:
  import json
  getattr(json,"load") 
except: #deal with it
  import simplejson as json

if len(sys.argv) != 4 :
    print "** Usage: %s APIKEY WORKER_NAME LOW_WORKER_SPEED" % sys.argv[0]
    print "**  aka YOU ARE MADE OF STUPID"
    exit (3)

API_KEY=sys.argv[1]
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"
    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)
            exit (2)
        else:
            print "++ everything fine, current speed is %f" % curr
            exit(0)