diff --git a/check_systemd_service.sh b/check_systemd_service.sh index c13bce4..7e2fab1 100644 --- a/check_systemd_service.sh +++ b/check_systemd_service.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Copyright (C) 2016 Mohamed El Morabity +# Copyright © 2016, 2017 Mohamed El Morabity # # This module is free software: you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free Software @@ -19,8 +19,8 @@ PLUGINDIR=$(dirname $0) . $PLUGINDIR/utils.sh -if [ $# -ne 1 ]; then - echo "Usage: ${0##*/} " >&2 +if [[ $# -ne 1 ]]; then + echo "Usage: ${0##*/} " exit $STATE_UNKNOWN fi @@ -29,19 +29,19 @@ service=$1 status=$(systemctl is-enabled $service 2>/dev/null) r=$? -if [ -z "$status" ]; then +if [[ -z "$status" ]]; then echo "ERROR: service $service doesn't exist" exit $STATE_CRITICAL fi -if [ $r -ne 0 ]; then +if [[ $r -ne 0 ]]; then echo "ERROR: service $service is $status" exit $STATE_CRITICAL fi systemctl --quiet is-active $service -if [ $? -ne 0 ]; then +if [[ $? -ne 0 ]]; then echo "ERROR: service $service is not running" exit $STATE_CRITICAL fi