Skip to content

Commit 97b3270

Browse files
authored
[python] make units compliant with IEC standard (netdata#4995)
* apache units fix * beanstalk * bind_rndc * boinc * ceph * chrony * couchdb * dns_query * dnsdist * dockerd * dovecot * elasticsearch by @vlvkobal <3 * example * exim * fail2ban * freeradius minor fixes * freeradius minor fixes * freeradius minor fixes * go_expvar * haproxy * hddtemp * httpcheck * icecast * ipfs * isc_dhcpd * litespeed * logind * megacli * memcached * mongodb * monit * mysql * nginx * nginx_plus * nsd * ntpd * nvidia_smi * openldap * ovpn_status * phpfm * portcheck * postfix * postgres * powerdns * proxysql * puppet * rabbitmq * redis * restroshare * samba * sensors * smartdlog * spigotmc * springboot * squid * retroshare * tomcat * retroshare * tor * traefik * traefik * unbound * uwsgi * varnish * w1sensor * web_log * ok codacy * retroshare * ipfs
1 parent 7ad91b8 commit 97b3270

File tree

62 files changed

+747
-580
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+747
-580
lines changed

collectors/python.d.plugin/apache/apache.chart.py

Lines changed: 70 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,63 +5,60 @@
55

66
from bases.FrameworkServices.UrlService import UrlService
77

8-
# default module values (can be overridden per job in `config`)
9-
# update_every = 2
10-
priority = 60000
118

12-
# default job configuration (overridden by python.d.plugin)
13-
# config = {'local': {
14-
# 'update_every': update_every,
15-
# 'retries': retries,
16-
# 'priority': priority,
17-
# 'url': 'http://www.apache.org/server-status?auto'
18-
# }}
19-
20-
# charts order (can be overridden if you want less charts, or different order)
21-
ORDER = ['requests', 'connections', 'conns_async', 'net', 'workers', 'reqpersec', 'bytespersec', 'bytesperreq']
9+
ORDER = [
10+
'requests',
11+
'connections',
12+
'conns_async',
13+
'net',
14+
'workers',
15+
'reqpersec',
16+
'bytespersec',
17+
'bytesperreq',
18+
]
2219

2320
CHARTS = {
2421
'bytesperreq': {
25-
'options': [None, 'apache Lifetime Avg. Response Size', 'bytes/request',
22+
'options': [None, 'Lifetime Avg. Request Size', 'KiB',
2623
'statistics', 'apache.bytesperreq', 'area'],
2724
'lines': [
28-
['size_req']
25+
['size_req', 'size', 'absolute', 1, 1024 * 100000]
2926
]},
3027
'workers': {
31-
'options': [None, 'apache Workers', 'workers', 'workers', 'apache.workers', 'stacked'],
28+
'options': [None, 'Workers', 'workers', 'workers', 'apache.workers', 'stacked'],
3229
'lines': [
3330
['idle'],
3431
['busy'],
3532
]},
3633
'reqpersec': {
37-
'options': [None, 'apache Lifetime Avg. Requests/s', 'requests/s', 'statistics',
34+
'options': [None, 'Lifetime Avg. Requests/s', 'requests/s', 'statistics',
3835
'apache.reqpersec', 'area'],
3936
'lines': [
40-
['requests_sec']
37+
['requests_sec', 'requests', 'absolute', 1, 100000]
4138
]},
4239
'bytespersec': {
43-
'options': [None, 'apache Lifetime Avg. Bandwidth/s', 'kilobits/s', 'statistics',
40+
'options': [None, 'Lifetime Avg. Bandwidth/s', 'kilobits/s', 'statistics',
4441
'apache.bytesperreq', 'area'],
4542
'lines': [
46-
['size_sec', None, 'absolute', 8, 1000]
43+
['size_sec', None, 'absolute', 8, 1000 * 100000]
4744
]},
4845
'requests': {
49-
'options': [None, 'apache Requests', 'requests/s', 'requests', 'apache.requests', 'line'],
46+
'options': [None, 'Requests', 'requests/s', 'requests', 'apache.requests', 'line'],
5047
'lines': [
5148
['requests', None, 'incremental']
5249
]},
5350
'net': {
54-
'options': [None, 'apache Bandwidth', 'kilobits/s', 'bandwidth', 'apache.net', 'area'],
51+
'options': [None, 'Bandwidth', 'kilobits/s', 'bandwidth', 'apache.net', 'area'],
5552
'lines': [
5653
['sent', None, 'incremental', 8, 1]
5754
]},
5855
'connections': {
59-
'options': [None, 'apache Connections', 'connections', 'connections', 'apache.connections', 'line'],
56+
'options': [None, 'Connections', 'connections', 'connections', 'apache.connections', 'line'],
6057
'lines': [
6158
['connections']
6259
]},
6360
'conns_async': {
64-
'options': [None, 'apache Async Connections', 'connections', 'connections', 'apache.conns_async', 'stacked'],
61+
'options': [None, 'Async Connections', 'connections', 'connections', 'apache.conns_async', 'stacked'],
6562
'lines': [
6663
['keepalive'],
6764
['closing'],
@@ -85,6 +82,14 @@
8582
'ConnsAsyncWriting': 'writing'
8683
}
8784

85+
FLOAT_VALUES = [
86+
'BytesPerReq',
87+
'ReqPerSec',
88+
'BytesPerSec',
89+
]
90+
91+
LIGHTTPD_MARKER = 'idle_servers'
92+
8893

8994
class Service(UrlService):
9095
def __init__(self, configuration=None, name=None):
@@ -95,20 +100,15 @@ def __init__(self, configuration=None, name=None):
95100

96101
def check(self):
97102
self._manager = self._build_manager()
103+
98104
data = self._get_data()
105+
99106
if not data:
100107
return None
101108

102-
if 'idle_servers' in data:
103-
self.module_name = 'lighttpd'
104-
for chart in self.definitions:
105-
if chart == 'workers':
106-
lines = self.definitions[chart]['lines']
107-
lines[0] = ['idle_servers', 'idle']
108-
lines[1] = ['busy_servers', 'busy']
109-
opts = self.definitions[chart]['options']
110-
opts[1] = opts[1].replace('apache', 'lighttpd')
111-
opts[4] = opts[4].replace('apache', 'lighttpd')
109+
if LIGHTTPD_MARKER in data:
110+
self.turn_into_lighttpd()
111+
112112
return True
113113

114114
def _get_data(self):
@@ -117,15 +117,44 @@ def _get_data(self):
117117
:return: dict
118118
"""
119119
raw_data = self._get_raw_data()
120+
120121
if not raw_data:
121122
return None
123+
122124
data = dict()
123125

124-
for row in raw_data.split('\n'):
125-
tmp = row.split(':')
126-
if tmp[0] in ASSIGNMENT:
127-
try:
128-
data[ASSIGNMENT[tmp[0]]] = int(float(tmp[1]))
129-
except (IndexError, ValueError):
130-
continue
126+
for line in raw_data.split('\n'):
127+
try:
128+
parse_line(line, data)
129+
except ValueError:
130+
continue
131+
131132
return data or None
133+
134+
def turn_into_lighttpd(self):
135+
self.module_name = 'lighttpd'
136+
for chart in self.definitions:
137+
if chart == 'workers':
138+
lines = self.definitions[chart]['lines']
139+
lines[0] = ['idle_servers', 'idle']
140+
lines[1] = ['busy_servers', 'busy']
141+
opts = self.definitions[chart]['options']
142+
opts[1] = opts[1].replace('apache', 'lighttpd')
143+
opts[4] = opts[4].replace('apache', 'lighttpd')
144+
145+
146+
def parse_line(line, data):
147+
parts = line.split(':')
148+
149+
if len(parts) != 2:
150+
return
151+
152+
key, value = parts[0], parts[1]
153+
154+
if key not in ASSIGNMENT:
155+
return
156+
157+
if key in FLOAT_VALUES:
158+
data[ASSIGNMENT[key]] = int((float(value) * 100000))
159+
else:
160+
data[ASSIGNMENT[key]] = int(value)

collectors/python.d.plugin/beanstalk/beanstalk.chart.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,18 @@
1212
from bases.FrameworkServices.SimpleService import SimpleService
1313
from bases.loaders import safe_load
1414

15-
# default module values (can be overridden per job in `config`)
16-
# update_every = 2
17-
priority = 60000
1815

19-
ORDER = ['cpu_usage', 'jobs_rate', 'connections_rate', 'commands_rate', 'current_tubes', 'current_jobs',
20-
'current_connections', 'binlog', 'uptime']
16+
ORDER = [
17+
'cpu_usage',
18+
'jobs_rate',
19+
'connections_rate',
20+
'commands_rate',
21+
'current_tubes',
22+
'current_jobs',
23+
'current_connections',
24+
'binlog',
25+
'uptime',
26+
]
2127

2228
CHARTS = {
2329
'cpu_usage': {

collectors/python.d.plugin/bind_rndc/bind_rndc.chart.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,15 @@
1111
from bases.collection import find_binary
1212
from bases.FrameworkServices.SimpleService import SimpleService
1313

14-
priority = 60000
14+
1515
update_every = 30
1616

17-
ORDER = ['name_server_statistics', 'incoming_queries', 'outgoing_queries', 'named_stats_size']
17+
ORDER = [
18+
'name_server_statistics',
19+
'incoming_queries',
20+
'outgoing_queries',
21+
'named_stats_size',
22+
]
1823

1924
CHARTS = {
2025
'name_server_statistics': {
@@ -43,7 +48,7 @@
4348
'lines': [
4449
]},
4550
'named_stats_size': {
46-
'options': [None, 'Named Stats File Size', 'MB', 'file size', 'bind_rndc.stats_size', 'line'],
51+
'options': [None, 'Named Stats File Size', 'MiB', 'file size', 'bind_rndc.stats_size', 'line'],
4752
'lines': [
4853
['stats_size', None, 'absolute', 1, 1 << 20]
4954
]
@@ -91,10 +96,20 @@ def __init__(self, configuration=None, name=None):
9196
self.definitions = CHARTS
9297
self.named_stats_path = self.configuration.get('named_stats_path', '/var/log/bind/named.stats')
9398
self.rndc = find_binary('rndc')
94-
self.data = dict(nms_requests=0, nms_responses=0, nms_failure=0, nms_auth=0,
95-
nms_non_auth=0, nms_nxrrset=0, nms_success=0, nms_nxdomain=0,
96-
nms_recursion=0, nms_duplicate=0, nms_rejected_queries=0,
97-
nms_dropped_queries=0)
99+
self.data = dict(
100+
nms_requests=0,
101+
nms_responses=0,
102+
nms_failure=0,
103+
nms_auth=0,
104+
nms_non_auth=0,
105+
nms_nxrrset=0,
106+
nms_success=0,
107+
nms_nxdomain=0,
108+
nms_recursion=0,
109+
nms_duplicate=0,
110+
nms_rejected_queries=0,
111+
nms_dropped_queries=0,
112+
)
98113

99114
def check(self):
100115
if not self.rndc:

collectors/python.d.plugin/boinc/boinc.chart.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@
1010
from third_party import boinc_client
1111

1212

13-
ORDER = ['tasks', 'states', 'sched_states', 'process_states']
13+
ORDER = [
14+
'tasks',
15+
'states',
16+
'sched_states',
17+
'process_states',
18+
]
1419

1520
CHARTS = {
1621
'tasks': {
@@ -141,14 +146,16 @@ def is_alive(self):
141146
def _get_data(self):
142147
if not self.is_alive():
143148
return None
149+
144150
data = dict(_DATA_TEMPLATE)
145-
results = []
151+
146152
try:
147153
results = self.client.get_tasks()
148154
except socket.error:
149155
self.error('Connection is dead')
150156
self.alive = False
151157
return None
158+
152159
for task in results:
153160
data['total'] += 1
154161
data[_TASK_MAP[task.state]] += 1
@@ -159,4 +166,5 @@ def _get_data(self):
159166
data[_PROC_MAP[task.active_task_state]] += 1
160167
except AttributeError:
161168
pass
162-
return data
169+
170+
return data or None

collectors/python.d.plugin/ceph/ceph.chart.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
except ImportError:
1010
CEPH = False
1111

12-
import os
1312
import json
13+
import os
14+
1415
from bases.FrameworkServices.SimpleService import SimpleService
1516

1617
# default module values (can be overridden per job in `config`)
1718
update_every = 10
18-
priority = 60000
1919

2020
ORDER = [
2121
'general_usage',
@@ -36,7 +36,7 @@
3636

3737
CHARTS = {
3838
'general_usage': {
39-
'options': [None, 'Ceph General Space', 'KB', 'general', 'ceph.general_usage', 'stacked'],
39+
'options': [None, 'Ceph General Space', 'KiB', 'general', 'ceph.general_usage', 'stacked'],
4040
'lines': [
4141
['general_available', 'avail', 'absolute'],
4242
['general_usage', 'used', 'absolute']
@@ -49,7 +49,7 @@
4949
]
5050
},
5151
'general_bytes': {
52-
'options': [None, 'Ceph General Read/Write Data/s', 'KB', 'general', 'ceph.general_bytes',
52+
'options': [None, 'Ceph General Read/Write Data/s', 'KiB/s', 'general', 'ceph.general_bytes',
5353
'area'],
5454
'lines': [
5555
['general_read_bytes', 'read', 'absolute', 1, 1024],
@@ -73,19 +73,19 @@
7373
]
7474
},
7575
'pool_usage': {
76-
'options': [None, 'Ceph Pools', 'KB', 'pool', 'ceph.pool_usage', 'line'],
76+
'options': [None, 'Ceph Pools', 'KiB', 'pool', 'ceph.pool_usage', 'line'],
7777
'lines': []
7878
},
7979
'pool_objects': {
8080
'options': [None, 'Ceph Pools', 'objects', 'pool', 'ceph.pool_objects', 'line'],
8181
'lines': []
8282
},
8383
'pool_read_bytes': {
84-
'options': [None, 'Ceph Read Pool Data/s', 'KB', 'pool', 'ceph.pool_read_bytes', 'area'],
84+
'options': [None, 'Ceph Read Pool Data/s', 'KiB/s', 'pool', 'ceph.pool_read_bytes', 'area'],
8585
'lines': []
8686
},
8787
'pool_write_bytes': {
88-
'options': [None, 'Ceph Write Pool Data/s', 'KB', 'pool', 'ceph.pool_write_bytes', 'area'],
88+
'options': [None, 'Ceph Write Pool Data/s', 'KiB/s', 'pool', 'ceph.pool_write_bytes', 'area'],
8989
'lines': []
9090
},
9191
'pool_read_operations': {
@@ -97,7 +97,7 @@
9797
'lines': []
9898
},
9999
'osd_usage': {
100-
'options': [None, 'Ceph OSDs', 'KB', 'osd', 'ceph.osd_usage', 'line'],
100+
'options': [None, 'Ceph OSDs', 'KiB', 'osd', 'ceph.osd_usage', 'line'],
101101
'lines': []
102102
},
103103
'osd_apply_latency': {

collectors/python.d.plugin/chrony/chrony.chart.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,19 @@
77

88
# default module values (can be overridden per job in `config`)
99
update_every = 5
10-
priority = 60000
10+
11+
CHRONY_COMMAND = 'chronyc -n tracking'
1112

1213
# charts order (can be overridden if you want less charts, or different order)
13-
ORDER = ['system', 'offsets', 'stratum', 'root', 'frequency', 'residualfreq', 'skew']
14+
ORDER = [
15+
'system',
16+
'offsets',
17+
'stratum',
18+
'root',
19+
'frequency',
20+
'residualfreq',
21+
'skew',
22+
]
1423

1524
CHARTS = {
1625
'system': {
@@ -76,9 +85,9 @@ class Service(ExecutableService):
7685
def __init__(self, configuration=None, name=None):
7786
ExecutableService.__init__(
7887
self, configuration=configuration, name=name)
79-
self.command = 'chronyc -n tracking'
8088
self.order = ORDER
8189
self.definitions = CHARTS
90+
self.command = CHRONY_COMMAND
8291

8392
def _get_data(self):
8493
"""

0 commit comments

Comments
 (0)