fix check_service_bsd.sh

This commit is contained in:
Cyberes 2023-06-08 11:38:10 -06:00
parent 5f5f831d02
commit 342d66071a
Signed by: cyberes
GPG Key ID: 6B4A33836A9500FE
1 changed files with 6 additions and 6 deletions

View File

@ -3,9 +3,9 @@
# Parse named arguments # Parse named arguments
while [ "$#" -gt 0 ]; do while [ "$#" -gt 0 ]; do
case "$1" in case "$1" in
--service=*) --service)
SERVICE="${1#*=}" SERVICE="$2"
shift 1 shift 2
;; ;;
*) *)
echo "Unknown option: $1" echo "Unknown option: $1"
@ -24,15 +24,15 @@ fi
service_status=$(service ${SERVICE} onestatus) service_status=$(service ${SERVICE} onestatus)
# If the service is running, return OK # 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" echo "OK - ${SERVICE} is running"
exit 0 exit 0
# If the service is not running, return CRITICAL # 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" echo "CRITICAL - ${SERVICE} is not running"
exit 2 exit 2
# If the check failed, return UNKNOWN # If the check failed, return UNKNOWN
else else
echo -e "UNKNOWN - Check failed:\n$service_status" echo "UNKNOWN - Check failed"
exit 3 exit 3
fi fi