Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / bitcoin / slush_hashrate_ @ 84c28707

Historique | Voir | Annoter | Télécharger (1,09 ko)

1
#!/usr/bin/python
2
# based on https://github.com/pdbrown/munin-custom/blob/master/plugins/hashrate
3
# improved by @deveth0 (donation to 1GzHgp9hsDRsf96MnVk2oo6EG1VmWP9jGs :) )
4
# usage: set your api key in node-config, eg
5
# [slush_*]
6
# env.apikey foobar
7
import sys
8
import urllib2
9
import json
10
import os
11

    
12
SLUSH_URL = 'https://mining.bitcoin.cz/accounts/profile/json/'
13
API_KEY = os.getenv('apikey')
14
SLUSH_STATS = SLUSH_URL + API_KEY
15

    
16
mining_stats_raw = urllib2.urlopen(SLUSH_STATS)
17
mining_stats = json.load(mining_stats_raw)
18
workers = mining_stats['workers']
19

    
20
command = ''
21
if len(sys.argv) > 1:
22
    command = sys.argv[1]
23

    
24
if command == 'config':
25
    print "graph_title Slush Hashrate"
26
    print "graph_args --upper-limit 3000 -l 0"
27
    print "graph_vlabel MHash/s"
28
    print "graph_category htc"
29
    for worker in workers:
30
        label = worker.replace(".","_")
31
        print label + ".label " +label
32
    sys.exit(0)
33

    
34
for worker in workers:
35
        hash_rate = workers[worker]['hashrate']
36
        label = worker.replace(".","_")
37
        print label + ".value %d" % int(hash_rate)