diff --git a/usr/local/bin/systemd_check b/usr/local/bin/systemd_check index cbad7b0..134aa1b 100755 --- a/usr/local/bin/systemd_check +++ b/usr/local/bin/systemd_check @@ -79,18 +79,21 @@ function checkService() { if [ "$(id -u)" != "0" ]; then local USER_COMMAND="systemctl --user is-active --quiet $SERVICE"; RESULT=$($USER_COMMAND); + if [ -z "$RESULT" ]; then + RESULT=0; + fi else local ROOT_COMMAND="systemctl is-active --quiet $SERVICE"; local USER_COMMAND="systemctl --user is-active --quiet $SERVICE"; local RESULT_ROOT_COMMAND=$($ROOT_COMMAND); local RESULT_USER_COMMAND=$($USER_COMMAND); - if [ "$RESULT_ROOT_COMMAND" ] || [ "$RESULT_USER_COMMAND" ]; then + if [ -z "$RESULT_ROOT_COMMAND" ] || [ -z "$RESULT_USER_COMMAND" ]; then RESULT=0; fi fi - if ! "$RESULT"; then + if [ "$RESULT" -gt 0 ]; then local SUBJECT="[systemd $SYSTEMD_CHECK_HOSTNAME for $SYSTEMD_CHECK_USER] CRITICAL $SERVICE"; echo "-> $SUBJECT: $MESSAGE";