@cryptotaxi247 / netdata-1 / commits / acf3b4352

Python.d PEP 8 cleanup, modules D-H (#4287)

* python.d/dnsdist.chart.py PEP 8 cleanup * Converted tabs in indentation to spaces (this is why the diff looks huge). * Fixed container literal formatting. * General cleanup regarding blank lines. * python.d/dns_query_time.chart.py PEP 8 cleanup Fixed container literal formatting. * python.d/dockerd.chart.py PEP 8 cleanup Fixed overly long lines and trailing empty line. * python.d/dovecot.chart.py PEP 8 cleanup Made string literals use consistent quoting and fixed container literal formatting. * python.d/elasticsearch.chart.py PEP 8 cleanup Fixed container literal formatting. * python.d/exim.chart.py PEP 8 cleanup Fixed string quoting and container literal formatting. * python.d/fail2ban.chart.py PEP 8 cleanup Fixed string quoting and container literal formatting. * python.d/freeradius.chart.py PEP 8 cleanup Fixed quoting of strings and formatting of container literals. * python.d/go_expvar.chart.py PEP 8 cleanup Fixed formatting of conainer literals. * python.d/haproxy.chart.py PEP 8 cleanup Make string quoting consistent and fix formatting of container literals. * python.d/httpcheck.chart.py PEP 8 cleanup Fixed quoting of strings and formatting of container literals. * Fix syntax issue in httpcheck module caused by previous commit.

Austin S. Hemmelgarn committed Sep 26, 2018 at 11:38 UTC acf3b43523224d5685d9ac5c794aeb49dba076f6
11 files changed +489 -346
python.d/dns_query_time.chart.py
+18 -8
@@ -4,18 +4,22 @@
4 # SPDX-License-Identifier: GPL-3.0+
5
6 from random import choice
7 -from threading import Thread
7 from socket import getaddrinfo, gaierror
8 +from threading import Thread
9
10 try:
11 from time import monotonic as time
12 except ImportError:
13 from time import time
14 +
15 try:
15 - import dns.message, dns.query, dns.name
16 + import dns.message
17 + import dns.query
18 + import dns.name
19 DNS_PYTHON = True
20 except ImportError:
21 DNS_PYTHON = False
22 +
23 try:
24 from queue import Queue
25 except ImportError:
@@ -118,8 +122,12 @@ def check_ns(ns):
122 def create_charts(aggregate, server_list):
123 if aggregate:
124 order = ['dns_group']
121 - definitions = {'dns_group': {'options': [None, 'DNS Response Time', 'ms', 'name servers',
122 - 'dns_query_time.response_time', 'line'], 'lines': []}}
125 + definitions = {
126 + 'dns_group': {
127 + 'options': [None, 'DNS Response Time', 'ms', 'name servers', 'dns_query_time.response_time', 'line'],
128 + 'lines': []
129 + }
130 + }
131 for ns in server_list:
132 definitions['dns_group']['lines'].append(['_'.join(['ns', ns.replace('.', '_')]), ns, 'absolute'])
133
@@ -128,8 +136,10 @@ def create_charts(aggregate, server_list):
136 order = [''.join(['dns_', ns.replace('.', '_')]) for ns in server_list]
137 definitions = dict()
138 for ns in server_list:
131 - definitions[''.join(['dns_', ns.replace('.', '_')])] = {'options': [None, 'DNS Response Time', 'ms', ns,
132 - 'dns_query_time.response_time', 'area'],
133 - 'lines': [['_'.join(['ns', ns.replace('.', '_')]),
134 - ns, 'absolute']]}
139 + definitions[''.join(['dns_', ns.replace('.', '_')])] = {
140 + 'options': [None, 'DNS Response Time', 'ms', ns, 'dns_query_time.response_time', 'area'],
141 + 'lines': [
142 + ['_'.join(['ns', ns.replace('.', '_')]), ns, 'absolute']
143 + ]
144 + }
145 return order, definitions
python.d/dnsdist.chart.py
+122 -91
@@ -1,102 +1,133 @@
1 # -*- coding: utf-8 -*-
2 # SPDX-License-Identifier: GPL-3.0+
3 +
4 from json import loads
5 +
6 from bases.FrameworkServices.UrlService import UrlService
7
6 -ORDER = ['queries', 'queries_dropped', 'packets_dropped', 'answers', 'backend_responses', 'backend_commerrors', 'backend_errors', 'cache', 'servercpu', 'servermem', 'query_latency', 'query_latency_avg']
8 +
9 +ORDER = [
10 + 'queries',
11 + 'queries_dropped',
12 + 'packets_dropped',
13 + 'answers',
14 + 'backend_responses',
15 + 'backend_commerrors',
16 + 'backend_errors',
17 + 'cache',
18 + 'servercpu',
19 + 'servermem',
20 + 'query_latency',
21 + 'query_latency_avg'
22 +]
23 +
24 +
25 CHARTS = {
8 - 'queries': {
9 - 'options': [None, 'Client queries received', 'queries/s', 'queries', 'dnsdist.queries', 'line'],
10 - 'lines': [
11 - ['queries', 'all', 'incremental'],
12 - ['rdqueries', 'recursive', 'incremental'],
13 - ['empty-queries', 'empty', 'incremental']
14 - ]},
15 - 'queries_dropped': {
16 - 'options': [None, 'Client queries dropped', 'queries/s', 'queries', 'dnsdist.queries_dropped', 'line'],
17 - 'lines': [
18 - ['rule-drop', 'rule drop', 'incremental'],
19 - ['dyn-blocked', 'dynamic block', 'incremental'],
20 - ['no-policy', 'no policy', 'incremental'],
21 - ['noncompliant-queries', 'non compliant', 'incremental']
22 - ]},
23 - 'packets_dropped': {
24 - 'options': [None, 'Packets dropped', 'packets/s', 'packets', 'dnsdist.packets_dropped', 'line'],
25 - 'lines': [
26 - ['acl-drops', 'acl', 'incremental']
27 - ]},
28 - 'answers': {
29 - 'options': [None, 'Answers statistics', 'answers/s', 'answers', 'dnsdist.answers', 'line'],
30 - 'lines': [
31 - ['self-answered', 'self answered', 'incremental'],
32 - ['rule-nxdomain', 'nxdomain', 'incremental', -1],
33 - ['rule-refused', 'refused', 'incremental', -1],
34 - ['trunc-failures', 'trunc failures', 'incremental', -1]
35 - ]},
36 - 'backend_responses': {
37 - 'options': [None, 'Backend responses', 'responses/s', 'backends', 'dnsdist.backend_responses', 'line'],
38 - 'lines': [
39 - ['responses', 'responses', 'incremental']
40 - ]},
41 - 'backend_commerrors': {
42 - 'options': [None, 'Backend Communication Errors', 'errors/s', 'backends', 'dnsdist.backend_commerrors', 'line'],
43 - 'lines': [
44 - ['downstream-send-errors', 'send errors', 'incremental']
45 - ]},
46 - 'backend_errors': {
47 - 'options': [None, 'Backend error responses', 'responses/s', 'backends', 'dnsdist.backend_errors', 'line'],
48 - 'lines': [
49 - ['downstream-timeouts', 'timeout', 'incremental'],
50 - ['servfail-responses', 'servfail', 'incremental'],
51 - ['noncompliant-responses', 'non compliant', 'incremental']
52 - ]},
53 - 'cache': {
54 - 'options': [None, 'Cache performance', 'answers/s', 'cache', 'dnsdist.cache', 'area'],
55 - 'lines': [
56 - ['cache-hits', 'hits', 'incremental'],
57 - ['cache-misses', 'misses', 'incremental', -1]
58 - ]},
59 - 'servercpu': {
60 - 'options': [None, 'DNSDIST server CPU utilization', 'ms/s', 'server', 'dnsdist.servercpu', 'stacked'],
61 - 'lines': [
62 - ['cpu-sys-msec', 'system state', 'incremental'],
63 - ['cpu-user-msec', 'user state', 'incremental']
64 - ]},
65 - 'servermem': {
66 - 'options': [None, 'DNSDIST server memory utilization', 'MB', 'server', 'dnsdist.servermem', 'area'],
67 - 'lines': [
68 - ['real-memory-usage', 'memory usage', 'absolute', 1, 1048576]
69 - ]},
70 - 'query_latency': {
71 - 'options': [None, 'Query latency', 'queries/s', 'latency', 'dnsdist.query_latency', 'stacked'],
72 - 'lines': [
73 - ['latency0-1', '1ms', 'incremental'],
74 - ['latency1-10', '10ms', 'incremental'],
75 - ['latency10-50', '50ms', 'incremental'],
76 - ['latency50-100', '100ms', 'incremental'],
77 - ['latency100-1000', '1sec', 'incremental'],
78 - ['latency-slow', 'slow', 'incremental']
79 - ]},
80 - 'query_latency_avg': {
81 - 'options': [None, 'Average latency for the last N queries', 'ms/query', 'latency', 'dnsdist.query_latency_avg', 'line'],
82 - 'lines': [
83 - ['latency-avg100', '100', 'absolute'],
84 - ['latency-avg1000', '1k', 'absolute'],
85 - ['latency-avg10000', '10k', 'absolute'],
86 - ['latency-avg1000000', '1000k', 'absolute']
87 - ]}
26 + 'queries': {
27 + 'options': [None, 'Client queries received', 'queries/s', 'queries', 'dnsdist.queries', 'line'],
28 + 'lines': [
29 + ['queries', 'all', 'incremental'],
30 + ['rdqueries', 'recursive', 'incremental'],
31 + ['empty-queries', 'empty', 'incremental']
32 + ]
33 + },
34 + 'queries_dropped': {
35 + 'options': [None, 'Client queries dropped', 'queries/s', 'queries', 'dnsdist.queries_dropped', 'line'],
36 + 'lines': [
37 + ['rule-drop', 'rule drop', 'incremental'],
38 + ['dyn-blocked', 'dynamic block', 'incremental'],
39 + ['no-policy', 'no policy', 'incremental'],
40 + ['noncompliant-queries', 'non compliant', 'incremental']
41 + ]
42 + },
43 + 'packets_dropped': {
44 + 'options': [None, 'Packets dropped', 'packets/s', 'packets', 'dnsdist.packets_dropped', 'line'],
45 + 'lines': [
46 + ['acl-drops', 'acl', 'incremental']
47 + ]
48 + },
49 + 'answers': {
50 + 'options': [None, 'Answers statistics', 'answers/s', 'answers', 'dnsdist.answers', 'line'],
51 + 'lines': [
52 + ['self-answered', 'self answered', 'incremental'],
53 + ['rule-nxdomain', 'nxdomain', 'incremental', -1],
54 + ['rule-refused', 'refused', 'incremental', -1],
55 + ['trunc-failures', 'trunc failures', 'incremental', -1]
56 + ]
57 + },
58 + 'backend_responses': {
59 + 'options': [None, 'Backend responses', 'responses/s', 'backends', 'dnsdist.backend_responses', 'line'],
60 + 'lines': [
61 + ['responses', 'responses', 'incremental']
62 + ]
63 + },
64 + 'backend_commerrors': {
65 + 'options': [None, 'Backend Communication Errors', 'errors/s', 'backends', 'dnsdist.backend_commerrors', 'line'],
66 + 'lines': [
67 + ['downstream-send-errors', 'send errors', 'incremental']
68 + ]
69 + },
70 + 'backend_errors': {
71 + 'options': [None, 'Backend error responses', 'responses/s', 'backends', 'dnsdist.backend_errors', 'line'],
72 + 'lines': [
73 + ['downstream-timeouts', 'timeout', 'incremental'],
74 + ['servfail-responses', 'servfail', 'incremental'],
75 + ['noncompliant-responses', 'non compliant', 'incremental']
76 + ]
77 + },
78 + 'cache': {
79 + 'options': [None, 'Cache performance', 'answers/s', 'cache', 'dnsdist.cache', 'area'],
80 + 'lines': [
81 + ['cache-hits', 'hits', 'incremental'],
82 + ['cache-misses', 'misses', 'incremental', -1]
83 + ]
84 + },
85 + 'servercpu': {
86 + 'options': [None, 'DNSDIST server CPU utilization', 'ms/s', 'server', 'dnsdist.servercpu', 'stacked'],
87 + 'lines': [
88 + ['cpu-sys-msec', 'system state', 'incremental'],
89 + ['cpu-user-msec', 'user state', 'incremental']
90 + ]
91 + },
92 + 'servermem': {
93 + 'options': [None, 'DNSDIST server memory utilization', 'MB', 'server', 'dnsdist.servermem', 'area'],
94 + 'lines': [
95 + ['real-memory-usage', 'memory usage', 'absolute', 1, 1048576]
96 + ]
97 + },
98 + 'query_latency': {
99 + 'options': [None, 'Query latency', 'queries/s', 'latency', 'dnsdist.query_latency', 'stacked'],
100 + 'lines': [
101 + ['latency0-1', '1ms', 'incremental'],
102 + ['latency1-10', '10ms', 'incremental'],
103 + ['latency10-50', '50ms', 'incremental'],
104 + ['latency50-100', '100ms', 'incremental'],
105 + ['latency100-1000', '1sec', 'incremental'],
106 + ['latency-slow', 'slow', 'incremental']
107 + ]
108 + },
109 + 'query_latency_avg': {
110 + 'options': [None, 'Average latency for the last N queries', 'ms/query', 'latency',
111 + 'dnsdist.query_latency_avg', 'line'],
112 + 'lines': [
113 + ['latency-avg100', '100', 'absolute'],
114 + ['latency-avg1000', '1k', 'absolute'],
115 + ['latency-avg10000', '10k', 'absolute'],
116 + ['latency-avg1000000', '1000k', 'absolute']
117 + ]
118 + }
119 }
120
90 -class Service(UrlService):
91 - def __init__(self, configuration=None, name=None):
92 - UrlService.__init__(self, configuration=configuration, name=name)
93 - self.order = ORDER
94 - self.definitions = CHARTS
121
96 - def _get_data(self):
97 - data = self._get_raw_data()
98 - if not data:
99 - return None
122 +class Service(UrlService):
123 + def __init__(self, configuration=None, name=None):
124 + UrlService.__init__(self, configuration=configuration, name=name)
125 + self.order = ORDER
126 + self.definitions = CHARTS
127
101 - return loads(data)
128 + def _get_data(self):
129 + data = self._get_raw_data()
130 + if not data:
131 + return None
132
133 + return loads(data)
python.d/dockerd.chart.py
+6 -4
@@ -24,19 +24,22 @@ ORDER = [
24
25 CHARTS = {
26 'running_containers': {
27 - 'options': [None, 'Number of running containers', 'running containers', 'running containers', 'docker.running_containers', 'line'],
27 + 'options': [None, 'Number of running containers', 'running containers', 'running containers',
28 + 'docker.running_containers', 'line'],
29 'lines': [
30 ['running_containers', 'running']
31 ]
32 },
33 'healthy_containers': {
33 - 'options': [None, 'Number of healthy containers', 'healthy containers', 'healthy containers', 'docker.healthy_containers', 'line'],
34 + 'options': [None, 'Number of healthy containers', 'healthy containers', 'healthy containers',
35 + 'docker.healthy_containers', 'line'],
36 'lines': [
37 ['healthy_containers', 'healthy']
38 ]
39 },
40 'unhealthy_containers': {
39 - 'options': [None, 'Number of unhealthy containers', 'unhealthy containers', 'unhealthy containers', 'docker.unhealthy_containers', 'line'],
41 + 'options': [None, 'Number of unhealthy containers', 'unhealthy containers', 'unhealthy containers',
42 + 'docker.unhealthy_containers', 'line'],
43 'lines': [
44 ['unhealthy_containers', 'unhealthy']
45 ]
@@ -72,4 +75,3 @@ class Service(SimpleService):
75 data['unhealthy_containers'] = len(self.client.containers.list(filters={'health': 'unhealthy'}, sparse=True))
76
77 return data or None
75 -
python.d/dovecot.chart.py
+53 -33
@@ -11,93 +11,113 @@ priority = 60000
11 retries = 60
12
13 # charts order (can be overridden if you want less charts, or different order)
14 -ORDER = ['sessions', 'logins', 'commands',
15 - 'faults',
16 - 'context_switches',
17 - 'io', 'net', 'syscalls',
18 - 'lookup', 'cache',
19 - 'auth', 'auth_cache']
14 +ORDER = [
15 + 'sessions',
16 + 'logins',
17 + 'commands',
18 + 'faults',
19 + 'context_switches',
20 + 'io',
21 + 'net',
22 + 'syscalls',
23 + 'lookup',
24 + 'cache',
25 + 'auth',
26 + 'auth_cache'
27 +]
28
29 CHARTS = {
30 'sessions': {
23 - 'options': [None, "Dovecot Active Sessions", 'number', 'sessions', 'dovecot.sessions', 'line'],
31 + 'options': [None, 'Dovecot Active Sessions', 'number', 'sessions', 'dovecot.sessions', 'line'],
32 'lines': [
33 ['num_connected_sessions', 'active sessions', 'absolute']
26 - ]},
34 + ]
35 + },
36 'logins': {
28 - 'options': [None, "Dovecot Logins", 'number', 'logins', 'dovecot.logins', 'line'],
37 + 'options': [None, 'Dovecot Logins', 'number', 'logins', 'dovecot.logins', 'line'],
38 'lines': [
39 ['num_logins', 'logins', 'absolute']
31 - ]},
40 + ]
41 + },
42 'commands': {
33 - 'options': [None, "Dovecot Commands", "commands", 'commands', 'dovecot.commands', 'line'],
43 + 'options': [None, 'Dovecot Commands', 'commands', 'commands', 'dovecot.commands', 'line'],
44 'lines': [
45 ['num_cmds', 'commands', 'absolute']
36 - ]},
46 + ]
47 + },
48 'faults': {
38 - 'options': [None, "Dovecot Page Faults", "faults", 'page faults', 'dovecot.faults', 'line'],
49 + 'options': [None, 'Dovecot Page Faults', 'faults', 'page faults', 'dovecot.faults', 'line'],
50 'lines': [
51 ['min_faults', 'minor', 'absolute'],
52 ['maj_faults', 'major', 'absolute']
42 - ]},
53 + ]
54 + },
55 'context_switches': {
44 - 'options': [None, "Dovecot Context Switches", '', 'context switches', 'dovecot.context_switches', 'line'],
56 + 'options': [None, 'Dovecot Context Switches', '', 'context switches', 'dovecot.context_switches', 'line'],
57 'lines': [
58 ['vol_cs', 'voluntary', 'absolute'],
59 ['invol_cs', 'involuntary', 'absolute']
48 - ]},
60 + ]
61 + },
62 'io': {
50 - 'options': [None, "Dovecot Disk I/O", 'kilobytes/s', 'disk', 'dovecot.io', 'area'],
63 + 'options': [None, 'Dovecot Disk I/O', 'kilobytes/s', 'disk', 'dovecot.io', 'area'],
64 'lines': [
65 ['disk_input', 'read', 'incremental', 1, 1024],
66 ['disk_output', 'write', 'incremental', -1, 1024]
54 - ]},
67 + ]
68 + },
69 'net': {
56 - 'options': [None, "Dovecot Network Bandwidth", 'kilobits/s', 'network', 'dovecot.net', 'area'],
70 + 'options': [None, 'Dovecot Network Bandwidth', 'kilobits/s', 'network', 'dovecot.net', 'area'],
71 'lines': [
72 ['read_bytes', 'read', 'incremental', 8, 1024],
73 ['write_bytes', 'write', 'incremental', -8, 1024]
60 - ]},
74 + ]
75 + },
76 'syscalls': {
62 - 'options': [None, "Dovecot Number of SysCalls", 'syscalls/s', 'system', 'dovecot.syscalls', 'line'],
77 + 'options': [None, 'Dovecot Number of SysCalls', 'syscalls/s', 'system', 'dovecot.syscalls', 'line'],
78 'lines': [
79 ['read_count', 'read', 'incremental'],
80 ['write_count', 'write', 'incremental']
66 - ]},
81 + ]
82 + },
83 'lookup': {
68 - 'options': [None, "Dovecot Lookups", 'number/s', 'lookups', 'dovecot.lookup', 'stacked'],
84 + 'options': [None, 'Dovecot Lookups', 'number/s', 'lookups', 'dovecot.lookup', 'stacked'],
85 'lines': [
86 ['mail_lookup_path', 'path', 'incremental'],
87 ['mail_lookup_attr', 'attr', 'incremental']
72 - ]},
88 + ]
89 + },
90 'cache': {
74 - 'options': [None, "Dovecot Cache Hits", 'hits/s', 'cache', 'dovecot.cache', 'line'],
91 + 'options': [None, 'Dovecot Cache Hits', 'hits/s', 'cache', 'dovecot.cache', 'line'],
92 'lines': [
93 ['mail_cache_hits', 'hits', 'incremental']
77 - ]},
94 + ]
95 + },
96 'auth': {
79 - 'options': [None, "Dovecot Authentications", 'attempts', 'logins', 'dovecot.auth', 'stacked'],
97 + 'options': [None, 'Dovecot Authentications', 'attempts', 'logins', 'dovecot.auth', 'stacked'],
98 'lines': [
99 ['auth_successes', 'ok', 'absolute'],
100 ['auth_failures', 'failed', 'absolute']
83 - ]},
101 + ]
102 + },
103 'auth_cache': {
85 - 'options': [None, "Dovecot Authentication Cache", 'number', 'cache', 'dovecot.auth_cache', 'stacked'],
104 + 'options': [None, 'Dovecot Authentication Cache', 'number', 'cache', 'dovecot.auth_cache', 'stacked'],
105 'lines': [
106 ['auth_cache_hits', 'hit', 'absolute'],
107 ['auth_cache_misses', 'miss', 'absolute']
89 - ]}
108 + ]
109 + }
110 }
111
112
113 class Service(SocketService):
114 def __init__(self, configuration=None, name=None):
115 SocketService.__init__(self, configuration=configuration, name=name)
96 - self.request = "EXPORT\tglobal\r\n"
116 + self.request = 'EXPORT\tglobal\r\n'
117 self.host = None # localhost
118 self.port = None # 24242
119 # self._keep_alive = True
100 - self.unix_socket = "/var/run/dovecot/stats"
120 + self.unix_socket = '/var/run/dovecot/stats'
121 self.order = ORDER
122 self.definitions = CHARTS
123
@@ -112,7 +132,7 @@ class Service(SocketService):
132 return None
133
134 if raw is None:
115 - self.debug("dovecot returned no data")
135 + self.debug('dovecot returned no data')
136 return None
137
138 data = raw.split('\n')[:2]
python.d/elasticsearch.chart.py
+86 -47
@@ -110,18 +110,22 @@ HEALTH_STATS = [
110 ]
111
112 LATENCY = {
113 - 'query_latency':
114 - {'total': 'indices_search_query_total',
115 - 'spent_time': 'indices_search_query_time_in_millis'},
116 - 'fetch_latency':
117 - {'total': 'indices_search_fetch_total',
118 - 'spent_time': 'indices_search_fetch_time_in_millis'},
119 - 'indexing_latency':
120 - {'total': 'indices_indexing_index_total',
121 - 'spent_time': 'indices_indexing_index_time_in_millis'},
122 - 'flushing_latency':
123 - {'total': 'indices_flush_total',
124 - 'spent_time': 'indices_flush_total_time_in_millis'}
113 + 'query_latency': {
114 + 'total': 'indices_search_query_total',
115 + 'spent_time': 'indices_search_query_time_in_millis'
116 + },
117 + 'fetch_latency': {
118 + 'total': 'indices_search_fetch_total',
119 + 'spent_time': 'indices_search_fetch_time_in_millis'
120 + },
121 + 'indexing_latency': {
122 + 'total': 'indices_indexing_index_total',
123 + 'spent_time': 'indices_indexing_index_time_in_millis'
124 + },
125 + 'flushing_latency': {
126 + 'total': 'indices_flush_total',
127 + 'spent_time': 'indices_flush_total_time_in_millis'
128 + }
129 }
130
131 # charts order (can be overridden if you want less charts, or different order)
@@ -170,27 +174,31 @@ CHARTS = {
174 'lines': [
175 ['indices_search_query_total', 'queries', 'incremental'],
176 ['indices_search_fetch_total', 'fetches', 'incremental']
173 - ]},
177 + ]
178 + },
179 'search_performance_current': {
180 'options': [None, 'Queries and Fetches In Progress', 'number of', 'search performance',
181 'elastic.search_performance_current', 'stacked'],
182 'lines': [
183 ['indices_search_query_current', 'queries', 'absolute'],
184 ['indices_search_fetch_current', 'fetches', 'absolute']
180 - ]},
185 + ]
186 + },
187 'search_performance_time': {
188 'options': [None, 'Time Spent On Queries And Fetches', 'seconds', 'search performance',
189 'elastic.search_performance_time', 'stacked'],
190 'lines': [
191 ['indices_search_query_time_in_millis', 'query', 'incremental', 1, 1000],
192 ['indices_search_fetch_time_in_millis', 'fetch', 'incremental', 1, 1000]
187 - ]},
193 + ]
194 + },
195 'search_latency': {
196 'options': [None, 'Query And Fetch Latency', 'ms', 'search performance', 'elastic.search_latency', 'stacked'],
197 'lines': [
198 ['query_latency', 'query', 'absolute', 1, 1000],
199 ['fetch_latency', 'fetch', 'absolute', 1, 1000]
193 - ]},
200 + ]
201 + },
202 'index_performance_total': {
203 'options': [None, 'Indexed Documents, Index Refreshes, Index Flushes To Disk', 'number of',
204 'indexing performance', 'elastic.index_performance_total', 'stacked'],
@@ -198,13 +206,15 @@ CHARTS = {
206 ['indices_indexing_index_total', 'indexed', 'incremental'],
207 ['indices_refresh_total', 'refreshes', 'incremental'],
208 ['indices_flush_total', 'flushes', 'incremental']
201 - ]},
209 + ]
210 + },
211 'index_performance_current': {
212 'options': [None, 'Number Of Documents Currently Being Indexed', 'currently indexed',
213 'indexing performance', 'elastic.index_performance_current', 'stacked'],
214 'lines': [
215 ['indices_indexing_index_current', 'documents', 'absolute']
207 - ]},
216 + ]
217 + },
218 'index_performance_time': {
219 'options': [None, 'Time Spent On Indexing, Refreshing, Flushing', 'seconds', 'indexing performance',
220 'elastic.index_performance_time', 'stacked'],
@@ -212,40 +222,46 @@ CHARTS = {
222 ['indices_indexing_index_time_in_millis', 'indexing', 'incremental', 1, 1000],
223 ['indices_refresh_total_time_in_millis', 'refreshing', 'incremental', 1, 1000],
224 ['indices_flush_total_time_in_millis', 'flushing', 'incremental', 1, 1000]
215 - ]},
225 + ]
226 + },
227 'index_latency': {
228 'options': [None, 'Indexing And Flushing Latency', 'ms', 'indexing performance',
229 'elastic.index_latency', 'stacked'],
230 'lines': [
231 ['indexing_latency', 'indexing', 'absolute', 1, 1000],
232 ['flushing_latency', 'flushing', 'absolute', 1, 1000]
222 - ]},
233 + ]
234 + },
235 'index_translog_operations': {
236 'options': [None, 'Translog Operations', 'count', 'translog',
237 'elastic.index_translog_operations', 'area'],
238 'lines': [
239 ['indices_translog_operations', 'total', 'absolute'],
240 ['indices_translog_uncommitted_operations', 'uncommited', 'absolute']
229 - ]},
241 + ]
242 + },
243 'index_translog_size': {
244 'options': [None, 'Translog Size', 'MB', 'translog',
245 'elastic.index_translog_size', 'area'],
246 'lines': [
247 ['indices_translog_size_in_bytes', 'total', 'absolute', 1, 1048567],
248 ['indices_translog_uncommitted_size_in_bytes', 'uncommited', 'absolute', 1, 1048567]
236 - ]},
249 + ]
250 + },
251 'index_segments_count': {
252 'options': [None, 'Total Number Of Indices Segments', 'count', 'indices segments',
253 'elastic.index_segments_count', 'line'],
254 'lines': [
255 ['indices_segments_count', 'segments', 'absolute']
242 - ]},
256 + ]
257 + },
258 'index_segments_memory_writer': {
259 'options': [None, 'Index Writer Memory Usage', 'MB', 'indices segments',
260 'elastic.index_segments_memory_writer', 'area'],
261 'lines': [
262 ['indices_segments_index_writer_memory_in_bytes', 'total', 'absolute', 1, 1048567]
248 - ]},
263 + ]
264 + },
265 'index_segments_memory': {
266 'options': [None, 'Indices Segments Memory Usage', 'MB', 'indices segments',
267 'elastic.index_segments_memory', 'stacked'],
@@ -258,54 +274,62 @@ CHARTS = {
274 ['indices_segments_doc_values_memory_in_bytes', 'doc values', 'absolute', 1, 1048567],
275 ['indices_segments_version_map_memory_in_bytes', 'version map', 'absolute', 1, 1048567],
276 ['indices_segments_fixed_bit_set_memory_in_bytes', 'fixed bit set', 'absolute', 1, 1048567]
261 - ]},
277 + ]
278 + },
279 'jvm_mem_heap': {
280 'options': [None, 'JVM Heap Percentage Currently in Use', 'percent', 'memory usage and gc',
281 'elastic.jvm_heap', 'area'],
282 'lines': [
283 ['jvm_mem_heap_used_percent', 'inuse', 'absolute']
267 - ]},
284 + ]
285 + },
286 'jvm_mem_heap_bytes': {
287 'options': [None, 'JVM Heap Commit And Usage', 'MB', 'memory usage and gc',
288 'elastic.jvm_heap_bytes', 'area'],
289 'lines': [
290 ['jvm_mem_heap_committed_in_bytes', 'commited', 'absolute', 1, 1048576],
291 ['jvm_mem_heap_used_in_bytes', 'used', 'absolute', 1, 1048576]
274 - ]},
292 + ]
293 + },
294 'jvm_buffer_pool_count': {
295 'options': [None, 'JVM Buffers', 'count', 'memory usage and gc',
296 'elastic.jvm_buffer_pool_count', 'line'],
297 'lines': [
298 ['jvm_buffer_pools_direct_count', 'direct', 'absolute'],
299 ['jvm_buffer_pools_mapped_count', 'mapped', 'absolute']
281 - ]},
300 + ]
301 + },
302 'jvm_direct_buffers_memory': {
303 'options': [None, 'JVM Direct Buffers Memory', 'MB', 'memory usage and gc',
304 'elastic.jvm_direct_buffers_memory', 'area'],
305 'lines': [
306 ['jvm_buffer_pools_direct_used_in_bytes', 'used', 'absolute', 1, 1048567],
307 ['jvm_buffer_pools_direct_total_capacity_in_bytes', 'total capacity', 'absolute', 1, 1048567]
288 - ]},
308 + ]
309 + },
310 'jvm_mapped_buffers_memory': {
311 'options': [None, 'JVM Mapped Buffers Memory', 'MB', 'memory usage and gc',
312 'elastic.jvm_mapped_buffers_memory', 'area'],
313 'lines': [
314 ['jvm_buffer_pools_mapped_used_in_bytes', 'used', 'absolute', 1, 1048567],
315 ['jvm_buffer_pools_mapped_total_capacity_in_bytes', 'total capacity', 'absolute', 1, 1048567]
295 - ]},
316 + ]
317 + },
318 'jvm_gc_count': {
319 'options': [None, 'Garbage Collections', 'counts', 'memory usage and gc', 'elastic.gc_count', 'stacked'],
320 'lines': [
321 ['jvm_gc_collectors_young_collection_count', 'young', 'incremental'],
322 ['jvm_gc_collectors_old_collection_count', 'old', 'incremental']
301 - ]},
323 + ]
324 + },
325 'jvm_gc_time': {
326 'options': [None, 'Time Spent On Garbage Collections', 'ms', 'memory usage and gc',
327 'elastic.gc_time', 'stacked'],
328 'lines': [
329 ['jvm_gc_collectors_young_collection_time_in_millis', 'young', 'incremental'],
330 ['jvm_gc_collectors_old_collection_time_in_millis', 'old', 'incremental']
308 - ]},
331 + ]
332 + },
333 'thread_pool_queued': {
334 'options': [None, 'Number Of Queued Threads In Thread Pool', 'queued threads', 'queues and rejections',
335 'elastic.thread_pool_queued', 'stacked'],
@@ -315,7 +339,8 @@ CHARTS = {
339 ['thread_pool_index_queue', 'index', 'absolute'],
340 ['thread_pool_search_queue', 'search', 'absolute'],
341 ['thread_pool_merge_queue', 'merge', 'absolute']
318 - ]},
342 + ]
343 + },
344 'thread_pool_rejected': {
345 'options': [None, 'Rejected Threads In Thread Pool', 'rejected threads', 'queues and rejections',
346 'elastic.thread_pool_rejected', 'stacked'],
@@ -325,19 +350,22 @@ CHARTS = {
350 ['thread_pool_index_rejected', 'index', 'absolute'],
351 ['thread_pool_search_rejected', 'search', 'absolute'],
352 ['thread_pool_merge_rejected', 'merge', 'absolute']
328 - ]},
353 + ]
354 + },
355 'fielddata_cache': {
356 'options': [None, 'Fielddata Cache', 'MB', 'fielddata cache', 'elastic.fielddata_cache', 'line'],
357 'lines': [
358 ['indices_fielddata_memory_size_in_bytes', 'cache', 'absolute', 1, 1048576]
333 - ]},
359 + ]
360 + },
361 'fielddata_evictions_tripped': {
362 'options': [None, 'Fielddata Evictions And Circuit Breaker Tripped Count', 'number of events',
363 'fielddata cache', 'elastic.fielddata_evictions_tripped', 'line'],
364 'lines': [
365 ['indices_fielddata_evictions', 'evictions', 'incremental'],
366 ['indices_fielddata_tripped', 'tripped', 'incremental']
340 - ]},
367 + ]
368 + },
369 'cluster_health_nodes': {
370 'options': [None, 'Nodes And Tasks Statistics', 'units', 'cluster health API',
371 'elastic.cluster_health_nodes', 'stacked'],
@@ -346,7 +374,8 @@ CHARTS = {
374 ['number_of_data_nodes', 'data_nodes', 'absolute'],
375 ['number_of_pending_tasks', 'pending_tasks', 'absolute'],
376 ['number_of_in_flight_fetch', 'in_flight_fetch', 'absolute']
349 - ]},
377 + ]
378 + },
379 'cluster_health_status': {
380 'options': [None, 'Cluster Status', 'status', 'cluster health API',
381 'elastic.cluster_health_status', 'area'],
@@ -357,7 +386,8 @@ CHARTS = {
386 ['status_foo2', None, 'absolute'],
387 ['status_foo3', None, 'absolute'],
388 ['status_yellow', 'yellow', 'absolute']
360 - ]},
389 + ]
390 + },
391 'cluster_health_shards': {
392 'options': [None, 'Shards Statistics', 'shards', 'cluster health API',
393 'elastic.cluster_health_shards', 'stacked'],
@@ -368,7 +398,8 @@ CHARTS = {
398 ['delayed_unassigned_shards', 'delayed_unassigned', 'absolute'],
399 ['initializing_shards', 'initializing', 'absolute'],
400 ['active_shards_percent_as_number', 'active_percent', 'absolute']
371 - ]},
401 + ]
402 + },
403 'cluster_stats_nodes': {
404 'options': [None, 'Nodes Statistics', 'nodes', 'cluster stats API',
405 'elastic.cluster_nodes', 'stacked'],
@@ -378,52 +409,60 @@ CHARTS = {
409 ['nodes_count_total', 'total', 'absolute'],
410 ['nodes_count_master_only', 'master_only', 'absolute'],
411 ['nodes_count_client', 'client', 'absolute']
381 - ]},
412 + ]
413 + },
414 'cluster_stats_query_cache': {
415 'options': [None, 'Query Cache Statistics', 'queries', 'cluster stats API',
416 'elastic.cluster_query_cache', 'stacked'],
417 'lines': [
418 ['indices_query_cache_hit_count', 'hit', 'incremental'],
419 ['indices_query_cache_miss_count', 'miss', 'incremental']
388 - ]},
420 + ]
421 + },
422 'cluster_stats_docs': {
423 'options': [None, 'Docs Statistics', 'count', 'cluster stats API',
424 'elastic.cluster_docs', 'line'],
425 'lines': [
426 ['indices_docs_count', 'docs', 'absolute']
394 - ]},
427 + ]
428 + },
429 'cluster_stats_store': {
430 'options': [None, 'Store Statistics', 'MB', 'cluster stats API',
431 'elastic.cluster_store', 'line'],
432 'lines': [
433 ['indices_store_size_in_bytes', 'size', 'absolute', 1, 1048567]
400 - ]},
434 + ]
435 + },
436 'cluster_stats_indices_shards': {
437 'options': [None, 'Indices And Shards Statistics', 'count', 'cluster stats API',
438 'elastic.cluster_indices_shards', 'stacked'],
439 'lines': [
440 ['indices_count', 'indices', 'absolute'],
441 ['indices_shards_total', 'shards', 'absolute']
407 - ]},
442 + ]
443 + },
444 'host_metrics_transport': {
445 'options': [None, 'Cluster Communication Transport Metrics', 'kilobit/s', 'host metrics',
446 'elastic.host_transport', 'area'],
447 'lines': [
448 ['transport_rx_size_in_bytes', 'in', 'incremental', 8, 1000],
449 ['transport_tx_size_in_bytes', 'out', 'incremental', -8, 1000]
414 - ]},
450 + ]
451 + },
452 'host_metrics_file_descriptors': {
453 'options': [None, 'Available File Descriptors In Percent', 'percent', 'host metrics',
454 'elastic.host_descriptors', 'area'],
455 'lines': [
456 ['file_descriptors_used', 'used', 'absolute', 1, 10]
420 - ]},
457 + ]
458 + },
459 'host_metrics_http': {
460 'options': [None, 'Opened HTTP Connections', 'connections', 'host metrics',
461 'elastic.host_http_connections', 'line'],
462 'lines': [
463 ['http_current_open', 'opened', 'absolute', 1, 1]
426 - ]}
464 + ]
465 + }
466 }
467
468
python.d/exim.chart.py
+4 -3
@@ -15,17 +15,18 @@ ORDER = ['qemails']
15
16 CHARTS = {
17 'qemails': {
18 - 'options': [None, "Exim Queue Emails", "emails", 'queue', 'exim.qemails', 'line'],
18 + 'options': [None, 'Exim Queue Emails', 'emails', 'queue', 'exim.qemails', 'line'],
19 'lines': [
20 ['emails', None, 'absolute']
21 - ]}
21 + ]
22 + }
23 }
24
25
26 class Service(ExecutableService):
27 def __init__(self, configuration=None, name=None):
28 ExecutableService.__init__(self, configuration=configuration, name=name)
28 - self.command = "exim -bpc"
29 + self.command = 'exim -bpc'
30 self.order = ORDER
31 self.definitions = CHARTS
32
python.d/fail2ban.chart.py
+27 -30
@@ -24,19 +24,16 @@ def charts(jails):
24 """
25
26 ch = {
27 - ORDER[0]:
28 - {
27 + ORDER[0]: {
28 'options':
29 [None, 'Jails Ban Rate', 'bans/s', 'bans', 'jail.bans', 'line'],
30 'lines': []
32 - },
33 - ORDER[1]:
34 - {
35 - 'options':
36 - [None, 'Banned IPs (since the last restart of netdata)', 'IPs','in jail', 'jail.in_jail', 'line'],
37 - 'lines':
38 - []
39 - },
31 + },
32 + ORDER[1]: {
33 + 'options': [None, 'Banned IPs (since the last restart of netdata)', 'IPs', 'in jail',
34 + 'jail.in_jail', 'line'],
35 + 'lines': []
36 + },
37 }
38 for jail in jails:
39 ch[ORDER[0]]['lines'].append([jail, jail, 'incremental'])
@@ -53,7 +50,7 @@ RE_JAILS = re.compile(r'\[([a-zA-Z0-9_-]+)\][^\[\]]+?enabled\s+= (true|false)')
50 RE_DATA = re.compile(r'\[(?P<jail>[A-Za-z-_0-9]+)\] (?P<action>Unban|Ban) (?P<ip>[a-f0-9.:]+)')
51
52 DEFAULT_JAILS = [
56 - "ssh",
53 + 'ssh',
54 ]
55
56
@@ -76,8 +73,8 @@ class Service(LogService):
73 """
74 :return: bool
75 """
79 - if not self.conf_path.endswith((".conf", ".local")):
80 - self.error("{0} is a wrong conf path name, must be *.conf or *.local".format(self.conf_path))
76 + if not self.conf_path.endswith(('.conf', '.local')):
77 + self.error('{0} is a wrong conf path name, must be *.conf or *.local'.format(self.conf_path))
78 return False
79
80 if not os.access(self.log_path, os.R_OK):
@@ -91,7 +88,7 @@ class Service(LogService):
88 self.monitoring_jails = self.jails_auto_detection()
89 for jail in self.monitoring_jails:
90 self.data[jail] = 0
94 - self.data["{0}_in_jail".format(jail)] = 0
91 + self.data['{0}_in_jail'.format(jail)] = 0
92
93 self.definitions = charts(self.monitoring_jails)
94 self.info('monitoring jails: {0}'.format(self.monitoring_jails))
@@ -115,20 +112,20 @@ class Service(LogService):
112
113 match = match.groupdict()
114
118 - if match["jail"] not in self.monitoring_jails:
115 + if match['jail'] not in self.monitoring_jails:
116 continue
117
118 jail, action, ip = match['jail'], match['action'], match['ip']
119
123 - if action == "Ban":
120 + if action == 'Ban':
121 self.data[jail] += 1
122 if ip not in self.banned_ips[jail]:
123 self.banned_ips[jail].add(ip)
127 - self.data["{0}_in_jail".format(jail)] += 1
124 + self.data['{0}_in_jail'.format(jail)] += 1
125 else:
126 if ip in self.banned_ips[jail]:
127 self.banned_ips[jail].remove(ip)
131 - self.data["{0}_in_jail".format(jail)] -= 1
128 + self.data['{0}_in_jail'.format(jail)] -= 1
129
130 return self.data
131
@@ -137,28 +134,28 @@ class Service(LogService):
134 :return: list
135 """
136 if not os.path.isdir(dir_path):
140 - self.error("{0} is not a directory".format(dir_path))
137 + self.error('{0} is not a directory'.format(dir_path))
138 return list()
139
143 - return glob("{0}/*.{1}".format(self.conf_dir, suffix))
140 + return glob('{0}/*.{1}'.format(self.conf_dir, suffix))
141
142 def get_jails_from_file(self, file_path):
143 """
144 :return: list
145 """
146 if not os.access(file_path, os.R_OK):
150 - self.error("{0} is not readable or not exist".format(file_path))
147 + self.error('{0} is not readable or not exist'.format(file_path))
148 return list()
149
150 with open(file_path, 'rt') as f:
151 lines = f.readlines()
155 - raw = " ".join(line for line in lines if line.startswith(('[', 'enabled')))
152 + raw = ' '.join(line for line in lines if line.startswith(('[', 'enabled')))
153
154 match = RE_JAILS.findall(raw)
155 # Result: [('ssh', 'true'), ('dropbear', 'true'), ('pam-generic', 'true'), ...]
156
157 if not match:
161 - self.debug("{0} parse failed".format(file_path))
158 + self.debug('{0} parse failed'.format(file_path))
159 return list()
160
161 return match
@@ -176,12 +173,12 @@ class Service(LogService):
173 """
174 jails_files, all_jails, active_jails = list(), list(), list()
175
179 - jails_files.append("{0}.conf".format(self.conf_path.rsplit(".")[0]))
180 - jails_files.extend(self.get_files_from_dir(self.conf_dir, "conf"))
181 - jails_files.append("{0}.local".format(self.conf_path.rsplit(".")[0]))
182 - jails_files.extend(self.get_files_from_dir(self.conf_dir, "local"))
176 + jails_files.append('{0}.conf'.format(self.conf_path.rsplit('.')[0]))
177 + jails_files.extend(self.get_files_from_dir(self.conf_dir, 'conf'))
178 + jails_files.append('{0}.local'.format(self.conf_path.rsplit('.')[0]))
179 + jails_files.extend(self.get_files_from_dir(self.conf_dir, 'local'))
180
184 - self.debug("config files to parse: {0}".format(jails_files))
181 + self.debug('config files to parse: {0}'.format(jails_files))
182
183 for f in jails_files:
184 all_jails.extend(self.get_jails_from_file(f))
@@ -192,9 +189,9 @@ class Service(LogService):
189 if name in exclude:
190 continue
191
195 - if status == "true" and name not in active_jails:
192 + if status == 'true' and name not in active_jails:
193 active_jails.append(name)
197 - elif status == "false" and name in active_jails:
194 + elif status == 'false' and name in active_jails:
195 active_jails.remove(name)
196
197 return active_jails or DEFAULT_JAILS
python.d/freeradius.chart.py
+13 -10
@@ -21,7 +21,7 @@ ORDER = ['authentication', 'accounting', 'proxy-auth', 'proxy-acct']
21
22 CHARTS = {
23 'authentication': {
24 - 'options': [None, "Authentication", "packets/s", 'Authentication', 'freerad.auth', 'line'],
24 + 'options': [None, 'Authentication', 'packets/s', 'Authentication', 'freerad.auth', 'line'],
25 'lines': [
26 ['access-accepts', None, 'incremental'],
27 ['access-rejects', None, 'incremental'],
@@ -30,9 +30,10 @@ CHARTS = {
30 ['auth-invalid-requests', 'invalid-requests', 'incremental'],
31 ['auth-malformed-requests', 'malformed-requests', 'incremental'],
32 ['auth-unknown-types', 'unknown-types', 'incremental']
33 - ]},
33 + ]
34 + },
35 'accounting': {
35 - 'options': [None, "Accounting", "packets/s", 'Accounting', 'freerad.acct', 'line'],
36 + 'options': [None, 'Accounting', 'packets/s', 'Accounting', 'freerad.acct', 'line'],
37 'lines': [
38 ['accounting-requests', 'requests', 'incremental'],
39 ['accounting-responses', 'responses', 'incremental'],
@@ -41,9 +42,10 @@ CHARTS = {
42 ['acct-invalid-requests', 'invalid-requests', 'incremental'],
43 ['acct-malformed-requests', 'malformed-requests', 'incremental'],
44 ['acct-unknown-types', 'unknown-types', 'incremental']
44 - ]},
45 + ]
46 + },
47 'proxy-auth': {
46 - 'options': [None, "Proxy Authentication", "packets/s", 'Authentication', 'freerad.proxy.auth', 'line'],
48 + 'options': [None, 'Proxy Authentication', 'packets/s', 'Authentication', 'freerad.proxy.auth', 'line'],
49 'lines': [
50 ['proxy-access-accepts', 'access-accepts', 'incremental'],
51 ['proxy-access-rejects', 'access-rejects', 'incremental'],
@@ -52,9 +54,10 @@ CHARTS = {
54 ['proxy-auth-invalid-requests', 'invalid-requests', 'incremental'],
55 ['proxy-auth-malformed-requests', 'malformed-requests', 'incremental'],
56 ['proxy-auth-unknown-types', 'unknown-types', 'incremental']
55 - ]},
57 + ]
58 + },
59 'proxy-acct': {
57 - 'options': [None, "Proxy Accounting", "packets/s", 'Accounting', 'freerad.proxy.acct', 'line'],
60 + 'options': [None, 'Proxy Accounting', 'packets/s', 'Accounting', 'freerad.proxy.acct', 'line'],
61 'lines': [
62 ['proxy-accounting-requests', 'requests', 'incremental'],
63 ['proxy-accounting-responses', 'responses', 'incremental'],
@@ -63,8 +66,8 @@ CHARTS = {
66 ['proxy-acct-invalid-requests', 'invalid-requests', 'incremental'],
67 ['proxy-acct-malformed-requests', 'malformed-requests', 'incremental'],
68 ['proxy-acct-unknown-types', 'unknown-types', 'incremental']
66 - ]}
67 -
69 + ]
70 + }
71 }
72
73
@@ -106,7 +109,7 @@ class Service(SimpleService):
109 """
110 result = self._get_raw_data()
111 return dict([(elem[0].lower(), int(elem[1])) for elem in findall(r'((?<=-)[AP][a-zA-Z-]+) = (\d+)', result)])
109 -
112 +
113 def _get_raw_data(self):
114 """
115 The following code is equivalent to
python.d/go_expvar.chart.py
+14 -7
@@ -21,43 +21,50 @@ MEMSTATS_CHARTS = {
21 'lines': [
22 ['memstats_heap_alloc', 'alloc', 'absolute', 1, 1024],
23 ['memstats_heap_inuse', 'inuse', 'absolute', 1, 1024]
24 - ]},
24 + ]
25 + },
26 'memstats_stack': {
27 'options': ['stack', 'memory: size of stack memory structures', 'kB', 'memstats',
28 'expvar.memstats.stack', 'line'],
29 'lines': [
30 ['memstats_stack_inuse', 'inuse', 'absolute', 1, 1024]
30 - ]},
31 + ]
32 + },
33 'memstats_mspan': {
34 'options': ['mspan', 'memory: size of mspan memory structures', 'kB', 'memstats',
35 'expvar.memstats.mspan', 'line'],
36 'lines': [
37 ['memstats_mspan_inuse', 'inuse', 'absolute', 1, 1024]
36 - ]},
38 + ]
39 + },
40 'memstats_mcache': {
41 'options': ['mcache', 'memory: size of mcache memory structures', 'kB', 'memstats',
42 'expvar.memstats.mcache', 'line'],
43 'lines': [
44 ['memstats_mcache_inuse', 'inuse', 'absolute', 1, 1024]
42 - ]},
45 + ]
46 + },
47 'memstats_live_objects': {
48 'options': ['live_objects', 'memory: number of live objects', 'objects', 'memstats',
49 'expvar.memstats.live_objects', 'line'],
50 'lines': [
51 ['memstats_live_objects', 'live']
48 - ]},
52 + ]
53 + },
54 'memstats_sys': {
55 'options': ['sys', 'memory: size of reserved virtual address space', 'kB', 'memstats',
56 'expvar.memstats.sys', 'line'],
57 'lines': [
58 ['memstats_sys', 'sys', 'absolute', 1, 1024]
54 - ]},
59 + ]
60 + },
61 'memstats_gc_pauses': {
62 'options': ['gc_pauses', 'memory: average duration of GC pauses', 'ns', 'memstats',
63 'expvar.memstats.gc_pauses', 'line'],
64 'lines': [
65 ['memstats_gc_pauses', 'avg']
60 - ]},
66 + ]
67 + }
68 }
69
70 MEMSTATS_ORDER = ['memstats_heap', 'memstats_stack', 'memstats_mspan', 'memstats_mcache',
python.d/haproxy.chart.py
+136 -106
@@ -21,155 +21,185 @@ priority = 60000
21 retries = 60
22
23 # charts order (can be overridden if you want less charts, or different order)
24 -ORDER = ['fbin', 'fbout', 'fscur', 'fqcur',
25 - 'fhrsp_1xx', 'fhrsp_2xx', 'fhrsp_3xx', 'fhrsp_4xx', 'fhrsp_5xx', 'fhrsp_other', 'fhrsp_total',
26 - 'bbin', 'bbout', 'bscur', 'bqcur',
27 - 'bhrsp_1xx', 'bhrsp_2xx', 'bhrsp_3xx', 'bhrsp_4xx', 'bhrsp_5xx', 'bhrsp_other', 'bhrsp_total',
28 - 'bqtime', 'bttime', 'brtime', 'bctime',
29 - 'health_sup', 'health_sdown', 'health_bdown', 'health_idle']
24 +ORDER = [
25 + 'fbin',
26 + 'fbout',
27 + 'fscur',
28 + 'fqcur',
29 + 'fhrsp_1xx',
30 + 'fhrsp_2xx',
31 + 'fhrsp_3xx',
32 + 'fhrsp_4xx',
33 + 'fhrsp_5xx',
34 + 'fhrsp_other',
35 + 'fhrsp_total',
36 + 'bbin',
37 + 'bbout',
38 + 'bscur',
39 + 'bqcur',
40 + 'bhrsp_1xx',
41 + 'bhrsp_2xx',
42 + 'bhrsp_3xx',
43 + 'bhrsp_4xx',
44 + 'bhrsp_5xx',
45 + 'bhrsp_other',
46 + 'bhrsp_total',
47 + 'bqtime',
48 + 'bttime',
49 + 'brtime',
50 + 'bctime',
51 + 'health_sup',
52 + 'health_sdown',
53 + 'health_bdown',
54 + 'health_idle'
55 +]
56
57 CHARTS = {
58 'fbin': {
33 - 'options': [None, "Kilobytes In", "KB/s", 'frontend', 'haproxy_f.bin', 'line'],
34 - 'lines': [
35 - ]},
59 + 'options': [None, 'Kilobytes In', 'KB/s', 'frontend', 'haproxy_f.bin', 'line'],
60 + 'lines': []
61 + },
62 'fbout': {
37 - 'options': [None, "Kilobytes Out", "KB/s", 'frontend', 'haproxy_f.bout', 'line'],
38 - 'lines': [
39 - ]},
63 + 'options': [None, 'Kilobytes Out', 'KB/s', 'frontend', 'haproxy_f.bout', 'line'],
64 + 'lines': []
65 + },
66 'fscur': {
41 - 'options': [None, "Sessions Active", "sessions", 'frontend', 'haproxy_f.scur', 'line'],
42 - 'lines': [
43 - ]},
67 + 'options': [None, 'Sessions Active', 'sessions', 'frontend', 'haproxy_f.scur', 'line'],
68 + 'lines': []
69 + },
70 'fqcur': {
45 - 'options': [None, "Session In Queue", "sessions", 'frontend', 'haproxy_f.qcur', 'line'],
46 - 'lines': [
47 - ]},
71 + 'options': [None, 'Session In Queue', 'sessions', 'frontend', 'haproxy_f.qcur', 'line'],
72 + 'lines': []
73 + },
74 'fhrsp_1xx': {
49 - 'options': [None, "HTTP responses with 1xx code", "responses/s", 'frontend', 'haproxy_f.hrsp_1xx', 'line'],
50 - 'lines': [
51 - ]},
75 + 'options': [None, 'HTTP responses with 1xx code', 'responses/s', 'frontend', 'haproxy_f.hrsp_1xx', 'line'],
76 + 'lines': []
77 + },
78 'fhrsp_2xx': {
53 - 'options': [None, "HTTP responses with 2xx code", "responses/s", 'frontend', 'haproxy_f.hrsp_2xx', 'line'],
54 - 'lines': [
55 - ]},
79 + 'options': [None, 'HTTP responses with 2xx code', 'responses/s', 'frontend', 'haproxy_f.hrsp_2xx', 'line'],
80 + 'lines': []
81 + },
82 'fhrsp_3xx': {
57 - 'options': [None, "HTTP responses with 3xx code", "responses/s", 'frontend', 'haproxy_f.hrsp_3xx', 'line'],
58 - 'lines': [
59 - ]},
83 + 'options': [None, 'HTTP responses with 3xx code', 'responses/s', 'frontend', 'haproxy_f.hrsp_3xx', 'line'],
84 + 'lines': []
85 + },
86 'fhrsp_4xx': {
61 - 'options': [None, "HTTP responses with 4xx code", "responses/s", 'frontend', 'haproxy_f.hrsp_4xx', 'line'],
62 - 'lines': [
63 - ]},
87 + 'options': [None, 'HTTP responses with 4xx code', 'responses/s', 'frontend', 'haproxy_f.hrsp_4xx', 'line'],
88 + 'lines': []
89 + },
90 'fhrsp_5xx': {
65 - 'options': [None, "HTTP responses with 5xx code", "responses/s", 'frontend', 'haproxy_f.hrsp_5xx', 'line'],
66 - 'lines': [
67 - ]},
91 + 'options': [None, 'HTTP responses with 5xx code', 'responses/s', 'frontend', 'haproxy_f.hrsp_5xx', 'line'],
92 + 'lines': []
93 + },
94 'fhrsp_other': {
69 - 'options': [None, "HTTP responses with other codes (protocol error)", "responses/s", 'frontend', 'haproxy_f.hrsp_other', 'line'],
70 - 'lines': [
71 - ]},
95 + 'options': [None, 'HTTP responses with other codes (protocol error)', 'responses/s', 'frontend',
96 + 'haproxy_f.hrsp_other', 'line'],
97 + 'lines': []
98 + },
99 'fhrsp_total': {
73 - 'options': [None, "HTTP responses", "responses", 'frontend', 'haproxy_f.hrsp_total', 'line'],
74 - 'lines': [
75 - ]},
100 + 'options': [None, 'HTTP responses', 'responses', 'frontend', 'haproxy_f.hrsp_total', 'line'],
101 + 'lines': []
102 + },
103 'bbin': {
77 - 'options': [None, "Kilobytes In", "KB/s", 'backend', 'haproxy_b.bin', 'line'],
78 - 'lines': [
79 - ]},
104 + 'options': [None, 'Kilobytes In', 'KB/s', 'backend', 'haproxy_b.bin', 'line'],
105 + 'lines': []
106 + },
107 'bbout': {
81 - 'options': [None, "Kilobytes Out", "KB/s", 'backend', 'haproxy_b.bout', 'line'],
82 - 'lines': [
83 - ]},
108 + 'options': [None, 'Kilobytes Out', 'KB/s', 'backend', 'haproxy_b.bout', 'line'],
109 + 'lines': []
110 + },
111 'bscur': {
85 - 'options': [None, "Sessions Active", "sessions", 'backend', 'haproxy_b.scur', 'line'],
86 - 'lines': [
87 - ]},
112 + 'options': [None, 'Sessions Active', 'sessions', 'backend', 'haproxy_b.scur', 'line'],
113 + 'lines': []
114 + },
115 'bqcur': {
89 - 'options': [None, "Sessions In Queue", "sessions", 'backend', 'haproxy_b.qcur', 'line'],
90 - 'lines': [
91 - ]},
116 + 'options': [None, 'Sessions In Queue', 'sessions', 'backend', 'haproxy_b.qcur', 'line'],
117 + 'lines': []
118 + },
119 'bhrsp_1xx': {
93 - 'options': [None, "HTTP responses with 1xx code", "responses/s", 'backend', 'haproxy_b.hrsp_1xx', 'line'],
94 - 'lines': [
95 - ]},
120 + 'options': [None, 'HTTP responses with 1xx code', 'responses/s', 'backend', 'haproxy_b.hrsp_1xx', 'line'],
121 + 'lines': []
122 + },
123 'bhrsp_2xx': {
97 - 'options': [None, "HTTP responses with 2xx code", "responses/s", 'backend', 'haproxy_b.hrsp_2xx', 'line'],
98 - 'lines': [
99 - ]},
124 + 'options': [None, 'HTTP responses with 2xx code', 'responses/s', 'backend', 'haproxy_b.hrsp_2xx', 'line'],
125 + 'lines': []
126 + },
127 'bhrsp_3xx': {
101 - 'options': [None, "HTTP responses with 3xx code", "responses/s", 'backend', 'haproxy_b.hrsp_3xx', 'line'],
102 - 'lines': [
103 - ]},
128 + 'options': [None, 'HTTP responses with 3xx code', 'responses/s', 'backend', 'haproxy_b.hrsp_3xx', 'line'],
129 + 'lines': []
130 + },
131 'bhrsp_4xx': {
105 - 'options': [None, "HTTP responses with 4xx code", "responses/s", 'backend', 'haproxy_b.hrsp_4xx', 'line'],
106 - 'lines': [
107 - ]},
132 + 'options': [None, 'HTTP responses with 4xx code', 'responses/s', 'backend', 'haproxy_b.hrsp_4xx', 'line'],
133 + 'lines': []
134 + },
135 'bhrsp_5xx': {
109 - 'options': [None, "HTTP responses with 5xx code", "responses/s", 'backend', 'haproxy_b.hrsp_5xx', 'line'],
110 - 'lines': [
111 - ]},
136 + 'options': [None, 'HTTP responses with 5xx code', 'responses/s', 'backend', 'haproxy_b.hrsp_5xx', 'line'],
137 + 'lines': []
138 + },
139 'bhrsp_other': {
113 - 'options': [None, "HTTP responses with other codes (protocol error)", "responses/s", 'backend',
140 + 'options': [None, 'HTTP responses with other codes (protocol error)', 'responses/s', 'backend',
141 'haproxy_b.hrsp_other', 'line'],
115 - 'lines': [
116 - ]},
142 + 'lines': []
143 + },
144 'bhrsp_total': {
118 - 'options': [None, "HTTP responses (total)", "responses/s", 'backend', 'haproxy_b.hrsp_total', 'line'],
119 - 'lines': [
120 - ]},
145 + 'options': [None, 'HTTP responses (total)', 'responses/s', 'backend', 'haproxy_b.hrsp_total', 'line'],
146 + 'lines': []
147 + },
148 'bqtime': {
122 - 'options': [None, "The average queue time over the 1024 last requests", "ms", 'backend', 'haproxy_b.qtime', 'line'],
123 - 'lines': [
124 - ]},
149 + 'options': [None, 'The average queue time over the 1024 last requests', 'ms', 'backend',
150 + 'haproxy_b.qtime', 'line'],
151 + 'lines': []
152 + },
153 'bctime': {
126 - 'options': [None, "The average connect time over the 1024 last requests", "ms", 'backend',
154 + 'options': [None, 'The average connect time over the 1024 last requests', 'ms', 'backend',
155 'haproxy_b.ctime', 'line'],
128 - 'lines': [
129 - ]},
156 + 'lines': []
157 + },
158 'brtime': {
131 - 'options': [None, "The average response time over the 1024 last requests", "ms", 'backend',
159 + 'options': [None, 'The average response time over the 1024 last requests', 'ms', 'backend',
160 'haproxy_b.rtime', 'line'],
133 - 'lines': [
134 - ]},
161 + 'lines': []
162 + },
163 'bttime': {
136 - 'options': [None, "The average total session time over the 1024 last requests", "ms", 'backend',
164 + 'options': [None, 'The average total session time over the 1024 last requests', 'ms', 'backend',
165 'haproxy_b.ttime', 'line'],
138 - 'lines': [
139 - ]},
166 + 'lines': []
167 + },
168 'health_sdown': {
141 - 'options': [None, "Backend Servers In DOWN State", "failed servers", 'health',
169 + 'options': [None, 'Backend Servers In DOWN State', 'failed servers', 'health',
170 'haproxy_hs.down', 'line'],
143 - 'lines': [
144 - ]},
171 + 'lines': []
172 + },
173 'health_sup': {
146 - 'options': [None, "Backend Servers In UP State", "health servers", 'health',
174 + 'options': [None, 'Backend Servers In UP State', 'health servers', 'health',
175 'haproxy_hs.up', 'line'],
148 - 'lines': [
149 - ]},
176 + 'lines': []
177 + },
178 'health_bdown': {
151 - 'options': [None, "Is Backend Alive? 1 = DOWN", "failed backend", 'health', 'haproxy_hb.down', 'line'],
152 - 'lines': [
153 - ]},
179 + 'options': [None, 'Is Backend Alive? 1 = DOWN', 'failed backend', 'health', 'haproxy_hb.down', 'line'],
180 + 'lines': []
181 + },
182 'health_idle': {
155 - 'options': [None, "The Ratio Of Polling Time Vs Total Time", "percent", 'health', 'haproxy.idle', 'line'],
183 + 'options': [None, 'The Ratio Of Polling Time Vs Total Time', 'percent', 'health', 'haproxy.idle', 'line'],
184 'lines': [
185 ['idle', None, 'absolute']
158 - ]}
186 + ]
187 + }
188 }
189
190
162 -METRICS = {'bin': {'algorithm': 'incremental', 'divisor': 1024},
163 - 'bout': {'algorithm': 'incremental', 'divisor': 1024},
164 - 'scur': {'algorithm': 'absolute', 'divisor': 1},
165 - 'qcur': {'algorithm': 'absolute', 'divisor': 1},
166 - 'hrsp_1xx': {'algorithm': 'incremental', 'divisor': 1},
167 - 'hrsp_2xx': {'algorithm': 'incremental', 'divisor': 1},
168 - 'hrsp_3xx': {'algorithm': 'incremental', 'divisor': 1},
169 - 'hrsp_4xx': {'algorithm': 'incremental', 'divisor': 1},
170 - 'hrsp_5xx': {'algorithm': 'incremental', 'divisor': 1},
171 - 'hrsp_other': {'algorithm': 'incremental', 'divisor': 1},
172 - }
191 +METRICS = {
192 + 'bin': {'algorithm': 'incremental', 'divisor': 1024},
193 + 'bout': {'algorithm': 'incremental', 'divisor': 1024},
194 + 'scur': {'algorithm': 'absolute', 'divisor': 1},
195 + 'qcur': {'algorithm': 'absolute', 'divisor': 1},
196 + 'hrsp_1xx': {'algorithm': 'incremental', 'divisor': 1},
197 + 'hrsp_2xx': {'algorithm': 'incremental', 'divisor': 1},
198 + 'hrsp_3xx': {'algorithm': 'incremental', 'divisor': 1},
199 + 'hrsp_4xx': {'algorithm': 'incremental', 'divisor': 1},
200 + 'hrsp_5xx': {'algorithm': 'incremental', 'divisor': 1},
201 + 'hrsp_other': {'algorithm': 'incremental', 'divisor': 1}
202 +}
203
204
205 BACKEND_METRICS = {
python.d/httpcheck.chart.py
+10 -7
@@ -36,12 +36,14 @@ CHARTS = {
36 'options': [None, 'HTTP response time', 'ms', 'response', 'httpcheck.responsetime', 'line'],
37 'lines': [
38 [HTTP_RESPONSE_TIME, 'time', 'absolute', 100, 1000]
39 - ]},
39 + ]
40 + },
41 'response_length': {
42 'options': [None, 'HTTP response body length', 'characters', 'response', 'httpcheck.responselength', 'line'],
43 'lines': [
44 [HTTP_RESPONSE_LENGTH, 'length', 'absolute']
44 - ]},
45 + ]
46 + },
47 'status': {
48 'options': [None, 'HTTP status', 'boolean', 'status', 'httpcheck.status', 'line'],
49 'lines': [
@@ -50,7 +52,8 @@ CHARTS = {
52 [HTTP_BAD_STATUS, 'bad status', 'absolute'],
53 [HTTP_TIMEOUT, 'timeout', 'absolute'],
54 [HTTP_NO_CONNECTION, 'no connection', 'absolute']
53 - ]}
55 + ]
56 + }
57 }
58
59
@@ -88,15 +91,15 @@ class Service(UrlService):
91 self.process_response(content, data, status)
92
93 except urllib3.exceptions.NewConnectionError as error:
91 - self.debug("Connection failed: {url}. Error: {error}".format(url=url, error=error))
94 + self.debug('Connection failed: {url}. Error: {error}'.format(url=url, error=error))
95 data[HTTP_NO_CONNECTION] = 1
96
97 except (urllib3.exceptions.TimeoutError, urllib3.exceptions.PoolError) as error:
95 - self.debug("Connection timed out: {url}. Error: {error}".format(url=url, error=error))
98 + self.debug('Connection timed out: {url}. Error: {error}'.format(url=url, error=error))
99 data[HTTP_TIMEOUT] = 1
100
101 except urllib3.exceptions.HTTPError as error:
99 - self.debug("Connection failed: {url}. Error: {error}".format(url=url, error=error))
102 + self.debug('Connection failed: {url}. Error: {error}'.format(url=url, error=error))
103 data[HTTP_NO_CONNECTION] = 1
104
105 except (TypeError, AttributeError) as error:
@@ -110,7 +113,7 @@ class Service(UrlService):
113 self.debug('Content: \n\n{content}\n'.format(content=content))
114 if status in self.status_codes_accepted:
115 if self.regex and self.regex.search(content) is None:
113 - self.debug("No match for regex '{regex}' found".format(regex=self.regex.pattern))
116 + self.debug('No match for regex "{regex}" found'.format(regex=self.regex.pattern))
117 data[HTTP_BAD_CONTENT] = 1
118 else:
119 data[HTTP_SUCCESS] = 1