summaryrefslogtreecommitdiffstats
path: root/collectors/python.d.plugin/ipfs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2018-11-07 12:19:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2018-11-07 12:20:17 +0000
commita64a253794ac64cb40befee54db53bde17dd0d49 (patch)
treec1024acc5f6e508814b944d99f112259bb28b1be /collectors/python.d.plugin/ipfs
parentNew upstream version 1.10.0+dfsg (diff)
downloadnetdata-a64a253794ac64cb40befee54db53bde17dd0d49.tar.xz
netdata-a64a253794ac64cb40befee54db53bde17dd0d49.zip
New upstream version 1.11.0+dfsgupstream/1.11.0+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--collectors/python.d.plugin/ipfs/Makefile.inc13
-rw-r--r--collectors/python.d.plugin/ipfs/README.md25
-rw-r--r--collectors/python.d.plugin/ipfs/ipfs.chart.py (renamed from python.d/ipfs.chart.py)60
-rw-r--r--collectors/python.d.plugin/ipfs/ipfs.conf (renamed from conf.d/python.d/ipfs.conf)9
4 files changed, 83 insertions, 24 deletions
diff --git a/collectors/python.d.plugin/ipfs/Makefile.inc b/collectors/python.d.plugin/ipfs/Makefile.inc
new file mode 100644
index 000000000..68458cb38
--- /dev/null
+++ b/collectors/python.d.plugin/ipfs/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 += ipfs/ipfs.chart.py
+dist_pythonconfig_DATA += ipfs/ipfs.conf
+
+# do not install these files, but include them in the distribution
+dist_noinst_DATA += ipfs/README.md ipfs/Makefile.inc
+
diff --git a/collectors/python.d.plugin/ipfs/README.md b/collectors/python.d.plugin/ipfs/README.md
new file mode 100644
index 000000000..a30649a5f
--- /dev/null
+++ b/collectors/python.d.plugin/ipfs/README.md
@@ -0,0 +1,25 @@
+# ipfs
+
+Module monitors [IPFS](https://ipfs.io) basic information.
+
+1. **Bandwidth** in kbits/s
+ * in
+ * out
+
+2. **Peers**
+ * peers
+
+### configuration
+
+Only url to IPFS server is needed.
+
+Sample:
+
+```yaml
+localhost:
+ name : 'local'
+ url : 'http://localhost:5001'
+```
+
+---
+
diff --git a/python.d/ipfs.chart.py b/collectors/python.d.plugin/ipfs/ipfs.chart.py
index 43500dfb5..3f6794e48 100644
--- a/python.d/ipfs.chart.py
+++ b/collectors/python.d.plugin/ipfs/ipfs.chart.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
# Description: IPFS netdata python.d module
-# Authors: Pawel Krupa (paulfantom), davidak
+# Authors: davidak
+# SPDX-License-Identifier: GPL-3.0-or-later
import json
@@ -26,31 +27,43 @@ CHARTS = {
'bandwidth': {
'options': [None, 'IPFS Bandwidth', 'kbits/s', 'Bandwidth', 'ipfs.bandwidth', 'line'],
'lines': [
- ["in", None, "absolute", 8, 1000],
- ["out", None, "absolute", -8, 1000]
- ]},
+ ['in', None, 'absolute', 8, 1000],
+ ['out', None, 'absolute', -8, 1000]
+ ]
+ },
'peers': {
'options': [None, 'IPFS Peers', 'peers', 'Peers', 'ipfs.peers', 'line'],
'lines': [
- ["peers", None, 'absolute']
- ]},
+ ['peers', None, 'absolute']
+ ]
+ },
'repo_size': {
'options': [None, 'IPFS Repo Size', 'GB', 'Size', 'ipfs.repo_size', 'area'],
'lines': [
- ["avail", None, "absolute", 1, 1e9],
- ["size", None, "absolute", 1, 1e9],
- ]},
+ ['avail', None, 'absolute', 1, 1e9],
+ ['size', None, 'absolute', 1, 1e9],
+ ]
+ },
'repo_objects': {
'options': [None, 'IPFS Repo Objects', 'objects', 'Objects', 'ipfs.repo_objects', 'line'],
'lines': [
- ["objects", None, "absolute", 1, 1],
- ["pinned", None, "absolute", 1, 1],
- ["recursive_pins", None, "absolute", 1, 1]
- ]},
+ ['objects', None, 'absolute', 1, 1],
+ ['pinned', None, 'absolute', 1, 1],
+ ['recursive_pins', None, 'absolute', 1, 1]
+ ]
+ }
}
-SI_zeroes = {'k': 3, 'm': 6, 'g': 9, 't': 12,
- 'p': 15, 'e': 18, 'z': 21, 'y': 24}
+SI_zeroes = {
+ 'k': 3,
+ 'm': 6,
+ 'g': 9,
+ 't': 12,
+ 'p': 15,
+ 'e': 18,
+ 'z': 21,
+ 'y': 24
+}
class Service(UrlService):
@@ -60,6 +73,7 @@ class Service(UrlService):
self.order = ORDER
self.definitions = CHARTS
self.__storage_max = None
+ self.do_pinapi = self.configuration.get('pinapi')
def _get_json(self, sub_url):
"""
@@ -73,7 +87,7 @@ class Service(UrlService):
@staticmethod
def _recursive_pins(keys):
- return len([k for k in keys if keys[k]["Type"] == b"recursive"])
+ return sum(1 for k in keys if keys[k]['Type'] == b'recursive')
@staticmethod
def _dehumanize(store_max):
@@ -93,7 +107,7 @@ class Service(UrlService):
def _storagemax(self, store_cfg):
if self.__storage_max is None:
- self.__storage_max = self._dehumanize(store_cfg['StorageMax'])
+ self.__storage_max = self._dehumanize(store_cfg)
return self.__storage_max
def _get_data(self):
@@ -106,13 +120,15 @@ class Service(UrlService):
'/api/v0/stats/bw':
[('in', 'RateIn', int), ('out', 'RateOut', int)],
'/api/v0/swarm/peers':
- [('peers', 'Strings', len)],
+ [('peers', 'Peers', len)],
'/api/v0/stats/repo':
- [('size', 'RepoSize', int), ('objects', 'NumObjects', int)],
- '/api/v0/pin/ls':
- [('pinned', 'Keys', len), ('recursive_pins', 'Keys', self._recursive_pins)],
- '/api/v0/config/show': [('avail', 'Datastore', self._storagemax)]
+ [('size', 'RepoSize', int), ('objects', 'NumObjects', int), ('avail', 'StorageMax', self._storagemax)],
}
+ if self.do_pinapi:
+ cfg.update({
+ '/api/v0/pin/ls':
+ [('pinned', 'Keys', len), ('recursive_pins', 'Keys', self._recursive_pins)]
+ })
r = dict()
for suburl in cfg:
in_json = self._get_json(suburl)
diff --git a/conf.d/python.d/ipfs.conf b/collectors/python.d.plugin/ipfs/ipfs.conf
index c247c1b7a..e3df0f6bb 100644
--- a/conf.d/python.d/ipfs.conf
+++ b/collectors/python.d.plugin/ipfs/ipfs.conf
@@ -64,11 +64,16 @@
# Additionally to the above, ipfs also supports the following:
#
# url: 'URL' # URL to the IPFS API
+# pinapi: no # Set status of IPFS pinned object polling
+# # Currently defaults to disabled due to IPFS Bug
+# # https://github.com/ipfs/go-ipfs/issues/3874
+# # resulting in very high CPU Usage
#
# ----------------------------------------------------------------------
# AUTO-DETECTION JOBS
# only one of them will run (they have the same name)
localhost:
- name : 'local'
- url : 'http://localhost:5001'
+ name : 'local'
+ url : 'http://localhost:5001'
+ pinapi : no