From 3d6742384f9d76df0c0442af7cfa2b3dd6647f0d Mon Sep 17 00:00:00 2001 From: Cyberes Date: Sat, 9 Sep 2023 12:23:34 -0600 Subject: [PATCH] check_pve_guest_metrics: adjust input data --- check_pve_guest_metrics.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/check_pve_guest_metrics.py b/check_pve_guest_metrics.py index 37bd9ae..03783f5 100755 --- a/check_pve_guest_metrics.py +++ b/check_pve_guest_metrics.py @@ -55,6 +55,15 @@ def main(): print('UNKNOWN: Failed to parse --levels JSON:', e) sys.exit(nagios.UNKNOWN) + for k, v in metrics_levels.items(): + metrics_levels[k]['min'] = metrics_levels[k].get('min') + if isinstance(metrics_levels[k]['min'], float): + metrics_levels[k]['min'] = int(metrics_levels[k]['min']) + if isinstance(metrics_levels[k]['warn'], float): + metrics_levels[k]['warn'] = int(metrics_levels[k]['warn']) + if isinstance(metrics_levels[k]['crit'], float): + metrics_levels[k]['crit'] = int(metrics_levels[k]['crit']) + try: args.node = json.loads(args.node) pve_node = args.node[0] @@ -171,7 +180,10 @@ def main(): for metric, data in check_data.items(): output_str = output_str + f"{metric} {data['value_str']}, " if not check_data[metric]['nan']: - perf_data.append(f"'{metric}'={data['value']};{metrics_levels[metric]['warn']};{metrics_levels[metric]['crit']};;") + if metrics_levels[metric]['min'] is None: + perf_data.append(f"'{metric}'={data['value']};{metrics_levels[metric]['warn']};{metrics_levels[metric]['crit']};;") + else: + perf_data.append(f"'{metric}'={data['value']};{metrics_levels[metric]['warn']};{metrics_levels[metric]['crit']};{metrics_levels[metric]['min']};") print(output_str.strip(', ').strip(), end=('\n' if args.table else ''))