mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-25 18:38:30 +00:00
variable names
This commit is contained in:
parent
60c8aba7bc
commit
32c7266651
1 changed files with 11 additions and 13 deletions
|
@ -23,33 +23,31 @@ import urllib2
|
||||||
import socket
|
import socket
|
||||||
import json
|
import json
|
||||||
|
|
||||||
OPTIONS = sys.argv[0].split('_')
|
|
||||||
|
|
||||||
command = ''
|
command = ''
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
command = sys.argv[1]
|
command = sys.argv[1]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ETH_ADDRESS, MINER = sys.argv[0].split("_")[1:]
|
eth_address, miner = sys.argv[0].split("_")[1:]
|
||||||
except ValueError:
|
except ValueError:
|
||||||
print("The filename of this plugin (or its symlink) should follow this pattern: "
|
print("The filename of this plugin (or its symlink) should follow this pattern: "
|
||||||
"'<YOUR_PUBLIC_ETHEREUM_ADDRESS>_<YOUR_RIG_NAME>'", file=sys.stderr)
|
"'<YOUR_PUBLIC_ETHEREUM_ADDRESS>_<YOUR_RIG_NAME>'", file=sys.stderr)
|
||||||
sys.exit(0)
|
sys.exit(9)
|
||||||
|
|
||||||
if command == 'config':
|
if command == 'config':
|
||||||
print("graph_title Ethermine {}".format(ETH_ADDRESS))
|
print("graph_title Ethermine {}".format(eth_address))
|
||||||
print("graph_info Ethermine Hashrate {}/{}".format(ETH_ADDRESS, MINER))
|
print("graph_info Ethermine Hashrate {}/{}".format(eth_address, miner))
|
||||||
print("graph_vlabel Ethermine Hashrate")
|
print("graph_vlabel Ethermine Hashrate")
|
||||||
print("graph_category htc")
|
print("graph_category htc")
|
||||||
print("{}_{}.warning 20:".format(ETH_ADDRESS, MINER));
|
print("{}_{}.warning 20:".format(eth_address, miner));
|
||||||
print("{}_{}.critical 10:".format(ETH_ADDRESS, MINER));
|
print("{}_{}.critical 10:".format(eth_address, miner));
|
||||||
print("{}_{}.label MH/s:".format(ETH_ADDRESS, MINER));
|
print("{}_{}.label MH/s:".format(eth_address, miner));
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
ETHERMINE_API_URL = 'https://ethermine.org/api/miner_new/' + ETH_ADDRESS
|
ethermine_api_url = 'https://ethermine.org/api/miner_new/' + eth_address
|
||||||
|
|
||||||
mining_req = urllib2.Request(ETHERMINE_API_URL)
|
mining_req = urllib2.Request(ethermine_api_url)
|
||||||
mining_req.add_header('User-Agent', 'Mozilla/5.0')
|
mining_req.add_header('User-Agent', 'Mozilla/5.0')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -67,7 +65,7 @@ workers = mining_stats['workers']
|
||||||
|
|
||||||
# ethermine.org sometimes has caching errors. You can see data from other miner. Always check your rig name.
|
# ethermine.org sometimes has caching errors. You can see data from other miner. Always check your rig name.
|
||||||
for worker in workers:
|
for worker in workers:
|
||||||
if workers[worker]['worker'] == MINER:
|
if workers[worker]['worker'] == miner:
|
||||||
hash_rate = workers[worker]['hashrate']
|
hash_rate = workers[worker]['hashrate']
|
||||||
hash_rate = hash_rate.replace(" MH/s", "")
|
hash_rate = hash_rate.replace(" MH/s", "")
|
||||||
print("{}_{}.value %s".format(ETH_ADDRESS, MINER, hash_rate));
|
print("{}_{}.value %s".format(eth_address, miner, hash_rate));
|
Loading…
Add table
Add a link
Reference in a new issue