@cryptotaxi247 / netdata-1 / commits / 166d99406

backend servers status charts added

Ilya committed Jan 10, 2017 at 11:31 UTC 166d99406e1d77268f51e3c33edb72b3d0f91a42
1 file changed +17 -1
python.d/haproxy.chart.py
+17 -1
@@ -10,7 +10,7 @@ priority = 60000
10 retries = 60
11
12 # charts order (can be overridden if you want less charts, or different order)
13 -ORDER = ['fbin', 'fbout', 'fscur', 'fqcur', 'bbin', 'bbout', 'bscur', 'bqcur']
13 +ORDER = ['fbin', 'fbout', 'fscur', 'fqcur', 'bbin', 'bbout', 'bscur', 'bqcur', 'health_down']
14 CHARTS = {
15 'fbin': {
16 'options': [None, "Kilobytes in", "kilobytes in/s", 'Frontend', 'f.bin', 'line'],
@@ -43,6 +43,10 @@ CHARTS = {
43 'bqcur': {
44 'options': [None, "Sessions in queue", "sessions", 'Backend', 'b.qcur', 'line'],
45 'lines': [
46 + ]},
47 + 'health_down': {
48 + 'options': [None, "Servers in DOWN state", "servers", 'Health', 'h.down', 'line'],
49 + 'lines': [
50 ]}
51 }
52
@@ -69,6 +73,7 @@ class Service(UrlService):
73 self.definitions['bbout']['lines'].append(['_'.join(['bbout', back_ends[_]['# pxname']]), back_ends[_]['# pxname'], 'incremental', 1, 1024])
74 self.definitions['bscur']['lines'].append(['_'.join(['bscur', back_ends[_]['# pxname']]), back_ends[_]['# pxname'], 'absolute'])
75 self.definitions['bqcur']['lines'].append(['_'.join(['bqcur', back_ends[_]['# pxname']]), back_ends[_]['# pxname'], 'absolute'])
76 + self.definitions['health_down']['lines'].append(['_'.join(['hdown', back_ends[_]['# pxname']]), back_ends[_]['# pxname'], 'absolute'])
77
78 def _get_data(self):
79 """
@@ -89,6 +94,7 @@ class Service(UrlService):
94
95 back_ends = list(filter(is_backend, all_instances))
96 front_ends = list(filter(is_frontend, all_instances))
97 + servers = list(filter(is_server, all_instances))
98
99 if self.charts:
100 self.create_charts(front_ends, back_ends)
@@ -104,6 +110,10 @@ class Service(UrlService):
110 for _ in self.order_back:
111 to_netdata.update({'_'.join([_, backend['# pxname']]): int(backend[_[1:]]) if backend.get(_[1:]) else 0})
112
113 + for _ in range(len(back_ends)):
114 + to_netdata.update({'_'.join(['hdown', back_ends[_]['# pxname']]):
115 + len([server for server in servers if is_server_up(server, back_ends, _)])})
116 +
117 return to_netdata
118
119 def is_backend(backend):
@@ -111,3 +121,9 @@ def is_backend(backend):
121
122 def is_frontend(frontend):
123 return frontend['svname'] == 'FRONTEND' and frontend['# pxname'] != 'stats'
124 +
125 +def is_server(server):
126 + return not server['svname'].startswith(('FRONTEND', 'BACKEND'))
127 +
128 +def is_server_up(server, back_ends, _):
129 + return server['# pxname'] == back_ends[_]['# pxname'] and server['status'] != 'UP'