From 342d66071ab99bca4fdcde1f664e6c7dbbbe95d7 Mon Sep 17 00:00:00 2001 From: Drake Panzer Date: Thu, 8 Jun 2023 11:38:10 -0600 Subject: [PATCH] fix check_service_bsd.sh --- check_service_bsd.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/check_service_bsd.sh b/check_service_bsd.sh index 7a76bae..a6a56cc 100755 --- a/check_service_bsd.sh +++ b/check_service_bsd.sh @@ -3,9 +3,9 @@ # Parse named arguments while [ "$#" -gt 0 ]; do case "$1" in - --service=*) - SERVICE="${1#*=}" - shift 1 + --service) + SERVICE="$2" + shift 2 ;; *) echo "Unknown option: $1" @@ -24,15 +24,15 @@ fi service_status=$(service ${SERVICE} onestatus) # If the service is running, return OK -if echo "$service_status" | grep -q "${SERVICE} is running as pid [0-9]*."; then +if echo "$service_status" | grep -iq "${SERVICE} is running \(as\|with\) pid [0-9]*."; then echo "OK - ${SERVICE} is running" exit 0 # If the service is not running, return CRITICAL -elif echo "$service_status" | grep -q "${SERVICE} is not running."; then +elif echo "$service_status" | grep -iq "${SERVICE} is not running."; then echo "CRITICAL - ${SERVICE} is not running" exit 2 # If the check failed, return UNKNOWN else - echo -e "UNKNOWN - Check failed:\n$service_status" + echo "UNKNOWN - Check failed" exit 3 fi