@cryptotaxi247 / netdata-1 / commits / f9b2c2396

haproxy plugin: bugfix

Ilya committed May 22, 2017 at 20:31 UTC f9b2c2396bccec88b1953327a48e12e534233082
1 file changed +14 -7
python.d/haproxy.chart.py
+14 -7
@@ -5,10 +5,11 @@
5 from base import UrlService, SocketService
6 from collections import defaultdict
7 from re import compile as re_compile
8 +
9 try:
9 - from urlparse import urlparse
10 + from urlparse import urlparse
11 except ImportError:
11 - from urllib.parse import urlparse
12 + from urllib.parse import urlparse
13
14 # default module values (can be overridden per job in `config`)
15 # update_every = 2
@@ -67,7 +68,11 @@ CHARTS = {
68 ]}
69 }
70
70 -METRICS = ('bin', 'bout', 'scur', 'qcur')
71 +METRICS = {'bin': {'algorithm': 'incremental', 'divisor': 1024},
72 + 'bout': {'algorithm': 'incremental', 'divisor': 1024},
73 + 'scur': {'algorithm': 'absolute', 'divisor': 1},
74 + 'qcur': {'algorithm': 'absolute', 'divisor': 1}}
75 +
76 REGEX = dict(url=re_compile(r'idle = (?P<idle>[0-9]+)'), socket=re_compile(r'Idle_pct: (?P<idle>[0-9]+)'))
77
78
@@ -113,7 +118,7 @@ class Service(UrlService, SocketService):
118
119 raw_data = raw_data.splitlines()
120 self.data = parse_data_([dict(zip(raw_data[0].split(','), raw_data[_].split(',')))
116 - for _ in range(1, len(raw_data))])
121 + for _ in range(1, len(raw_data))])
122 if not self.data:
123 return dict()
124
@@ -127,7 +132,7 @@ class Service(UrlService, SocketService):
132 for backend in self.data['backend']:
133 name, idx = backend['# pxname'], backend['# pxname'].replace('.', '_')
134 stat_data['hsdown_' + idx] = len([server for server in self.data['servers']
130 - if server_down(server, name)])
135 + if server_down(server, name)])
136 stat_data['hbdown_' + idx] = 1 if backend.get('status') == 'DOWN' else 0
137 for metric in METRICS:
138 stat_data['_'.join(['backend', metric, idx])] = backend.get(metric) or 0
@@ -158,12 +163,14 @@ class Service(UrlService, SocketService):
163 name, idx = front['# pxname'], front['# pxname'].replace('.', '_')
164 for metric in METRICS:
165 self.definitions['f' + metric]['lines'].append(['_'.join(['frontend', metric, idx]),
161 - name, 'incremental', 1, 1024])
166 + METRICS[metric]['algorithm'], 1,
167 + METRICS[metric]['divisor']])
168 for back in self.data['backend']:
169 name, idx = back['# pxname'], back['# pxname'].replace('.', '_')
170 for metric in METRICS:
171 self.definitions['b' + metric]['lines'].append(['_'.join(['backend', metric, idx]),
166 - name, 'incremental', 1, 1024])
172 + name, METRICS[metric]['algorithm'], 1,
173 + METRICS[metric]['divisor']])
174 self.definitions['health_sdown']['lines'].append(['hsdown_' + idx, name, 'absolute'])
175 self.definitions['health_bdown']['lines'].append(['hbdown_' + idx, name, 'absolute'])
176