From 82952f58b359b275f73ef12b236ecc7ecfc2f5da Mon Sep 17 00:00:00 2001 From: andrew-pickin-epi Date: Thu, 12 Sep 2024 15:16:12 +0000 Subject: [PATCH] check_container.sh fixed for paused containers --- bin/check_container.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/bin/check_container.sh b/bin/check_container.sh index 48e9d67..78b219f 100755 --- a/bin/check_container.sh +++ b/bin/check_container.sh @@ -10,14 +10,14 @@ PROG=$(basename $0) check () { - docker top $NAME > /dev/null && docker container stats --no-stream $NAME 2>&1 - case $? in - 0) - exit $OK;; - 1) - exit $CRITICAL;; - *) # Unknown service - exit $UNKNOWN;; + STATUS=$(docker container inspect $NAME 2> /dev/null | jq -r .[0].State.Status) + + case $STATUS in + running) + docker container stats --no-stream $NAME 2>&1 + exit $OK;; + *) [ "$STATUS" == "null" ] && echo "Container $NAME not running" || echo "Container $NAME $STATUS" + exit $CRITICAL;; esac }