From 0ad9690aa9635ec6c93265656d57ddfad2a62f10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Sch=C3=A4ferdiek?= Date: Fri, 25 Jan 2019 19:52:59 +0100 Subject: [PATCH] Fix systemd --- usr/local/bin/systemd_check | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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";