Add performance data
This commit is contained in:
parent
d0b3649213
commit
28d084da36
1 changed files with 29 additions and 4 deletions
|
@ -40,6 +40,13 @@ function in_array() {
|
|||
return 1
|
||||
}
|
||||
|
||||
function implode() {
|
||||
local d=${1-} f=${2-}
|
||||
if shift 2; then
|
||||
printf %s "$f" "${@/#/$d}"
|
||||
fi
|
||||
}
|
||||
|
||||
function usage() {
|
||||
error="$1"
|
||||
[ -n "$error" ] && echo "$error"
|
||||
|
@ -252,20 +259,38 @@ fi
|
|||
|
||||
debug "Final exit code: $EXIT_CODE"
|
||||
|
||||
debug "Check containers (${#CHECKED_CONTAINERS[@]}): $( implode ", " "${CHECKED_CONTAINERS[@]}" )"
|
||||
debug "Containers with errors (${#ERRORS[@]}): $( implode ", " "${!ERRORS[@]}" )"
|
||||
debug "Not found containers (${#NOTFOUNDS[@]}): $( implode ", " "${NOTFOUNDS[@]}" )"
|
||||
|
||||
# Compute performance data
|
||||
let CONTAINER_COUNTS=${#CHECKED_CONTAINERS[@]}+${#NOTFOUNDS[@]}
|
||||
PERF_DATA=(
|
||||
"uptodate_containers=${#UPTODATE[@]};;;0;$CONTAINER_COUNTS"
|
||||
"containers_with_errors=${#ERRORS[@]};1;;0;$CONTAINER_COUNTS"
|
||||
"unknown_state_containers=${#UNKNOWNS[@]};;;0;$CONTAINER_COUNTS"
|
||||
)
|
||||
|
||||
# Display check result message
|
||||
case $EXIT_CODE in
|
||||
0)
|
||||
echo "OK - All ${#UPTODATE[@]} container(s) are uptodate"
|
||||
echo -n "OK - All ${#UPTODATE[@]} container(s) are uptodate"
|
||||
;;
|
||||
1)
|
||||
echo "WARNING - ${#ERRORS[@]} container(s) need to be updated"
|
||||
echo -n "WARNING - ${#ERRORS[@]} container(s) need to be updated"
|
||||
;;
|
||||
2)
|
||||
echo "CRITICAL - ${#ERRORS[@]} container(s) need to be updated"
|
||||
echo -n "CRITICAL - ${#ERRORS[@]} container(s) need to be updated"
|
||||
;;
|
||||
*)
|
||||
echo "UNKNOWN - fail to retrieve status of ${#UNKNOWNS[@]} container(s)"
|
||||
echo -n "UNKNOWN - fail to retrieve status of ${#UNKNOWNS[@]} container(s)"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Add performance data
|
||||
echo " |$( implode " " "${PERF_DATA[@]}" )"
|
||||
|
||||
# Display details, starting by errors
|
||||
for container in ${!ERRORS[@]}
|
||||
do
|
||||
echo ${container} - ${ERRORS[${container}]}
|
||||
|
|
Loading…
Reference in a new issue