fix perfdata

This commit is contained in:
Cyberes 2023-04-21 23:54:20 -06:00
parent f9c30524f6
commit 7f98f7154c
2 changed files with 9 additions and 9 deletions

View File

@ -4,7 +4,6 @@ import sys
import time
import traceback
import hurry
import numpy as np
import requests
from urllib3.exceptions import InsecureRequestWarning
@ -98,11 +97,11 @@ def main():
ok.append(name)
status = '[OK]'
perf_data.append(f'{name}-rate_in={filesize(data["rate_in"], spaces=False)};{warn_value};{crit_value};0;')
perf_data.append(f'{name}-rate_out={filesize(data["rate_out"], spaces=False)};{warn_value};{crit_value};0;')
perf_data.append(f'{name}-cumulative_in={filesize(data["cumulative_in"], spaces=False)};{warn_value};{crit_value};0;')
perf_data.append(f'{name}-cumulative_out={filesize(data["cumulative_out"], spaces=False)};{warn_value};{crit_value};0;')
perf_data.append(f'{name}-connections={data["connections"]};{warn_value};{crit_value};0;')
perf_data.append(f'\'{name}RateIn\'={int(data["rate_in"])}B;{warn_value};{crit_value};0;')
perf_data.append(f'\'{name}RateOut\'={int(data["rate_out"])}B;{warn_value};{crit_value};0;')
perf_data.append(f'\'{name}CumulativeIn\'={int(data["cumulative_in"])}B;{warn_value};{crit_value};0;')
perf_data.append(f'\'{name}CumulativeOut\'={int(data["cumulative_out"])}B;{warn_value};{crit_value};0;')
perf_data.append(f'\'{name}Connections\'={int(data["connections"])}B;{warn_value};{crit_value};0;')
output_table = [
('Host', 'Interface', 'Rate In', 'Rate Out', 'Cumulative In', 'Cumulative Out', 'Connections', 'Status'),

View File

@ -116,6 +116,7 @@ def main():
if metrics_levels[metric]['type'] == 'filesize':
check_data[metric]['value_str'] = filesize(avg)
check_data[metric]['value'] = f'{int(avg)}B'
else:
check_data[metric]['value_str'] = str(avg)
@ -142,7 +143,7 @@ def main():
perf_data = []
for metric, data in check_data.items():
output_str = output_str + f"{metric} {data['value_str']}, "
perf_data.append(f"{metric}={data['value_str'].replace(' ', '')};{metrics_levels[metric]['warn']};{metrics_levels[metric]['crit']};;")
perf_data.append(f"'{metric}'={data['value']};{metrics_levels[metric]['warn']};{metrics_levels[metric]['crit']};;")
print(output_str.strip(', ').strip(), end=('\n' if args.table else ''))