diff --git a/check_opnsense_traffic_for_host.py b/check_opnsense_traffic_for_host.py index 12cc22d..eeac96b 100755 --- a/check_opnsense_traffic_for_host.py +++ b/check_opnsense_traffic_for_host.py @@ -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'), @@ -110,7 +109,7 @@ def main(): ] 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) diff --git a/check_pve_guest_metrics.py b/check_pve_guest_metrics.py index 006c81c..56f1dd1 100755 --- a/check_pve_guest_metrics.py +++ b/check_pve_guest_metrics.py @@ -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,11 +143,11 @@ 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 '')) - perf_data_str = f'|{" ".join(perf_data)}' + perf_data_str = f'| {" ".join(perf_data)}' if args.table: output_table = [('Metric', 'Value', 'Status')]