Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/CISOfy/lynis.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Boelen <michael.boelen@cisofy.com>2016-07-30 15:01:36 +0300
committerMichael Boelen <michael.boelen@cisofy.com>2016-07-30 15:01:36 +0300
commitc8096dd06c92aeb9a95fb9e2134f72d8cd198c73 (patch)
treee55200cc258539d80cb8f35f372bbf8c20f10000 /include/tests_containers
parentad8c9f40caa382bf0d1fb01e5d7eb014cfd088fe (diff)
Only show number of running containers when there are any
Diffstat (limited to 'include/tests_containers')
-rw-r--r--include/tests_containers6
1 files changed, 3 insertions, 3 deletions
diff --git a/include/tests_containers b/include/tests_containers
index c32a59d0..11764afe 100644
--- a/include/tests_containers
+++ b/include/tests_containers
@@ -139,7 +139,7 @@
DOCKER_CONTAINERS_TOTAL=0
fi
LogText "Result: docker info shows ${DOCKER_CONTAINERS_TOTAL} containers"
- DOCKER_CONTAINERS_TOTAL2=`${DOCKERBINARY} ps -a 2> /dev/null | grep -v "CONTAINER" | wc -l`
+ DOCKER_CONTAINERS_TOTAL2=$(${DOCKERBINARY} ps -a 2> /dev/null | grep -c -v "CONTAINER")
LogText "Result: docker ps -a shows ${DOCKER_CONTAINERS_TOTAL2} containers"
if [ ! "${DOCKER_CONTAINERS_TOTAL}" = "${DOCKER_CONTAINERS_TOTAL2}" ]; then
LogText "Result: difference detected, which is unexpected"
@@ -150,9 +150,9 @@
fi
# Check running instances
- DOCKER_CONTAINERS_RUNNING=`${DOCKERBINARY} ps 2> /dev/null | grep -v "CONTAINER" | wc -l`
- Display --indent 8 --text "- Running containers" --result "${DOCKER_CONTAINERS_RUNNING}" --color GREEN
+ DOCKER_CONTAINERS_RUNNING=$(${DOCKERBINARY} ps 2> /dev/null | grep -c -v "CONTAINER")
if [ ${DOCKER_CONTAINERS_RUNNING} -gt 0 ]; then
+ Display --indent 10 --text "- Running containers" --result "${DOCKER_CONTAINERS_RUNNING}" --color GREEN
LogText "Result: ${DOCKER_CONTAINERS_RUNNING} containers are currently active"
Report "docker_containers_running=${DOCKER_CONTAINERS_RUNNING}"
else