From dafd6236bcb1e5f4724addc93c948da3601b164d Mon Sep 17 00:00:00 2001 From: Cyberes Date: Mon, 23 Sep 2024 21:28:59 -0600 Subject: [PATCH] check_systemd_service: modify output when a service is allowed disabled --- check_systemd_service.sh | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/check_systemd_service.sh b/check_systemd_service.sh index c1332f8..299bcc1 100755 --- a/check_systemd_service.sh +++ b/check_systemd_service.sh @@ -91,9 +91,23 @@ if [ -n "$end_time" ] && [ "$end_time" != "n/a" ] && [ -z "$end_time" ]; then end_time_str=" Exited at $end_time." fi +# ============= +# Build output + if [ "$IS_TIMER" = true ] && { [ "$substate" = "exited" ] || [ "$active" = "inactive" ]; }; then - echo "OK - $UNIT_NAME is active and exited (returned $exit_code) and enabled.$end_time_str $end_time_diff_perf" + status="exited (returned $exit_code)" else - echo "OK - $UNIT_NAME is active and enabled.$start_time_str $start_time_diff_perf" + status="active" fi + +if [ "$enabled" = "enabled" ] || [ "$IS_ALLOWED_DISABLED" != true ]; then + status+=" and enabled" +fi + +if [ "$IS_TIMER" = true ] && { [ "$substate" = "exited" ] || [ "$active" = "inactive" ]; }; then + echo "OK - $UNIT_NAME is $status.$end_time_str $end_time_diff_perf" +else + echo "OK - $UNIT_NAME is $status.$start_time_str $start_time_diff_perf" +fi + exit 0