From f877fac512f295eeb2e4cd8bdb8f1ade391e2bc3 Mon Sep 17 00:00:00 2001 From: Salt Date: Wed, 18 Aug 2021 19:03:14 -0500 Subject: [PATCH] Fix a bug where oneshot services that weren't running got weird status text --- check_systemd_unit | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/check_systemd_unit b/check_systemd_unit index c0e88f3..e5c2faf 100755 --- a/check_systemd_unit +++ b/check_systemd_unit @@ -37,12 +37,13 @@ else ;; 3) # In this case, the unit is not running. Whether this is an issue depends on the type of service - if systemctl cat backup | grep -ie '^Type=' | grep -ie 'oneshot'; then + if systemctl cat backup | grep -ie '^Type=' | grep -ie 'oneshot' > /dev/null 2>&1; then echo "UNIT OK: $service is not running" + exit 0 else echo "UNIT CRITICAL: $service is not running" + exit 4 fi - exit 0 ;; 4) echo "UNIT CRITICAL: $service is not present on this machine"