From 2d911cee998a19af55cbe0bc640f8c328da5aa9a Mon Sep 17 00:00:00 2001 From: Danny Date: Sun, 23 Nov 2025 22:29:44 +0100 Subject: [PATCH] cpu_status loop added --- roles/pips/files/cpu_usage.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/roles/pips/files/cpu_usage.py b/roles/pips/files/cpu_usage.py index 6505db3..52fc894 100644 --- a/roles/pips/files/cpu_usage.py +++ b/roles/pips/files/cpu_usage.py @@ -40,12 +40,13 @@ def main(): status = 0 status_str = "OK" - if percent_used >= args.critical: - status = 2 - status_str = "CRITICAL" - elif percent_used >= args.warning: - status = 1 - status_str = "WARNING" + for percent_used in cpu: + if percent_used >= args.critical: + status = 2 + status_str = "CRITICAL" + elif percent_used >= args.warning: + status = 1 + status_str = "WARNING" # Perfdata: used and total in MiB, and percent perf = ( @@ -53,7 +54,7 @@ def main(): f" total={total_mb:.1f}MiB" ) - print(f"MEMORY {status_str} - {used_mb:.1f}MiB used of {total_mb:.1f}MiB ({percent_used:.1f}%) | {perf}") + print(f"CPU {status_str} - {used_mb:.1f}MiB used of {total_mb:.1f}MiB ({percent_used:.1f}%) | {perf}") sys.exit(status)