fix traffic

This commit is contained in:
Cyberes 2023-05-03 12:48:44 -06:00
parent 1ef32a1730
commit 3dcae7a5a1
1 changed files with 21 additions and 20 deletions

View File

@ -71,14 +71,14 @@ def main():
print(traffic_data)
sys.exit(nagios.UNKNOWN)
elif not len(traffic_data):
traffic_data = {
'rate_bits_in': 0,
'rate_bits_out': 0,
'cumulative_bytes_in': 0,
'cumulative_bytes_out': 0,
check_result[name] = {
'rate_in': 0,
'rate_out': 0,
'cumulative_in': 0,
'cumulative_out': 0,
'details': 0
}
else:
try:
check_result[name] = {
'rate_in': np.average([x['rate_bits_in'] for x in traffic_data]),
@ -90,7 +90,8 @@ def main():
except Exception as e:
print(f'UNKNOWN: Failed to parse traffic data: "{e}"')
print(traceback.format_exc())
print('\nRaw data:')
print('')
print('Raw data:')
print(traffic_data)
sys.exit(nagios.UNKNOWN)