Double quote to prevent globbing and word splitting.

Do not use legacy backticks.
Proper use of printf
Do not use wc -l with grep, instead use grep -c
Use pgrep

Signed-off-by: Werner Buck <wernerbuck@gmail.com>
This commit is contained in:
Werner Buck 2015-05-29 13:42:34 +02:00
commit f4aab9c8c5
9 changed files with 87 additions and 87 deletions

View file

@ -15,7 +15,7 @@ else
set -f; IFS=$'
'
for c in $containers; do
volumes=`docker inspect --format '{{ .Volumes }}' $c`
volumes=$(docker inspect --format '{{ .Volumes }}' "$c")
if [ "$volumes" = "map[]" ]; then
# If it's the first container, fail the test
@ -36,8 +36,8 @@ set +f; unset IFS
# 6.6
check_6_6="6.6 - Avoid image sprawl"
images=`docker images | wc -l | awk '{print $1}'`
if [ $images -gt 100 ]; then
images=$(docker images | wc -l | awk '{print $1}')
if [ "$images" -gt 100 ]; then
warn "$check_6_6"
warn " * There are currently: $images images"
else
@ -47,10 +47,10 @@ fi
# 6.7
check_6_7="6.7 - Avoid container sprawl"
total_containers=`docker info 2>/dev/null | grep "Containers" | awk '{print $2}'`
running_containers=`docker ps -q | wc -l | awk '{print $1}'`
diff=`expr "$total_containers" - "$running_containers"`
if [ $diff -gt 25 ]; then
total_containers=$(docker info 2>/dev/null | grep "Containers" | awk '{print $2}')
running_containers=$(docker ps -q | wc -l | awk '{print $1}')
diff="$(($total_containers - $running_containers))"
if [ "$diff" -gt 25 ]; then
warn "$check_6_7"
warn " * There are currently a total of $total_containers containers, with only $running_containers of them currently running"
else