Add containers counts in output message
This commit is contained in:
parent
1cde0c3b86
commit
d0b3649213
1 changed files with 10 additions and 6 deletions
|
@ -134,6 +134,7 @@ declare -A CONTAINER_STATUS_FILE
|
||||||
declare -A CONTAINER_PID
|
declare -A CONTAINER_PID
|
||||||
declare -A UPTODATE
|
declare -A UPTODATE
|
||||||
declare -A ERRORS
|
declare -A ERRORS
|
||||||
|
declare -A UNKNOWNS
|
||||||
CHECKED_CONTAINERS=( )
|
CHECKED_CONTAINERS=( )
|
||||||
|
|
||||||
debug "List running containers..."
|
debug "List running containers..."
|
||||||
|
@ -227,20 +228,23 @@ do
|
||||||
UPTODATE+=( ["$container"]=$STATUS )
|
UPTODATE+=( ["$container"]=$STATUS )
|
||||||
else
|
else
|
||||||
ERRORS+=( ["$container"]=$STATUS )
|
ERRORS+=( ["$container"]=$STATUS )
|
||||||
|
[ $ex -ge 3 ] && UNKNOWNS+=( "$container" )
|
||||||
fi
|
fi
|
||||||
[ $EXIT_CODE -ge $ex ] && continue
|
[ $EXIT_CODE -ge $ex ] && continue
|
||||||
[ $ex -gt 3 ] && ex=3
|
[ $ex -gt 3 ] && ex=3
|
||||||
EXIT_CODE=$ex
|
EXIT_CODE=$ex
|
||||||
done
|
done
|
||||||
|
|
||||||
|
NOTFOUNDS=()
|
||||||
if ! is_empty $ONLY_CONTAINERS
|
if ! is_empty $ONLY_CONTAINERS
|
||||||
then
|
then
|
||||||
for container in ${ONLY_CONTAINERS[@]}
|
for container in ${ONLY_CONTAINERS[@]}
|
||||||
do
|
do
|
||||||
if ! in_array $container ${CHECKED_CONTAINERS[@]}
|
if ! in_array $container ${CHECKED_CONTAINERS[@]}
|
||||||
then
|
then
|
||||||
debug "$container - Not found"
|
debug "$container - Container not found"
|
||||||
ERRORS+=( ["$container"]="Not found" )
|
ERRORS+=( ["$container"]="Container not found" )
|
||||||
|
NOTFOUNDS+=( "$container" )
|
||||||
EXIT_CODE=3
|
EXIT_CODE=3
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -250,16 +254,16 @@ debug "Final exit code: $EXIT_CODE"
|
||||||
|
|
||||||
case $EXIT_CODE in
|
case $EXIT_CODE in
|
||||||
0)
|
0)
|
||||||
echo "OK - All containers are uptodate"
|
echo "OK - All ${#UPTODATE[@]} container(s) are uptodate"
|
||||||
;;
|
;;
|
||||||
1)
|
1)
|
||||||
echo "WARNING - some containers need to be updated"
|
echo "WARNING - ${#ERRORS[@]} container(s) need to be updated"
|
||||||
;;
|
;;
|
||||||
2)
|
2)
|
||||||
echo "CRITICAL - some containers need to be updated"
|
echo "CRITICAL - ${#ERRORS[@]} container(s) need to be updated"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "UNKNOWN - fail to retrieve status of some containers"
|
echo "UNKNOWN - fail to retrieve status of ${#UNKNOWNS[@]} container(s)"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
for container in ${!ERRORS[@]}
|
for container in ${!ERRORS[@]}
|
||||||
|
|
Loading…
Reference in a new issue