mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-08-04 07:04:02 +00:00
rename
This commit is contained in:
parent
32c7266651
commit
497e66ddcb
2 changed files with 8 additions and 7 deletions
71
plugins/ethereum/ethermine_hashrate_
Executable file
71
plugins/ethereum/ethermine_hashrate_
Executable file
|
@ -0,0 +1,71 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#
|
||||
# ethermine_hashrate_
|
||||
#
|
||||
# Munin plugin to monitor your ethermine.org hashrate.
|
||||
#
|
||||
# Author: Nils Knieling - https://github.com/Cyclenerd
|
||||
# Licence: GPLv2
|
||||
#
|
||||
# USAGE
|
||||
# ethermine_hashrate_<YOUR_PUBLIC_ETHEREUM_ADDRESS>_<YOUR_RIG_NAME>
|
||||
#
|
||||
# EXAMPLE
|
||||
# ln -s /usr/share/munin/plugins/ethermine_hashrate_ /etc/munin/plugins/ethermine_hashrate_3257bde8cf067ae6f1ddc0e4b140fe02e3c5e44f_mine
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import sys
|
||||
import urllib2
|
||||
import socket
|
||||
import json
|
||||
|
||||
command = ''
|
||||
if len(sys.argv) > 1:
|
||||
command = sys.argv[1]
|
||||
|
||||
try:
|
||||
eth_address, miner = sys.argv[0].split("_")[1:]
|
||||
except ValueError:
|
||||
print("The filename of this plugin (or its symlink) should follow this pattern: "
|
||||
"'ethermine_hashrate_<YOUR_PUBLIC_ETHEREUM_ADDRESS>_<YOUR_RIG_NAME>'", file=sys.stderr)
|
||||
sys.exit(9)
|
||||
|
||||
if command == 'config':
|
||||
print("graph_title Ethermine {}".format(eth_address))
|
||||
print("graph_info Ethermine Hashrate {}/{}".format(eth_address, miner))
|
||||
print("graph_vlabel Ethermine Hashrate")
|
||||
print("graph_category htc")
|
||||
print("{}_{}.warning 20:".format(eth_address, miner));
|
||||
print("{}_{}.critical 10:".format(eth_address, miner));
|
||||
print("{}_{}.label MH/s:".format(eth_address, miner));
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
ethermine_api_url = 'https://ethermine.org/api/miner_new/' + eth_address
|
||||
|
||||
mining_req = urllib2.Request(ethermine_api_url)
|
||||
mining_req.add_header('User-Agent', 'Mozilla/5.0')
|
||||
|
||||
try:
|
||||
mining_stats_raw = urllib2.urlopen(mining_req, timeout=1.5 )
|
||||
except IOError as exc:
|
||||
print("Failed to request ethermine.org API: {}".format(exc), file=sys.stderr)
|
||||
|
||||
try:
|
||||
mining_stats = json.load(mining_stats_raw)
|
||||
except ValueError:
|
||||
print("Failed to parse JSON responce.", file=sys.stderr);
|
||||
sys.exit(9)
|
||||
|
||||
workers = mining_stats['workers']
|
||||
|
||||
# ethermine.org sometimes has caching errors. You can see data from other miner. Always check your rig name.
|
||||
for worker in workers:
|
||||
if workers[worker]['worker'] == miner:
|
||||
hash_rate = workers[worker]['hashrate']
|
||||
hash_rate = hash_rate.replace(" MH/s", "")
|
||||
print("{}_{}.value %s".format(eth_address, miner, hash_rate));
|
Loading…
Add table
Add a link
Reference in a new issue