Skip to content

Commit

Permalink
Add RPC info
Browse files Browse the repository at this point in the history
  • Loading branch information
EchterAgo committed Mar 1, 2021
1 parent 6e69c9a commit cc2a804
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions bitcoind-monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@
"bitcoin_verification_progress", "Estimate of verification progress [0..1]"
)

BITCOIN_RPC_ACTIVE = Gauge("bitcoin_rpc_active", "Number of RPC calls being processed")

EXPORTER_ERRORS = Counter(
"bitcoin_exporter_errors", "Number of errors encountered by the exporter", labelnames=["type"]
)
Expand Down Expand Up @@ -209,6 +211,7 @@ def refresh_metrics() -> None:
chaintips = len(bitcoinrpc("getchaintips"))
mempool = bitcoinrpc("getmempoolinfo")
nettotals = bitcoinrpc("getnettotals")
rpcinfo = bitcoinrpc("getrpcinfo")
latest_block = get_block(str(blockchaininfo["bestblockhash"]))
hashps_120 = float(bitcoinrpc("getnetworkhashps", 120)) # 120 is the default
hashps_neg1 = float(bitcoinrpc("getnetworkhashps", -1))
Expand Down Expand Up @@ -273,6 +276,9 @@ def refresh_metrics() -> None:
BITCOIN_LATEST_BLOCK_OUTPUTS.set(outputs)
BITCOIN_LATEST_BLOCK_VALUE.set(value)

# Subtract one because we don't want to count the "getrpcinfo" call itself
BITCOIN_RPC_ACTIVE.set(len(rpcinfo["active_commands"]) - 1)


def sigterm_handler(signal, frame) -> None:
logger.critical("Received SIGTERM. Exiting.")
Expand Down

0 comments on commit cc2a804

Please sign in to comment.