fix traffic
This commit is contained in:
parent
1ef32a1730
commit
3dcae7a5a1
|
@ -71,28 +71,29 @@ def main():
|
||||||
print(traffic_data)
|
print(traffic_data)
|
||||||
sys.exit(nagios.UNKNOWN)
|
sys.exit(nagios.UNKNOWN)
|
||||||
elif not len(traffic_data):
|
elif not len(traffic_data):
|
||||||
traffic_data = {
|
check_result[name] = {
|
||||||
'rate_bits_in': 0,
|
'rate_in': 0,
|
||||||
'rate_bits_out': 0,
|
'rate_out': 0,
|
||||||
'cumulative_bytes_in': 0,
|
'cumulative_in': 0,
|
||||||
'cumulative_bytes_out': 0,
|
'cumulative_out': 0,
|
||||||
'details': 0
|
'details': 0
|
||||||
}
|
}
|
||||||
|
else:
|
||||||
try:
|
try:
|
||||||
check_result[name] = {
|
check_result[name] = {
|
||||||
'rate_in': np.average([x['rate_bits_in'] for x in traffic_data]),
|
'rate_in': np.average([x['rate_bits_in'] for x in traffic_data]),
|
||||||
'rate_out': np.average([x['rate_bits_out'] for x in traffic_data]),
|
'rate_out': np.average([x['rate_bits_out'] for x in traffic_data]),
|
||||||
'cumulative_in': np.average([x['cumulative_bytes_in'] for x in traffic_data]),
|
'cumulative_in': np.average([x['cumulative_bytes_in'] for x in traffic_data]),
|
||||||
'cumulative_out': np.average([x['cumulative_bytes_out'] for x in traffic_data]),
|
'cumulative_out': np.average([x['cumulative_bytes_out'] for x in traffic_data]),
|
||||||
'connections': int(np.average([len(x['details']) for x in traffic_data]))
|
'connections': int(np.average([len(x['details']) for x in traffic_data]))
|
||||||
}
|
}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f'UNKNOWN: Failed to parse traffic data: "{e}"')
|
print(f'UNKNOWN: Failed to parse traffic data: "{e}"')
|
||||||
print(traceback.format_exc())
|
print(traceback.format_exc())
|
||||||
print('\nRaw data:')
|
print('')
|
||||||
print(traffic_data)
|
print('Raw data:')
|
||||||
sys.exit(nagios.UNKNOWN)
|
print(traffic_data)
|
||||||
|
sys.exit(nagios.UNKNOWN)
|
||||||
|
|
||||||
# TODO: figure out status
|
# TODO: figure out status
|
||||||
print('OK: no metrics defined.')
|
print('OK: no metrics defined.')
|
||||||
|
|
Loading…
Reference in New Issue