Fix systemd

This commit is contained in:
Alexander Schäferdiek 2019-01-25 19:52:59 +01:00
parent 986f3e2fc2
commit 0ad9690aa9

View file

@ -79,18 +79,21 @@ function checkService() {
if [ "$(id -u)" != "0" ]; then if [ "$(id -u)" != "0" ]; then
local USER_COMMAND="systemctl --user is-active --quiet $SERVICE"; local USER_COMMAND="systemctl --user is-active --quiet $SERVICE";
RESULT=$($USER_COMMAND); RESULT=$($USER_COMMAND);
if [ -z "$RESULT" ]; then
RESULT=0;
fi
else else
local ROOT_COMMAND="systemctl is-active --quiet $SERVICE"; local ROOT_COMMAND="systemctl is-active --quiet $SERVICE";
local USER_COMMAND="systemctl --user is-active --quiet $SERVICE"; local USER_COMMAND="systemctl --user is-active --quiet $SERVICE";
local RESULT_ROOT_COMMAND=$($ROOT_COMMAND); local RESULT_ROOT_COMMAND=$($ROOT_COMMAND);
local RESULT_USER_COMMAND=$($USER_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; RESULT=0;
fi fi
fi fi
if ! "$RESULT"; then if [ "$RESULT" -gt 0 ]; then
local SUBJECT="[systemd $SYSTEMD_CHECK_HOSTNAME for $SYSTEMD_CHECK_USER] CRITICAL $SERVICE"; local SUBJECT="[systemd $SYSTEMD_CHECK_HOSTNAME for $SYSTEMD_CHECK_USER] CRITICAL $SERVICE";
echo "-> $SUBJECT: $MESSAGE"; echo "-> $SUBJECT: $MESSAGE";