summaryrefslogtreecommitdiffstats
path: root/collectors/python.d.plugin/energid
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 11:08:07 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 11:08:07 +0000
commitc69cb8cc094cc916adbc516b09e944cd3d137c01 (patch)
treef2878ec41fb6d0e3613906c6722fc02b934eeb80 /collectors/python.d.plugin/energid
parentInitial commit. (diff)
downloadnetdata-c69cb8cc094cc916adbc516b09e944cd3d137c01.tar.xz
netdata-c69cb8cc094cc916adbc516b09e944cd3d137c01.zip
Adding upstream version 1.29.3.upstream/1.29.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--collectors/python.d.plugin/energid/Makefile.inc13
-rw-r--r--collectors/python.d.plugin/energid/README.md77
-rw-r--r--collectors/python.d.plugin/energid/energid.chart.py163
-rw-r--r--collectors/python.d.plugin/energid/energid.conf90
4 files changed, 343 insertions, 0 deletions
diff --git a/collectors/python.d.plugin/energid/Makefile.inc b/collectors/python.d.plugin/energid/Makefile.inc
new file mode 100644
index 0000000..44a209d
--- /dev/null
+++ b/collectors/python.d.plugin/energid/Makefile.inc
@@ -0,0 +1,13 @@
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+# THIS IS NOT A COMPLETE Makefile
+# IT IS INCLUDED BY ITS PARENT'S Makefile.am
+# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT
+
+# install these files
+dist_python_DATA += energid/energid.chart.py
+dist_pythonconfig_DATA += energid/energid.conf
+
+# do not install these files, but include them in the distribution
+dist_noinst_DATA += energid/README.md energid/Makefile.inc
+
diff --git a/collectors/python.d.plugin/energid/README.md b/collectors/python.d.plugin/energid/README.md
new file mode 100644
index 0000000..60c829f
--- /dev/null
+++ b/collectors/python.d.plugin/energid/README.md
@@ -0,0 +1,77 @@
+<!--
+title: "Energi Core node monitoring with Netdata"
+custom_edit_url: https://github.com/netdata/netdata/edit/master/collectors/python.d.plugin/energid/README.md
+sidebar_label: "Energi Core"
+-->
+
+# Energi Core node monitoring with Netdata
+
+Monitors blockchain, memory, network and unspent transactions statistics.
+
+
+As [Energi Core](https://github.com/energicryptocurrency/energi) Gen 1 & 2 are based on the original Bitcoin code and
+supports very similar JSON RPC, there is quite high chance the module works
+with many others forks including bitcoind itself.
+
+Introduces several new charts:
+
+1. **Blockchain Index**
+ - blocks
+ - headers
+
+2. **Blockchain Difficulty**
+ - diff
+
+3. **MemPool** in MiB
+ - Max
+ - Usage
+ - TX Size
+
+4. **Secure Memory** in KiB
+ - Total
+ - Locked
+ - Used
+
+5. **Network**
+ - Connections
+
+6. **UTXO** (Unspent Transaction Output)
+ - UTXO
+ - Xfers (related transactions)
+
+Configuration is needed in most cases of secure deployment to specify RPC
+credentials. However, Energi, Bitcoin and Dash daemons are checked on
+startup by default.
+
+It may be desired to increase retry count for production use due to possibly
+long daemon startup.
+
+## Configuration
+
+Edit the `python.d/energid.conf` configuration file using `edit-config` from the Netdata [config
+directory](/docs/configure/nodes.md), which is typically at `/etc/netdata`.
+
+```bash
+cd /etc/netdata # Replace this path with your Netdata config directory, if different
+sudo ./edit-config python.d/energid.conf
+```
+
+Sample:
+
+```yaml
+energi:
+ host: '127.0.0.1'
+ port: 9796
+ user: energi
+ pass: energi
+
+bitcoin:
+ host: '127.0.0.1'
+ port: 8332
+ user: bitcoin
+ pass: bitcoin
+```
+
+---
+
+[![analytics](https://www.google-analytics.com/collect?v=1&aip=1&t=pageview&_s=1&ds=github&dr=https%3A%2F%2Fgithub.com%2Fnetdata%2Fnetdata&dl=https%3A%2F%2Fmy-netdata.io%2Fgithub%2Fcollectors%2Fpython.d.plugin%2Fenergid%2FREADME&_u=MAC~&cid=5792dfd7-8dc4-476b-af31-da2fdb9f93d2&tid=UA-64295674-3)](<>)
diff --git a/collectors/python.d.plugin/energid/energid.chart.py b/collectors/python.d.plugin/energid/energid.chart.py
new file mode 100644
index 0000000..079c32d
--- /dev/null
+++ b/collectors/python.d.plugin/energid/energid.chart.py
@@ -0,0 +1,163 @@
+# -*- coding: utf-8 -*-
+# Description: Energi Core / Bitcoin netdata python.d module
+# Author: Andrey Galkin <andrey@futoin.org> (andvgal)
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# This module is designed for energid, but it should work with many other Bitcoin forks
+# which support more or less standard JSON-RPC.
+#
+
+import json
+
+from bases.FrameworkServices.UrlService import UrlService
+
+update_every = 5
+
+ORDER = [
+ 'blockindex',
+ 'difficulty',
+ 'mempool',
+ 'secmem',
+ 'network',
+ 'timeoffset',
+ 'utxo',
+ 'xfers',
+]
+
+CHARTS = {
+ 'blockindex': {
+ 'options': [None, 'Blockchain Index', 'count', 'blockchain', 'energi.blockindex', 'area'],
+ 'lines': [
+ ['blockchain_blocks', 'blocks', 'absolute'],
+ ['blockchain_headers', 'headers', 'absolute'],
+ ]
+ },
+ 'difficulty': {
+ 'options': [None, 'Blockchain Difficulty', 'difficulty', 'blockchain', 'energi.difficulty', 'line'],
+ 'lines': [
+ ['blockchain_difficulty', 'Diff', 'absolute'],
+ ],
+ },
+ 'mempool': {
+ 'options': [None, 'MemPool', 'MiB', 'memory', 'energid.mempool', 'area'],
+ 'lines': [
+ ['mempool_max', 'Max', 'absolute', None, 1024 * 1024],
+ ['mempool_current', 'Usage', 'absolute', None, 1024 * 1024],
+ ['mempool_txsize', 'TX Size', 'absolute', None, 1024 * 1024],
+ ],
+ },
+ 'secmem': {
+ 'options': [None, 'Secure Memory', 'KiB', 'memory', 'energid.secmem', 'area'],
+ 'lines': [
+ ['secmem_total', 'Total', 'absolute', None, 1024],
+ ['secmem_locked', 'Locked', 'absolute', None, 1024],
+ ['secmem_used', 'Used', 'absolute', None, 1024],
+ ],
+ },
+ 'network': {
+ 'options': [None, 'Network', 'count', 'network', 'energid.network', 'line'],
+ 'lines': [
+ ['network_connections', 'Connections', 'absolute'],
+ ],
+ },
+ 'timeoffset': {
+ 'options': [None, 'Network', 'seconds', 'network', 'energid.timeoffset', 'line'],
+ 'lines': [
+ ['network_timeoffset', 'offseet', 'absolute'],
+ ],
+ },
+ 'utxo': {
+ 'options': [None, 'UTXO', 'count', 'UTXO', 'energid.utxo', 'line'],
+ 'lines': [
+ ['utxo_count', 'UTXO', 'absolute'],
+ ],
+ },
+ 'xfers': {
+ 'options': [None, 'UTXO', 'count', 'UTXO', 'energid.xfers', 'line'],
+ 'lines': [
+ ['utxo_xfers', 'Xfers', 'absolute'],
+ ],
+ },
+}
+
+METHODS = {
+ 'getblockchaininfo': lambda r: {
+ 'blockchain_blocks': r['blocks'],
+ 'blockchain_headers': r['headers'],
+ 'blockchain_difficulty': r['difficulty'],
+ },
+ 'getmempoolinfo': lambda r: {
+ 'mempool_txcount': r['size'],
+ 'mempool_txsize': r['bytes'],
+ 'mempool_current': r['usage'],
+ 'mempool_max': r['maxmempool'],
+ },
+ 'getmemoryinfo': lambda r: dict([
+ ('secmem_' + k, v) for (k, v) in r['locked'].items()
+ ]),
+ 'getnetworkinfo': lambda r: {
+ 'network_timeoffset': r['timeoffset'],
+ 'network_connections': r['connections'],
+ },
+ 'gettxoutsetinfo': lambda r: {
+ 'utxo_count': r['txouts'],
+ 'utxo_xfers': r['transactions'],
+ 'utxo_size': r['disk_size'],
+ 'utxo_amount': r['total_amount'],
+ },
+}
+
+JSON_RPC_VERSION = '1.1'
+
+
+class Service(UrlService):
+ def __init__(self, configuration=None, name=None):
+ UrlService.__init__(self, configuration=configuration, name=name)
+ self.order = ORDER
+ self.definitions = CHARTS
+ self.host = self.configuration.get('host', '127.0.0.1')
+ self.port = self.configuration.get('port', 9796)
+ self.url = '{scheme}://{host}:{port}'.format(
+ scheme=self.configuration.get('scheme', 'http'),
+ host=self.host,
+ port=self.port,
+ )
+ self.method = 'POST'
+ self.header = {
+ 'Content-Type': 'application/json',
+ }
+
+ def _get_data(self):
+ #
+ # Bitcoin family speak JSON-RPC version 1.0 for maximum compatibility,
+ # but uses JSON-RPC 1.1/2.0 standards for parts of the 1.0 standard that were
+ # unspecified (HTTP errors and contents of 'error').
+ #
+ # 1.0 spec: https://www.jsonrpc.org/specification_v1
+ # 2.0 spec: https://www.jsonrpc.org/specification
+ #
+ # The call documentation: https://github.com/energicryptocurrency/core-api-documentation
+ #
+ batch = []
+
+ for i, method in enumerate(METHODS):
+ batch.append({
+ 'version': JSON_RPC_VERSION,
+ 'id': i,
+ 'method': method,
+ 'params': [],
+ })
+
+ result = self._get_raw_data(body=json.dumps(batch))
+
+ if not result:
+ return None
+
+ result = json.loads(result.decode('utf-8'))
+ data = dict()
+
+ for i, (_, handler) in enumerate(METHODS.items()):
+ r = result[i]
+ data.update(handler(r['result']))
+
+ return data
diff --git a/collectors/python.d.plugin/energid/energid.conf b/collectors/python.d.plugin/energid/energid.conf
new file mode 100644
index 0000000..3b13841
--- /dev/null
+++ b/collectors/python.d.plugin/energid/energid.conf
@@ -0,0 +1,90 @@
+# netdata python.d.plugin configuration for energid
+#
+# This file is in YaML format. Generally the format is:
+#
+# name: value
+#
+# There are 2 sections:
+# - global variables
+# - one or more JOBS
+#
+# JOBS allow you to collect values from multiple sources.
+# Each source will have its own set of charts.
+#
+# JOB parameters have to be indented (using spaces only, example below).
+
+# ----------------------------------------------------------------------
+# Global Variables
+# These variables set the defaults for all JOBs, however each JOB
+# may define its own, overriding the defaults.
+
+# update_every sets the default data collection frequency.
+# If unset, the python.d.plugin default is used.
+# update_every: 1
+
+# priority controls the order of charts at the netdata dashboard.
+# Lower numbers move the charts towards the top of the page.
+# If unset, the default for python.d.plugin is used.
+# priority: 60000
+
+# penalty indicates whether to apply penalty to update_every in case of failures.
+# Penalty will increase every 5 failed updates in a row. Maximum penalty is 10 minutes.
+# penalty: yes
+
+# autodetection_retry sets the job re-check interval in seconds.
+# The job is not deleted if check fails.
+# Attempts to start the job are made once every autodetection_retry.
+# This feature is disabled by default.
+# autodetection_retry: 0
+
+# ----------------------------------------------------------------------
+# JOBS (data collection sources)
+#
+# The default JOBS share the same *name*. JOBS with the same name
+# are mutually exclusive. Only one of them will be allowed running at
+# any time. This allows autodetection to try several alternatives and
+# pick the one that works.
+#
+# Any number of jobs is supported.
+#
+# All python.d.plugin JOBS (for all its modules) support a set of
+# predefined parameters. These are:
+#
+# job_name:
+# name: myname # the JOB's name as it will appear at the
+# # dashboard (by default is the job_name)
+# # JOBs sharing a name are mutually exclusive
+# update_every: 1 # the JOB's data collection frequency
+# priority: 60000 # the JOB's order on the dashboard
+# penalty: yes # the JOB's penalty
+# autodetection_retry: 0 # the JOB's re-check interval in seconds
+#
+# Additionally to the above, energid also supports the following:
+#
+# host: 'IP or HOSTNAME' # type <str> the RPC host to connect to
+# port: PORT # type <int> the RPC port to connect to
+# user: 'RPC username' # type <str> the RPC username to use
+# pass: 'RPC password' # type <str> the RPC password to use
+#
+# ----------------------------------------------------------------------
+# AUTO-DETECTION JOBS
+# only one of them will run (they have the same name)
+#
+
+# Defaults:
+# host: '127.0.0.1'
+# user:
+# pass:
+#
+
+# Energi mainnet
+energi:
+ port: 9796
+
+# Most likely supported Bitcoin mainnet
+bitcoin:
+ port: 8332
+
+# Most likely supported Dash mainnet
+dash:
+ port: 9998