diff options
author | Austin S. Hemmelgarn <ahferroin7@gmail.com> | 2018-09-27 08:56:26 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-27 08:56:26 -0400 |
commit | beefe4e223c6a63653cc76410d5fcf7d59115708 (patch) | |
tree | e66984c324c50a21d902df0a5731edcf47544437 | |
parent | 3938fa3065830d79705d08856f1ab4f8c0431cf8 (diff) |
Python.d PEP 8 cleanup, modules S-Z (#4302)
* python.d/samba.chart.py PEP 8 cleanup
Fix formatting of container literals.
* python.d/sensors.chart.py PEP 8 cleanup
Fix formatting of container literals and quoting of string literals.
* python.d/smartd_log.chart.py PEP 8 cleanup
Fix formatting of container literals.
* python.d/spigotmc.chart.py PEP 8 cleanup
Fix spacing of code blocks.
* python.d/springboot.chart.py PEP 8 cleanup
Bunches of formatting fixes, plus some code correctness fixes.
* python.d/squid.chart.py PEP 8 cleanup
Fix formatting of container literals and quoting of string literals.
* python.d/tomcat.chart.py PEP 8 cleanup
Multiple formatting fixes.
* python.d/traefik.chart.py PEP 8 cleanup
Fixed long lines and formatting of container literals.
* python.d/unbound.chart.py PEP 8 cleanup
Fixed overly long lines.
* python.d/varnish.chart.py PEP 8 cleanup
Fixed formatting of container literals.
* python.d/w1sensor.chart.py PEP 8 cleanup
Fixed container literal formatting.
* python.d/web_log.chart.py PEP 8 cleanup
Multiple formatting fixes.
* Fixed trailing whitespace.
-rw-r--r-- | python.d/samba.chart.py | 126 | ||||
-rw-r--r-- | python.d/sensors.chart.py | 28 | ||||
-rw-r--r-- | python.d/smartd_log.chart.py | 2 | ||||
-rw-r--r-- | python.d/spigotmc.chart.py | 1 | ||||
-rw-r--r-- | python.d/springboot.chart.py | 95 | ||||
-rw-r--r-- | python.d/squid.chart.py | 74 | ||||
-rw-r--r-- | python.d/tomcat.chart.py | 96 | ||||
-rw-r--r-- | python.d/traefik.chart.py | 39 | ||||
-rw-r--r-- | python.d/unbound.chart.py | 6 | ||||
-rw-r--r-- | python.d/varnish.chart.py | 23 | ||||
-rw-r--r-- | python.d/w1sensor.chart.py | 17 | ||||
-rw-r--r-- | python.d/web_log.chart.py | 322 |
12 files changed, 494 insertions, 335 deletions
diff --git a/python.d/samba.chart.py b/python.d/samba.chart.py index 2bc7e49b4b..59f59a8d08 100644 --- a/python.d/samba.chart.py +++ b/python.d/samba.chart.py @@ -26,67 +26,75 @@ update_every = 5 priority = 60000 retries = 60 -ORDER = ['syscall_rw','smb2_rw','smb2_create_close','smb2_info','smb2_find','smb2_notify','smb2_sm_count'] +ORDER = [ + 'syscall_rw', + 'smb2_rw', + 'smb2_create_close', + 'smb2_info', + 'smb2_find', + 'smb2_notify', + 'smb2_sm_count' +] CHARTS = { - 'syscall_rw': { - 'lines': [ - ['syscall_sendfile_bytes', 'sendfile', 'incremental', 1, 1024], - ['syscall_recvfile_bytes', 'recvfile', 'incremental', -1, 1024] - ], - 'options': [None, 'R/Ws', 'kilobytes/s', 'syscall', 'syscall.rw', 'area'] - }, - 'smb2_rw': { - 'lines': [ - ['smb2_read_outbytes', 'readout', 'incremental', 1, 1024], - ['smb2_write_inbytes', 'writein', 'incremental', -1, 1024], - ['smb2_read_inbytes', 'readin', 'incremental', 1, 1024], - ['smb2_write_outbytes', 'writeout', 'incremental', -1, 1024] - ], - 'options': [None, 'R/Ws', 'kilobytes/s', 'smb2', 'smb2.rw', 'area'] - }, - 'smb2_create_close': { - 'lines': [ - ['smb2_create_count', 'create', 'incremental', 1, 1], - ['smb2_close_count', 'close', 'incremental', -1, 1] - ], - 'options': [None, 'Create/Close', 'operations/s', 'smb2', 'smb2.create_close', 'line'] - }, - 'smb2_info': { - 'lines': [ - ['smb2_getinfo_count', 'getinfo', 'incremental', 1, 1], - ['smb2_setinfo_count', 'setinfo', 'incremental', -1, 1] - ], - 'options': [None, 'Info', 'operations/s', 'smb2', 'smb2.get_set_info', 'line'] - }, - 'smb2_find': { - 'lines': [ - ['smb2_find_count', 'find', 'incremental', 1, 1] - ], - 'options': [None, 'Find', 'operations/s', 'smb2', 'smb2.find', 'line'] - }, - 'smb2_notify': { - 'lines': [ - ['smb2_notify_count', 'notify', 'incremental', 1, 1] - ], - 'options': [None, 'Notify', 'operations/s', 'smb2', 'smb2.notify', 'line'] - }, - 'smb2_sm_count': { - 'lines': [ - ['smb2_tcon_count', 'tcon', 'absolute', 1, 1], - ['smb2_negprot_count', 'negprot', 'absolute', 1, 1], - ['smb2_tdis_count', 'tdis', 'absolute', 1, 1], - ['smb2_cancel_count', 'cancel', 'absolute', 1, 1], - ['smb2_logoff_count', 'logoff', 'absolute', 1, 1], - ['smb2_flush_count', 'flush', 'absolute', 1, 1], - ['smb2_lock_count', 'lock', 'absolute', 1, 1], - ['smb2_keepalive_count', 'keepalive', 'absolute', 1, 1], - ['smb2_break_count', 'break', 'absolute', 1, 1], - ['smb2_sessetup_count', 'sessetup', 'absolute', 1, 1] - ], - 'options': [None, 'Lesser Ops', 'count', 'smb2', 'smb2.sm_counters', 'stacked'] - } - } + 'syscall_rw': { + 'options': [None, 'R/Ws', 'kilobytes/s', 'syscall', 'syscall.rw', 'area'], + 'lines': [ + ['syscall_sendfile_bytes', 'sendfile', 'incremental', 1, 1024], + ['syscall_recvfile_bytes', 'recvfile', 'incremental', -1, 1024] + ] + }, + 'smb2_rw': { + 'options': [None, 'R/Ws', 'kilobytes/s', 'smb2', 'smb2.rw', 'area'], + 'lines': [ + ['smb2_read_outbytes', 'readout', 'incremental', 1, 1024], + ['smb2_write_inbytes', 'writein', 'incremental', -1, 1024], + ['smb2_read_inbytes', 'readin', 'incremental', 1, 1024], + ['smb2_write_outbytes', 'writeout', 'incremental', -1, 1024] + ] + }, + 'smb2_create_close': { + 'options': [None, 'Create/Close', 'operations/s', 'smb2', 'smb2.create_close', 'line'], + 'lines': [ + ['smb2_create_count', 'create', 'incremental', 1, 1], + ['smb2_close_count', 'close', 'incremental', -1, 1] + ] + }, + 'smb2_info': { + 'options': [None, 'Info', 'operations/s', 'smb2', 'smb2.get_set_info', 'line'], + 'lines': [ + ['smb2_getinfo_count', 'getinfo', 'incremental', 1, 1], + ['smb2_setinfo_count', 'setinfo', 'incremental', -1, 1] + ] + }, + 'smb2_find': { + 'options': [None, 'Find', 'operations/s', 'smb2', 'smb2.find', 'line'], + 'lines': [ + ['smb2_find_count', 'find', 'incremental', 1, 1] + ] + }, + 'smb2_notify': { + 'options': [None, 'Notify', 'operations/s', 'smb2', 'smb2.notify', 'line'], + 'lines': [ + ['smb2_notify_count', 'notify', 'incremental', 1, 1] + ] + }, + 'smb2_sm_count': { + 'options': [None, 'Lesser Ops', 'count', 'smb2', 'smb2.sm_counters', 'stacked'], + 'lines': [ + ['smb2_tcon_count', 'tcon', 'absolute', 1, 1], + ['smb2_negprot_count', 'negprot', 'absolute', 1, 1], + ['smb2_tdis_count', 'tdis', 'absolute', 1, 1], + ['smb2_cancel_count', 'cancel', 'absolute', 1, 1], + ['smb2_logoff_count', 'logoff', 'absolute', 1, 1], + ['smb2_flush_count', 'flush', 'absolute', 1, 1], + ['smb2_lock_count', 'lock', 'absolute', 1, 1], + ['smb2_keepalive_count', 'keepalive', 'absolute', 1, 1], + ['smb2_break_count', 'break', 'absolute', 1, 1], + ['smb2_sessetup_count', 'sessetup', 'absolute', 1, 1] + ] + } +} class Service(ExecutableService): diff --git a/python.d/sensors.chart.py b/python.d/sensors.chart.py index 6bc7c80508..84ce97ca84 100644 --- a/python.d/sensors.chart.py +++ b/python.d/sensors.chart.py @@ -17,37 +17,44 @@ CHARTS = { 'options': [None, ' temperature', 'Celsius', 'temperature', 'sensors.temperature', 'line'], 'lines': [ [None, None, 'absolute', 1, 1000] - ]}, + ] + }, 'voltage': { 'options': [None, ' voltage', 'Volts', 'voltage', 'sensors.voltage', 'line'], 'lines': [ [None, None, 'absolute', 1, 1000] - ]}, + ] + }, 'current': { 'options': [None, ' current', 'Ampere', 'current', 'sensors.current', 'line'], 'lines': [ [None, None, 'absolute', 1, 1000] - ]}, + ] + }, 'power': { 'options': [None, ' power', 'Watt', 'power', 'sensors.power', 'line'], 'lines': [ [None, None, 'absolute', 1, 1000000] - ]}, + ] + }, 'fan': { 'options': [None, ' fans speed', 'Rotations/min', 'fans', 'sensors.fan', 'line'], 'lines': [ [None, None, 'absolute', 1, 1000] - ]}, + ] + }, 'energy': { 'options': [None, ' energy', 'Joule', 'energy', 'sensors.energy', 'areastack'], 'lines': [ [None, None, 'incremental', 1, 1000000] - ]}, + ] + }, 'humidity': { 'options': [None, ' humidity', 'Percent', 'humidity', 'sensors.humidity', 'line'], 'lines': [ [None, None, 'absolute', 1, 1000] - ]} + ] + } } LIMITS = { @@ -95,7 +102,7 @@ class Service(SimpleService): limit = LIMITS[type_name] if val < limit[0] or val > limit[1]: continue - data[prefix + "_" + str(feature.name.decode())] = int(val * 1000) + data[prefix + '_' + str(feature.name.decode())] = int(val * 1000) except Exception as error: self.error(error) return None @@ -115,7 +122,7 @@ class Service(SimpleService): continue if TYPE_MAP[feature.type] == sensor: # create chart - name = chip_name + "_" + TYPE_MAP[feature.type] + name = chip_name + '_' + TYPE_MAP[feature.type] if name not in self.order: self.order.append(name) chart_def = list(CHARTS[sensor]['options']) @@ -123,7 +130,7 @@ class Service(SimpleService): self.definitions[name] = {'options': chart_def} self.definitions[name]['lines'] = [] line = list(CHARTS[sensor]['lines'][0]) - line[0] = chip_name + "_" + str(feature.name.decode()) + line[0] = chip_name + '_' + str(feature.name.decode()) line[1] = sensors.get_label(chip, feature) self.definitions[name]['lines'].append(line) @@ -137,4 +144,3 @@ class Service(SimpleService): self.create_definitions() return True - diff --git a/python.d/smartd_log.chart.py b/python.d/smartd_log.chart.py index 050656ba4d..ef4d10ee42 100644 --- a/python.d/smartd_log.chart.py +++ b/python.d/smartd_log.chart.py @@ -116,7 +116,7 @@ def chart_template(chart_name): chart_name: { 'options': [None, title, units, family, 'smartd_log.' + chart_name, 'line'], 'lines': [] - } + } } diff --git a/python.d/spigotmc.chart.py b/python.d/spigotmc.chart.py index 1fc0a13470..ecdd8f44bf 100644 --- a/python.d/spigotmc.chart.py +++ b/python.d/spigotmc.chart.py @@ -35,6 +35,7 @@ CHARTS = { } } + class Service(SimpleService): def __init__(self, configuration=None, name=None): SimpleService.__init__(self, configuration=configuration, name=name) diff --git a/python.d/springboot.chart.py b/python.d/springboot.chart.py index 04151bfaa8..642da04bfc 100644 --- a/python.d/springboot.chart.py +++ b/python.d/springboot.chart.py @@ -18,54 +18,61 @@ DEFAULT_CHARTS = { 'response_code': { 'options': [None, "Response Codes", "requests/s", "response", "springboot.response_code", "stacked"], 'lines': [ - ["resp_other", 'Other', 'incremental'], - ["resp_1xx", '1xx', 'incremental'], - ["resp_2xx", '2xx', 'incremental'], - ["resp_3xx", '3xx', 'incremental'], - ["resp_4xx", '4xx', 'incremental'], - ["resp_5xx", '5xx', 'incremental'], - ]}, + ["resp_other", 'Other', 'incremental'], + ["resp_1xx", '1xx', 'incremental'], + ["resp_2xx", '2xx', 'incremental'], + ["resp_3xx", '3xx', 'incremental'], + ["resp_4xx", '4xx', 'incremental'], + ["resp_5xx", '5xx', 'incremental'], + ] + }, 'threads': { 'options': [None, "Threads", "current threads", "threads", "springboot.threads", "area"], 'lines': [ ["threads_daemon", 'daemon', 'absolute'], ["threads", 'total', 'absolute'], - ]}, + ] + }, 'gc_time': { 'options': [None, "GC Time", "milliseconds", "garbage collection", "springboot.gc_time", "stacked"], 'lines': [ - ["gc_copy_time", 'Copy', 'incremental'], - ["gc_marksweepcompact_time", 'MarkSweepCompact', 'incremental'], - ["gc_parnew_time", 'ParNew', 'incremental'], - ["gc_concurrentmarksweep_time", 'ConcurrentMarkSweep', 'incremental'], - ["gc_ps_scavenge_time", 'PS Scavenge', 'incremental'], - ["gc_ps_marksweep_time", 'PS MarkSweep', 'incremental'], - ["gc_g1_young_generation_time", 'G1 Young Generation', 'incremental'], - ["gc_g1_old_generation_time", 'G1 Old Generation', 'incremental'], - ]}, + ["gc_copy_time", 'Copy', 'incremental'], + ["gc_marksweepcompact_time", 'MarkSweepCompact', 'incremental'], + ["gc_parnew_time", 'ParNew', 'incremental'], + ["gc_concurrentmarksweep_time", 'ConcurrentMarkSweep', 'incremental'], + ["gc_ps_scavenge_time", 'PS Scavenge', 'incremental'], + ["gc_ps_marksweep_time", 'PS MarkSweep', 'incremental'], + ["gc_g1_young_generation_time", 'G1 Young Generation', 'incremental'], + ["gc_g1_old_generation_time", 'G1 Old Generation', 'incremental'], + ] + }, 'gc_ope': { 'options': [None, "GC Operations", "operations/s", "garbage collection", "springboot.gc_ope", "stacked"], 'lines': [ - ["gc_copy_count", 'Copy', 'incremental'], - ["gc_marksweepcompact_count", 'MarkSweepCompact', 'incremental'], - ["gc_parnew_count", 'ParNew', 'incremental'], - ["gc_concurrentmarksweep_count", 'ConcurrentMarkSweep', 'incremental'], - ["gc_ps_scavenge_count", 'PS Scavenge', 'incremental'], - ["gc_ps_marksweep_count", 'PS MarkSweep', 'incremental'], - ["gc_g1_young_generation_count", 'G1 Young Generation', 'incremental'], - ["gc_g1_old_generation_count", 'G1 Old Generation', 'incremental'], - ]}, + ["gc_copy_count", 'Copy', 'incremental'], + ["gc_marksweepcompact_count", 'MarkSweepCompact', 'incremental'], + ["gc_parnew_count", 'ParNew', 'incremental'], + ["gc_concurrentmarksweep_count", 'ConcurrentMarkSweep', 'incremental'], + ["gc_ps_scavenge_count", 'PS Scavenge', 'incremental'], + ["gc_ps_marksweep_count", 'PS MarkSweep', 'incremental'], + ["gc_g1_young_generation_count", 'G1 Young Generation', 'incremental'], + ["gc_g1_old_generation_count", 'G1 Old Generation', 'incremental'], + ] + }, 'heap': { 'options': [None, "Heap Memory Usage", "KB", "heap memory", "springboot.heap", "area"], 'lines': [ ["heap_committed", 'committed', "absolute"], ["heap_used", 'used', "absolute"], - ]}, + ] + } } + class ExtraChartError(ValueError): pass + class Service(UrlService): def __init__(self, configuration=None, name=None): UrlService.__init__(self, configuration=configuration, name=name) @@ -88,11 +95,11 @@ class Service(UrlService): return None result = { - 'resp_1xx': 0, - 'resp_2xx': 0, - 'resp_3xx': 0, - 'resp_4xx': 0, - 'resp_5xx': 0, + 'resp_1xx': 0, + 'resp_2xx': 0, + 'resp_3xx': 0, + 'resp_4xx': 0, + 'resp_5xx': 0, 'resp_other': 0, } @@ -122,14 +129,14 @@ class Service(UrlService): self.order.append(extra['id']) def _add_extra_chart(self, chart): - chart_id = chart.get('id', None) or die('id is not defined in extra chart') - options = chart.get('options', None) or die('option is not defined in extra chart: %s' % chart_id) - lines = chart.get('lines', None) or die('lines is not defined in extra chart: %s' % chart_id) - - title = options.get('title', None) or die('title is missing: %s' % chart_id) - units = options.get('units', None) or die('units is missing: %s' % chart_id) - family = options.get('family', title) - context = options.get('context', 'springboot.' + title) + chart_id = chart.get('id', None) or self.die('id is not defined in extra chart') + options = chart.get('options', None) or self.die('option is not defined in extra chart: %s' % chart_id) + lines = chart.get('lines', None) or self.die('lines is not defined in extra chart: %s' % chart_id) + + title = options.get('title', None) or self.die('title is missing: %s' % chart_id) + units = options.get('units', None) or self.die('units is missing: %s' % chart_id) + family = options.get('family', title) + context = options.get('context', 'springboot.' + title) charttype = options.get('charttype', 'line') result = { @@ -138,11 +145,11 @@ class Service(UrlService): } for line in lines: - dimension = line.get('dimension', None) or die('dimension is missing: %s' % chart_id) - name = line.get('name', dimension) - algorithm = line.get('algorithm', 'absolute') + dimension = line.get('dimension', None) or self.die('dimension is missing: %s' % chart_id) + name = line.get('name', dimension) + algorithm = line.get('algorithm', 'absolute') multiplier = line.get('multiplier', 1) - divisor = line.get('divisor', 1) + divisor = line.get('divisor', 1) result['lines'].append([dimension, name, algorithm, multiplier, divisor]) self.definitions[chart_id] = result diff --git a/python.d/squid.chart.py b/python.d/squid.chart.py index f267199449..168e7fdbcd 100644 --- a/python.d/squid.chart.py +++ b/python.d/squid.chart.py @@ -16,31 +16,35 @@ ORDER = ['clients_net', 'clients_requests', 'servers_net', 'servers_requests'] CHARTS = { 'clients_net': { - 'options': [None, "Squid Client Bandwidth", "kilobits/s", "clients", "squid.clients_net", "area"], + 'options': [None, 'Squid Client Bandwidth', 'kilobits/s', 'clients', 'squid.clients_net', 'area'], 'lines': [ - ["client_http_kbytes_in", "in", "incremental", 8, 1], - ["client_http_kbytes_out", "out", "incremental", -8, 1], - ["client_http_hit_kbytes_out", "hits", "incremental", -8, 1] - ]}, + ['client_http_kbytes_in', 'in', 'incremental', 8, 1], + ['client_http_kbytes_out', 'out', 'incremental', -8, 1], + ['client_http_hit_kbytes_out', 'hits', 'incremental', -8, 1] + ] + }, 'clients_requests': { - 'options': [None, "Squid Client Requests", "requests/s", "clients", "squid.clients_requests", 'line'], + 'options': [None, 'Squid Client Requests', 'requests/s', 'clients', 'squid.clients_requests', 'line'], 'lines': [ - ["client_http_requests", "requests", "incremental"], - ["client_http_hits", "hits", "incremental"], - ["client_http_errors", "errors", "incremental", -1, 1] - ]}, + ['client_http_requests', 'requests', 'incremental'], + ['client_http_hits', 'hits', 'incremental'], + ['client_http_errors', 'errors', 'incremental', -1, 1] + ] + }, 'servers_net': { - 'options': [None, "Squid Server Bandwidth", "kilobits/s", "servers", "squid.servers_net", "area"], + 'options': [None, 'Squid Server Bandwidth', 'kilobits/s', 'servers', 'squid.servers_net', 'area'], 'lines': [ - ["server_all_kbytes_in", "in", "incremental", 8, 1], - ["server_all_kbytes_out", "out", "incremental", -8, 1] - ]}, + ['server_all_kbytes_in', 'in', 'incremental', 8, 1], + ['server_all_kbytes_out', 'out', 'incremental', -8, 1] + ] + }, 'servers_requests': { - 'options': [None, "Squid Server Requests", "requests/s", "servers", "squid.servers_requests", 'line'], + 'options': [None, 'Squid Server Requests', 'requests/s', 'servers', 'squid.servers_requests', 'line'], 'lines': [ - ["server_all_requests", "requests", "incremental"], - ["server_all_errors", "errors", "incremental", -1, 1] - ]} + ['server_all_requests', 'requests', 'incremental'], + ['server_all_errors', 'errors', 'incremental', -1, 1] + ] + } } @@ -48,8 +52,8 @@ class Service(SocketService): def __init__(self, configuration=None, name=None): SocketService.__init__(self, configuration=configuration, name=name) self._keep_alive = True - self.request = "" - self.host = "localhost" + self.request = '' + self.host = 'localhost' self.port = 3128 self.order = ORDER self.definitions = CHARTS @@ -63,43 +67,43 @@ class Service(SocketService): data = dict() try: - raw = "" + raw = '' for tmp in response.split('\r\n'): - if tmp.startswith("sample_time"): + if tmp.startswith('sample_time'): raw = tmp break if raw.startswith('<'): - self.error("invalid data received") + self.error('invalid data received') return None for row in raw.split('\n'): - if row.startswith(("client", "server.all")): - tmp = row.split("=") + if row.startswith(('client', 'server.all')): + tmp = row.split('=') data[tmp[0].replace('.', '_').strip(' ')] = int(tmp[1]) except (ValueError, AttributeError, TypeError): - self.error("invalid data received") + self.error('invalid data received') return None if not data: - self.error("no data received") + self.error('no data received') return None return data def _check_raw_data(self, data): header = data[:1024].lower() - if "connection: keep-alive" in header: + if 'connection: keep-alive' in header: self._keep_alive = True else: self._keep_alive = False - if data[-7:] == "\r\n0\r\n\r\n" and "transfer-encoding: chunked" in header: # HTTP/1.1 response - self.debug("received full response from squid") + if data[-7:] == '\r\n0\r\n\r\n' and 'transfer-encoding: chunked' in header: # HTTP/1.1 response + self.debug('received full response from squid') return True - self.debug("waiting more data from squid") + self.debug('waiting more data from squid') return False def check(self): @@ -110,10 +114,10 @@ class Service(SocketService): self._parse_config() # format request req = self.request.decode() - if not req.startswith("GET"): - req = "GET " + req - if not req.endswith(" HTTP/1.1\r\n\r\n"): - req += " HTTP/1.1\r\n\r\n" + if not req.startswith('GET'): + req = 'GET ' + req + if not req.endswith(' HTTP/1.1\r\n\r\n'): + req += ' HTTP/1.1\r\n\r\n' self.request = req.encode() if self._get_data() is not None: return True diff --git a/python.d/tomcat.chart.py b/python.d/tomcat.chart.py index eaf8210641..e6883b1169 100644 --- a/python.d/tomcat.chart.py +++ b/python.d/tomcat.chart.py @@ -18,67 +18,75 @@ ORDER = ['accesses', 'bandwidth', 'processing_time', 'threads', 'jvm', 'jvm_eden CHARTS = { 'accesses': { - 'options': [None, "Requests", "requests/s", "statistics", "tomcat.accesses", "area"], + 'options': [None, 'Requests', 'requests/s', 'statistics', 'tomcat.accesses', 'area'], 'lines': [ - ["requestCount", 'accesses', 'incremental'], - ["errorCount", 'errors', 'incremental'], - ]}, + ['requestCount', 'accesses', 'incremental'], + ['errorCount', 'errors', 'incremental'], + ] + }, 'bandwidth': { - 'options': [None, "Bandwidth", "KB/s", "statistics", "tomcat.bandwidth", "area"], + 'options': [None, 'Bandwidth', 'KB/s', 'statistics', 'tomcat.bandwidth', 'area'], 'lines': [ - ["bytesSent", 'sent', 'incremental', 1, 1024], - ["bytesReceived", 'received', 'incremental', 1, 1024], - ]}, + ['bytesSent', 'sent', 'incremental', 1, 1024], + ['bytesReceived', 'received', 'incremental', 1, 1024], + ] + }, 'processing_time': { - 'options': [None, "processing time", "seconds", "statistics", "tomcat.processing_time", "area"], + 'options': [None, 'processing time', 'seconds', 'statistics', 'tomcat.processing_time', 'area'], 'lines': [ - ["processingTime", 'processing time', 'incremental', 1, 1000] - ]}, + ['processingTime', 'processing time', 'incremental', 1, 1000] + ] + }, 'threads': { - 'options': [None, "Threads", "current threads", "statistics", "tomcat.threads", "area"], + 'options': [None, 'Threads', 'current threads', 'statistics', 'tomcat.threads', 'area'], 'lines': [ - ["currentThreadCount", 'current', "absolute"], - ["currentThreadsBusy", 'busy', "absolute"] - ]}, + ['currentThreadCount', 'current', 'absolute'], + ['currentThreadsBusy', 'busy', 'absolute'] + ] + }, 'jvm': { - 'options': [None, "JVM Memory Pool Usage", "MB", "memory", "tomcat.jvm", "stacked"], + 'options': [None, 'JVM Memory Pool Usage', 'MB', 'memory', 'tomcat.jvm', 'stacked'], 'lines': [ - ["free", 'free', "absolute", 1, 1048576], - ["eden_used", 'eden', "absolute", 1, 1048576], - ["survivor_used", 'survivor', "absolute", 1, 1048576], - ["tenured_used", 'tenured', "absolute", 1, 1048576], - ["code_cache_used", 'code cache', "absolute", 1, 1048576], - ["compressed_used", 'compressed', "absolute", 1, 1048576], - ["metaspace_used", 'metaspace', "absolute", 1, 1048576], - ]}, + ['free', 'free', 'absolute', 1, 1048576], + ['eden_used', 'eden', 'absolute', 1, 1048576], + ['survivor_used', 'survivor', 'absolute', 1, 1048576], + ['tenured_used', 'tenured', 'absolute', 1, 1048576], + ['code_cache_used', 'code cache', 'absolute', 1, 1048576], + ['compressed_used', 'compressed', 'absolute', 1, 1048576], + ['metaspace_used', 'metaspace', 'absolute', 1, 1048576], + ] + }, 'jvm_eden': { - 'options': [None, "Eden Memory Usage", "MB", "memory", "tomcat.jvm_eden", "area"], + 'options': [None, 'Eden Memory Usage', 'MB', 'memory', 'tomcat.jvm_eden', 'area'], 'lines': [ - ["eden_used", 'used', "absolute", 1, 1048576], - ["eden_committed", 'committed', "absolute", 1, 1048576], - ["eden_max", 'max', "absolute", 1, 1048576] - ]}, + ['eden_used', 'used', 'absolute', 1, 1048576], + ['eden_committed', 'committed', 'absolute', 1, 1048576], + ['eden_max', 'max', 'absolute', 1, 1048576] + ] + }, 'jvm_survivor': { - 'options': [None, "Survivor Memory Usage", "MB", "memory", "tomcat.jvm_survivor", "area"], + 'options': [None, 'Survivor Memory Usage', 'MB', 'memory', 'tomcat.jvm_survivor', 'area'], 'lines': [ - ["survivor_used", 'used', "absolute", 1, 1048576], - ["survivor_committed", 'committed', "absolute", 1, 1048576], - ["survivor_max", 'max', "absolute", 1, 1048576] - ]}, + ['survivor_used', 'used', 'absolute', 1, 1048576], + ['survivor_committed', 'committed', 'absolute', 1, 1048576], + ['survivor_max', 'max', 'absolute', 1, 1048576] + ] + }, 'jvm_tenured': { - 'options': [None, "Tenured Memory Usage", "MB", "memory", "tomcat.jvm_tenured", "area"], + 'options': [None, 'Tenured Memory Usage', 'MB', 'memory', 'tomcat.jvm_tenured', 'area'], 'lines': [ - ["tenured_used", 'used', "absolute", 1, 1048576], - ["tenured_committed", 'committed', "absolute", 1, 1048576], - ["tenured_max", 'max', "absolute", 1, 1048576] - ]}, + ['tenured_used', 'used', 'absolute', 1, 1048576], + ['tenured_committed', 'committed', 'absolute', 1, 1048576], + ['tenured_max', 'max', 'absolute', 1, 1048576] + ] + } } class Service(UrlService): def __init__(self, configuration=None, name=None): UrlService.__init__(self, configuration=configuration, name=name) - self.url = self.configuration.get('url', "http://127.0.0.1:8080/manager/status?XML=true") + self.url = self.configuration.get('url', 'http://127.0.0.1:8080/manager/status?XML=true') self.connector_name = self.configuration.get('connector_name', None) self.order = ORDER self.definitions = CHARTS @@ -147,9 +155,9 @@ class Service(UrlService): request_info = connector.find('requestInfo') data['processingTime'] = request_info.get('processingTime') - data['requestCount'] = request_info.get('requestCount') - data['errorCount'] = request_info.get('errorCount') - data['bytesReceived'] = request_info.get('bytesReceived') - data['bytesSent'] = request_info.get('bytesSent') + data['requestCount'] = request_info.get('requestCount') + data['errorCount'] = request_info.get('errorCount') + data['bytesReceived'] = request_info.get('bytesReceived') + data['bytesSent'] = request_info.get('bytesSent') return data or None diff --git a/python.d/traefik.chart.py b/python.d/traefik.chart.py index d8ad0619a2..312575a66f 100644 --- a/python.d/traefik.chart.py +++ b/python.d/traefik.chart.py @@ -33,7 +33,8 @@ CHARTS = { ['redirects', 'redirect', 'incremental'], ['bad_requests', 'bad', 'incremental'], ['other_requests', 'other', 'incremental'] - ]}, + ] + }, 'response_codes': { 'options': [None, 'Responses by codes', 'requests/s', 'responses', 'traefik.response_codes', 'stacked'], 'lines': [ @@ -43,37 +44,45 @@ CHARTS = { ['4xx', None, 'incremental'], ['1xx', None, 'incremental'], ['other', None, 'incremental'] - ]}, + ] + }, 'detailed_response_codes': { - 'options': [None, 'Detailed response codes', 'requests/s', 'responses', 'traefik.detailed_response_codes', 'stacked'], - 'lines': [ - ]}, + 'options': [None, 'Detailed response codes', 'requests/s', 'responses', 'traefik.detailed_response_codes', + 'stacked'], + 'lines': [] + }, 'requests': { 'options': [None, 'Requests', 'requests/s', 'requests', 'traefik.requests', 'line'], 'lines': [ ['total_count', 'requests', 'incremental'] - ]}, + ] + }, 'total_response_time': { 'options': [None, 'Total response time', 'seconds', 'timings', 'traefik.total_response_time', 'line'], 'lines': [ ['total_response_time_sec', 'response', 'absolute', 1, 10000] - ]}, + ] + }, 'average_response_time': { 'options': [None, 'Average response time', 'milliseconds', 'timings', 'traefik.average_response_time', 'line'], 'lines': [ ['average_response_time_sec', 'response', 'absolute', 1, 1000] - ]}, + ] + }, 'average_response_time_per_iteration': { - 'options': [None, 'Average response time per iteration', 'milliseconds', 'timings', 'traefik.average_response_time_per_iteration', 'line'], + 'options': [None, 'Average response time per iteration', 'milliseconds', 'timings', + 'traefik.average_response_time_per_iteration', 'line'], 'lines': [ ['average_response_time_per_iteration_sec', 'response', 'incremental', 1, 10000] - ]}, + ] + }, 'uptime': { 'options': [None, 'Uptime', 'seconds', 'uptime', 'traefik.uptime', 'line'], 'lines': [ ['uptime_sec', 'uptime', 'absolute'] - ]} + ] } +} HEALTH_STATS = [ 'uptime_sec', @@ -83,6 +92,7 @@ HEALTH_STATS = [ 'total_status_code_count' ] + class Service(UrlService): def __init__(self, configuration=None, name=None): UrlService.__init__(self, configuration=configuration, name=name) @@ -117,9 +127,11 @@ class Service(UrlService): self.data['average_response_time_sec'] *= 1000000 |