mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
bitcoind_: update for Bitcoin Core v0.19.0 release
* Use new RPC calls to get relevant statistics, as some calls are either deprecated or completely removed. * Fix response printing when MUNIN_DEBUG is set. * Remove "fees" graph as there is no sane way to implement that. * Add missing success return.
This commit is contained in:
parent
642b48a4f7
commit
15f1055e2c
1 changed files with 25 additions and 10 deletions
|
@ -69,7 +69,6 @@ def main():
|
|||
command = sys.argv[1] if len(sys.argv) > 1 else None
|
||||
request_labels = {'balance': ('Wallet Balance', 'BTC'),
|
||||
'connections': ('Peer Connections', 'Connections'),
|
||||
'fees': ("Tip Offered", "BTC"),
|
||||
'transactions': ("Transactions", "Transactions",
|
||||
('confirmed', 'waiting')),
|
||||
'block_age': ("Last Block Age", "Seconds"),
|
||||
|
@ -120,8 +119,9 @@ def main():
|
|||
bitcoin_options.rpcport),
|
||||
username=bitcoin_options.rpcuser,
|
||||
password=bitcoin_options.rpcpassword)
|
||||
(info, connect_error) = bitcoin.getinfo()
|
||||
error = "Could not connect to Bitcoin server: {}".format(connect_error)
|
||||
(info, connect_error) = bitcoin.getnetworkinfo()
|
||||
if connect_error:
|
||||
error = "Could not connect to Bitcoin server: {}".format(connect_error)
|
||||
|
||||
if command == 'autoconf':
|
||||
if error:
|
||||
|
@ -134,20 +134,35 @@ def main():
|
|||
print(error, file=sys.stderr)
|
||||
return False
|
||||
|
||||
if request_var == 'balance':
|
||||
# we use getbalance*s* (plural) as old getbalance is being deprecated,
|
||||
# and we have to calculate total balance (owned and watch-only) manually now.
|
||||
(info, error) = bitcoin.getbalances()
|
||||
|
||||
total = sum(info[wallet_mode]['trusted']
|
||||
for wallet_mode in ('mine', 'watchonly')
|
||||
if wallet_mode in info)
|
||||
|
||||
info['balance'] = total
|
||||
|
||||
if request_var in ('transactions', 'block_age'):
|
||||
(info, error) = bitcoin.getblockhash(info['blocks'])
|
||||
(info, error) = bitcoin.getblock(info)
|
||||
(info, error) = bitcoin.getblockchaininfo()
|
||||
(info, error) = bitcoin.getblock(info['bestblockhash'])
|
||||
info['block_age'] = int(time.time()) - info['time']
|
||||
info['confirmed'] = len(info['tx'])
|
||||
|
||||
if request_var in ('fees', 'transactions'):
|
||||
(memory_pool, error) = bitcoin.getrawmempool()
|
||||
if memory_pool:
|
||||
info['waiting'] = len(memory_pool)
|
||||
if request_var == 'difficulty':
|
||||
(info, error) = bitcoin.getblockchaininfo()
|
||||
|
||||
if request_var == 'transactions':
|
||||
(memory_pool, error) = bitcoin.getmempoolinfo()
|
||||
info['waiting'] = memory_pool['size']
|
||||
|
||||
for label in line_labels:
|
||||
print("%s.value %s" % (label, info[label]))
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def parse_conf(filename):
|
||||
""" Bitcoin config file parser. """
|
||||
|
@ -249,7 +264,7 @@ class Proxy:
|
|||
return (None, e)
|
||||
|
||||
if DEBUG:
|
||||
print('RPC Response (%s): %s' % (self.method, json.dumps(body, indent=4)))
|
||||
print('RPC Response (%s): %s' % (self.method, json.dumps(json.loads(body), indent=4)))
|
||||
|
||||
try:
|
||||
data = json.loads(body)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue