Projet

Général

Profil

Révision 3bf0c91b

ID3bf0c91b92416501e2c14919d44178159b8d0060
Parent 84866ca6
Enfant 2213ba06

Ajouté par deveth0 il y a presque 12 ans

Update slush_hashrate_

Moved from filename to env parameter for the api key. This way the api key is no longer displayed as the chart name

Voir les différences:

plugins/bitcoin/slush_hashrate_
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: link to slush_hashrate_YOURAPIKEY
5
import sys
6
import urllib2
7
import json
8

  
9
SLUSH_URL = 'https://mining.bitcoin.cz/accounts/profile/json/'
10
API_KEY =  sys.argv[0][(sys.argv[0].rfind('_')+1):]
11
SLUSH_STATS = SLUSH_URL + API_KEY
12

  
13
mining_stats_raw = urllib2.urlopen(SLUSH_STATS)
14
mining_stats = json.load(mining_stats_raw)
15
workers = mining_stats['workers']
16

  
17
command = ''
18
if len(sys.argv) > 1:
19
    command = sys.argv[1]
20

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

  
31
for worker in workers:
32
        hash_rate = workers[worker]['hashrate']
33
        label = worker.replace(".","_")
34
        print label + ".value %d" % int(hash_rate)
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 Bitcoin"
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)

Formats disponibles : Unified diff