@cryptotaxi247 / netdata-1 / commits / 64b678e00

Fix HAProxy server status parsing and add MAINT status chart (#16253)

Kyle Dodson committed Oct 24, 2023 at 05:45 UTC 64b678e00d95b10d5baf714ad08e6ea671c7cc64
1 file changed +9 -1
collectors/python.d.plugin/haproxy/haproxy.chart.py
+9 -1
@@ -44,6 +44,7 @@ ORDER = [
44 'bctime',
45 'health_sup',
46 'health_sdown',
47 + 'health_smaint',
48 'health_bdown',
49 'health_idle'
50 ]
@@ -167,6 +168,10 @@ CHARTS = {
168 'options': [None, 'Backend Servers In UP State', 'health servers', 'health', 'haproxy_hs.up', 'line'],
169 'lines': []
170 },
171 + 'health_smaint': {
172 + 'options': [None, 'Backend Servers In MAINT State', 'maintenance servers', 'health', 'haproxy_hs.maint', 'line'],
173 + 'lines': []
174 + },
175 'health_bdown': {
176 'options': [None, 'Is Backend Failed?', 'boolean', 'health', 'haproxy_hb.down', 'line'],
177 'lines': []
@@ -267,6 +272,8 @@ class Service(UrlService, SocketService):
272 if server_status(server, name, 'UP')])
273 stat_data['hsdown_' + idx] = len([server for server in self.data['servers']
274 if server_status(server, name, 'DOWN')])
275 + stat_data['hsmaint_' + idx] = len([server for server in self.data['servers']
276 + if server_status(server, name, 'MAINT')])
277 stat_data['hbdown_' + idx] = 1 if backend.get('status') == 'DOWN' else 0
278 for metric in BACKEND_METRICS:
279 stat_data['_'.join(['backend', metric, idx])] = backend.get(metric) or 0
@@ -321,6 +328,7 @@ class Service(UrlService, SocketService):
328 BACKEND_METRICS[metric]['divisor']])
329 self.definitions['health_sup']['lines'].append(['hsup_' + idx, name, 'absolute'])
330 self.definitions['health_sdown']['lines'].append(['hsdown_' + idx, name, 'absolute'])
331 + self.definitions['health_smaint']['lines'].append(['hsmaint_' + idx, name, 'absolute'])
332 self.definitions['health_bdown']['lines'].append(['hbdown_' + idx, name, 'absolute'])
333
334
@@ -352,7 +360,7 @@ def parse_data_(data):
360
361
362 def server_status(server, backend_name, status='DOWN'):
355 - return server.get('# pxname') == backend_name and server.get('status') == status
363 + return server.get('# pxname') == backend_name and server.get('status').partition(' ')[0] == status
364
365
366 def url_remove_params(url):