2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00

Merge pull request #361 from deveth0/master

Plugins for Bitcoin-Miner Hashrates (btcguild and slushs pool)
This commit is contained in:
Kenyon Ralph 2013-11-03 01:40:40 -07:00
commit 9153f029de
3 changed files with 109 additions and 0 deletions

View File

@ -0,0 +1,41 @@
#!/usr/bin/python
# based on https://github.com/pdbrown/munin-custom/blob/master/plugins/hashrate
# improved by @deveth0 (donation to 1GzHgp9hsDRsf96MnVk2oo6EG1VmWP9jGs :) )
# usage: link to slush_hashrate_YOURAPIKEY
import sys
import urllib2
import json
URL = 'https://www.btcguild.com/api.php?api_key='
API_KEY = sys.argv[0][(sys.argv[0].rfind('_')+1):]
STATS = URL + API_KEY
print STATS
command = ''
if len(sys.argv) > 1:
command = sys.argv[1]
header = {'User-Agent':'Mozilla/5.0'}
request = urllib2.Request(STATS,headers=header)
mining_stats_raw = urllib2.urlopen(request)
mining_stats = json.load(mining_stats_raw)
workers = mining_stats['workers']
if command == 'config':
print "graph_title BTCGuild Hashrate"
print "graph_args --upper-limit 3000 -l 0"
print "graph_vlabel MHash/s"
print "graph_category Bitcoin"
for worker in workers:
label = workers[worker]['worker_name']
print label + ".label " + label
sys.exit(0)
for worker in workers:
hash_rate = workers[worker]['hash_rate']
label = workers[worker]['worker_name']
print label + ".value %d" % int(hash_rate)

View File

@ -0,0 +1,34 @@
#!/usr/bin/python
# based on https://github.com/pdbrown/munin-custom/blob/master/plugins/hashrate
# improved by @deveth0 (donation to 1GzHgp9hsDRsf96MnVk2oo6EG1VmWP9jGs :) )
# usage: link to slush_hashrate_YOURAPIKEY
import sys
import urllib2
import json
SLUSH_URL = 'https://mining.bitcoin.cz/accounts/profile/json/'
API_KEY = sys.argv[0][(sys.argv[0].rfind('_')+1):]
SLUSH_STATS = SLUSH_URL + API_KEY
mining_stats_raw = urllib2.urlopen(SLUSH_STATS)
mining_stats = json.load(mining_stats_raw)
workers = mining_stats['workers']
command = ''
if len(sys.argv) > 1:
command = sys.argv[1]
if command == 'config':
print "graph_title Slush Hashrate"
print "graph_args --upper-limit 3000 -l 0"
print "graph_vlabel MHash/s"
print "graph_category Bitcoin"
for worker in workers:
label = worker.replace(".","_")
print label + ".label " +label
sys.exit(0)
for worker in workers:
hash_rate = workers[worker]['hashrate']
label = worker.replace(".","_")
print label + ".value %d" % int(hash_rate)

View File

@ -0,0 +1,34 @@
#!/usr/bin/python
# based on https://github.com/pdbrown/munin-custom/blob/master/plugins/hashrate
# improved by @deveth0 (donation to 1GzHgp9hsDRsf96MnVk2oo6EG1VmWP9jGs :) )
# usage: link to slush_hashrate_YOURAPIKEY
import sys
import urllib2
import json
SLUSH_URL = 'https://mining.bitcoin.cz/accounts/profile/json/'
API_KEY = sys.argv[0][(sys.argv[0].rfind('_')+1):]
SLUSH_STATS = SLUSH_URL + API_KEY
mining_stats_raw = urllib2.urlopen(SLUSH_STATS)
mining_stats = json.load(mining_stats_raw)
command = ''
if len(sys.argv) > 1:
command = sys.argv[1]
if command == 'config':
print "graph_title Slush Rewards"
print "graph_args -l 0"
print "graph_vlabel BTC"
print "graph_category Bitcoin"
print "unconfirmed_reward.label Unconfirmed Reward"
print "estimated_reward.label Estimeated Reward"
print "confirmed_reward.label Confirmed Reward"
print "send_threshold.label Send Threshold"
sys.exit(0)
print "unconfirmed_reward.value " +mining_stats['unconfirmed_reward']
print "estimated_reward.value " +mining_stats['estimated_reward']
print "confirmed_reward.value " +mining_stats['confirmed_reward']
print "send_threshold.value " +mining_stats['send_threshold']