From 934a246a5925fabf007fd77e4ed51a44e273e684 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o?= <theo@le-filament.com> Date: Thu, 12 May 2022 19:00:32 +0200 Subject: [PATCH] fix missing zero for cpu usage lower than 1% --- check_docker.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_docker.sh b/check_docker.sh index 733a444..7fe4851 100755 --- a/check_docker.sh +++ b/check_docker.sh @@ -77,7 +77,7 @@ for container_stats in ${running_containers_stats}; do all_cpu=$(/usr/bin/awk -F ':' '{print +$2}' <(echo $container_stats)) mem=$(/usr/bin/awk -F ':' '{print +$3}' <(echo $container_stats)) proc_number=$(nproc --all) - cpu=$(echo "scale=2; ${all_cpu} / ${proc_number}" | bc) + cpu=$(echo "${all_cpu} ${proc_number}" | /usr/bin/awk '{printf "%.2f", $1 / $2}') status='OK' [[ ${cpu%.*} -ge $cpu_threshold_warning ]] && status='WARNING' -- GitLab