1 # -*- coding: utf-8 -*-
2 # Description: RetroShare netdata python.d module
5 from base import UrlService
8 # default module values (can be overridden per job in `config`)
13 # charts order (can be overridden if you want less charts, or different order)
14 ORDER = ['bandwidth', 'peers', 'dht']
18 'options': [None, 'RetroShare Bandwidth', 'kB/s', 'RetroShare', 'retroshare.bandwidth', 'area'],
20 ['bandwidth_up_kb', 'Upload'],
21 ['bandwidth_down_kb', 'Download']
24 'options': [None, 'RetroShare Peers', 'peers', 'RetroShare', 'retroshare.peers', 'line'],
26 ['peers_all', 'All friends'],
27 ['peers_connected', 'Connected friends']
30 'options': [None, 'Retroshare DHT', 'peers', 'RetroShare', 'retroshare.dht', 'line'],
32 ['dht_size_all', 'DHT nodes estimated'],
33 ['dht_size_rs', 'RS nodes estimated']
38 class Service(UrlService):
39 def __init__(self, configuration=None, name=None):
40 UrlService.__init__(self, configuration=configuration, name=name)
42 self.baseurl = str(self.configuration['url'])
43 except (KeyError, TypeError):
44 self.baseurl = 'http://localhost:9090'
46 self.definitions = CHARTS
50 Format data received from http request
54 raw = self._get_raw_data()
55 parsed = json.loads(raw)
56 if str(parsed['returncode']) != 'ok':
61 return parsed['data'][0]
68 self.url = self.baseurl + '/api/v2/stats'
69 data = self._get_stats()
73 data['bandwidth_up_kb'] = data['bandwidth_up_kb'] * -1
74 if data['dht_active'] is False:
75 data['dht_size_all'] = None
76 data['dht_size_rs'] = None