|
10 | 10 | retries = 60 |
11 | 11 |
|
12 | 12 | # charts order (can be overridden if you want less charts, or different order) |
13 | | -ORDER = ['fbin', 'fbout', 'fscur', 'fqcur', 'bbin', 'bbout', 'bscur', 'bqcur', 'health_down'] |
| 13 | +ORDER = ['fbin', 'fbout', 'fscur', 'fqcur', 'bbin', 'bbout', 'bscur', 'bqcur', 'health_sdown', 'health_bdown'] |
14 | 14 | CHARTS = { |
15 | 15 | 'fbin': { |
16 | 16 | 'options': [None, "Kilobytes in", "kilobytes in/s", 'Frontend', 'haproxy_f.bin', 'line'], |
|
44 | 44 | 'options': [None, "Sessions in queue", "sessions", 'Backend', 'haproxy_b.qcur', 'line'], |
45 | 45 | 'lines': [ |
46 | 46 | ]}, |
47 | | - 'health_down': { |
48 | | - 'options': [None, "Servers in DOWN state", "failed servers", 'Health', 'haproxy_h.down', 'line'], |
| 47 | + 'health_sdown': { |
| 48 | + 'options': [None, "Number of servers in backend in DOWN state", "failed servers", 'Health', 'haproxy_hs.down', 'line'], |
| 49 | + 'lines': [ |
| 50 | + ]}, |
| 51 | + 'health_bdown': { |
| 52 | + 'options': [None, "Is backend alive? 1 = DOWN", "failed backend", 'Health', 'haproxy_hb.down', 'line'], |
49 | 53 | 'lines': [ |
50 | 54 | ]} |
51 | 55 | } |
@@ -93,7 +97,8 @@ def create_charts(self, front_ends, back_ends): |
93 | 97 | self.definitions['bbout']['lines'].append(['_'.join(['bbout', back_ends[_]['# pxname']]), back_ends[_]['# pxname'], 'incremental', 1, 1024]) |
94 | 98 | self.definitions['bscur']['lines'].append(['_'.join(['bscur', back_ends[_]['# pxname']]), back_ends[_]['# pxname'], 'absolute']) |
95 | 99 | self.definitions['bqcur']['lines'].append(['_'.join(['bqcur', back_ends[_]['# pxname']]), back_ends[_]['# pxname'], 'absolute']) |
96 | | - self.definitions['health_down']['lines'].append(['_'.join(['hdown', back_ends[_]['# pxname']]), back_ends[_]['# pxname'], 'absolute']) |
| 100 | + self.definitions['health_sdown']['lines'].append(['_'.join(['hsdown', back_ends[_]['# pxname']]), back_ends[_]['# pxname'], 'absolute']) |
| 101 | + self.definitions['health_bdown']['lines'].append(['_'.join(['hbdown', back_ends[_]['# pxname']]), back_ends[_]['# pxname'], 'absolute']) |
97 | 102 |
|
98 | 103 | def _get_data(self): |
99 | 104 | """ |
@@ -127,8 +132,9 @@ def _get_data(self): |
127 | 132 | to_netdata.update({'_'.join([_, backend['# pxname']]): int(backend[_[1:]]) if backend.get(_[1:]) else 0}) |
128 | 133 |
|
129 | 134 | for _ in range(len(back_ends)): |
130 | | - to_netdata.update({'_'.join(['hdown', back_ends[_]['# pxname']]): |
| 135 | + to_netdata.update({'_'.join(['hsdown', back_ends[_]['# pxname']]): |
131 | 136 | len([server for server in servers if is_server_down(server, back_ends, _)])}) |
| 137 | + to_netdata.update({'_'.join(['hbdown', back_ends[_]['# pxname']]): 1 if is_backend_down(back_ends, _) else 0}) |
132 | 138 |
|
133 | 139 | return to_netdata |
134 | 140 |
|
@@ -163,3 +169,9 @@ def is_server_down(server, back_ends, _): |
163 | 169 | return server['# pxname'] == back_ends[_]['# pxname'] and server['status'] == 'DOWN' |
164 | 170 | except Exception: |
165 | 171 | return False |
| 172 | + |
| 173 | +def is_backend_down(back_ends, _): |
| 174 | + try: |
| 175 | + return back_ends[_]['status'] == 'DOWN' |
| 176 | + except Exception: |
| 177 | + return False |
0 commit comments