summaryrefslogtreecommitdiffstats
path: root/collectors/python.d.plugin/ipfs/ipfs.chart.py
diff options
context:
space:
mode:
Diffstat (limited to 'collectors/python.d.plugin/ipfs/ipfs.chart.py')
-rw-r--r--collectors/python.d.plugin/ipfs/ipfs.chart.py37
1 files changed, 27 insertions, 10 deletions
diff --git a/collectors/python.d.plugin/ipfs/ipfs.chart.py b/collectors/python.d.plugin/ipfs/ipfs.chart.py
index 8c89b4be1..abfc9c492 100644
--- a/collectors/python.d.plugin/ipfs/ipfs.chart.py
+++ b/collectors/python.d.plugin/ipfs/ipfs.chart.py
@@ -7,7 +7,6 @@ import json
from bases.FrameworkServices.UrlService import UrlService
-
ORDER = [
'bandwidth',
'peers',
@@ -64,7 +63,9 @@ class Service(UrlService):
self.order = ORDER
self.definitions = CHARTS
self.baseurl = self.configuration.get('url', 'http://localhost:5001')
+ self.method = "POST"
self.do_pinapi = self.configuration.get('pinapi')
+ self.do_repoapi = self.configuration.get('repoapi')
self.__storage_max = None
def _get_json(self, sub_url):
@@ -89,7 +90,7 @@ class Service(UrlService):
if store_max.endswith('b'):
val, units = store_max[:-2], store_max[-2]
if units in SI_zeroes:
- val += '0'*SI_zeroes[units]
+ val += '0' * SI_zeroes[units]
store_max = val
try:
store_max = int(store_max)
@@ -110,17 +111,33 @@ class Service(UrlService):
# suburl : List of (result-key, original-key, transform-func)
cfg = {
'/api/v0/stats/bw':
- [('in', 'RateIn', int), ('out', 'RateOut', int)],
+ [
+ ('in', 'RateIn', int),
+ ('out', 'RateOut', int),
+ ],
'/api/v0/swarm/peers':
- [('peers', 'Peers', len)],
- '/api/v0/stats/repo':
- [('size', 'RepoSize', int), ('objects', 'NumObjects', int), ('avail', 'StorageMax', self._storagemax)],
+ [
+ ('peers', 'Peers', len),
+ ],
}
+ if self.do_repoapi:
+ cfg.update({
+ '/api/v0/stats/repo':
+ [
+ ('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)]
- })
+ 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)