fix perfdata
This commit is contained in:
parent
f9c30524f6
commit
7f98f7154c
|
@ -4,7 +4,6 @@ import sys
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
import hurry
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import requests
|
import requests
|
||||||
from urllib3.exceptions import InsecureRequestWarning
|
from urllib3.exceptions import InsecureRequestWarning
|
||||||
|
@ -98,11 +97,11 @@ def main():
|
||||||
ok.append(name)
|
ok.append(name)
|
||||||
status = '[OK]'
|
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}RateIn\'={int(data["rate_in"])}B;{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}RateOut\'={int(data["rate_out"])}B;{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}CumulativeIn\'={int(data["cumulative_in"])}B;{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}CumulativeOut\'={int(data["cumulative_out"])}B;{warn_value};{crit_value};0;')
|
||||||
perf_data.append(f'{name}-connections={data["connections"]};{warn_value};{crit_value};0;')
|
perf_data.append(f'\'{name}Connections\'={int(data["connections"])}B;{warn_value};{crit_value};0;')
|
||||||
|
|
||||||
output_table = [
|
output_table = [
|
||||||
('Host', 'Interface', 'Rate In', 'Rate Out', 'Cumulative In', 'Cumulative Out', 'Connections', 'Status'),
|
('Host', 'Interface', 'Rate In', 'Rate Out', 'Cumulative In', 'Cumulative Out', 'Connections', 'Status'),
|
||||||
|
@ -110,7 +109,7 @@ def main():
|
||||||
]
|
]
|
||||||
print(list_to_markdown_table(output_table, align='left', seperator='!', borders=False))
|
print(list_to_markdown_table(output_table, align='left', seperator='!', borders=False))
|
||||||
|
|
||||||
print(f' |{" ".join(perf_data)}')
|
print(f'| {" ".join(perf_data)}')
|
||||||
sys.exit(exit_code)
|
sys.exit(exit_code)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -116,6 +116,7 @@ def main():
|
||||||
|
|
||||||
if metrics_levels[metric]['type'] == 'filesize':
|
if metrics_levels[metric]['type'] == 'filesize':
|
||||||
check_data[metric]['value_str'] = filesize(avg)
|
check_data[metric]['value_str'] = filesize(avg)
|
||||||
|
check_data[metric]['value'] = f'{int(avg)}B'
|
||||||
else:
|
else:
|
||||||
check_data[metric]['value_str'] = str(avg)
|
check_data[metric]['value_str'] = str(avg)
|
||||||
|
|
||||||
|
@ -142,11 +143,11 @@ def main():
|
||||||
perf_data = []
|
perf_data = []
|
||||||
for metric, data in check_data.items():
|
for metric, data in check_data.items():
|
||||||
output_str = output_str + f"{metric} {data['value_str']}, "
|
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 ''))
|
print(output_str.strip(', ').strip(), end=('\n' if args.table else ''))
|
||||||
|
|
||||||
perf_data_str = f'|{" ".join(perf_data)}'
|
perf_data_str = f'| {" ".join(perf_data)}'
|
||||||
|
|
||||||
if args.table:
|
if args.table:
|
||||||
output_table = [('Metric', 'Value', 'Status')]
|
output_table = [('Metric', 'Value', 'Status')]
|
||||||
|
|
Loading…
Reference in New Issue