Skip to content
Snippets Groups Projects
Commit fbc03dc1 authored by Théo - Le Filament's avatar Théo - Le Filament
Browse files

fix retrieval of not running conatiners

parent 3ce24d6e
No related branches found
No related tags found
No related merge requests found
...@@ -48,11 +48,11 @@ while [[ $# -gt 0 ]]; do ...@@ -48,11 +48,11 @@ while [[ $# -gt 0 ]]; do
done done
# Gathering facts. # Gathering facts.
all_containers=`sudo docker ps --format '{{.Names}}' --filter "name=${filter}" --no-trunc --quiet --all` all_containers=`sudo /usr/bin/docker ps --format '{{.Names}}' --filter "name=${filter}" --no-trunc --quiet --all`
running_containers=`sudo docker ps --format '{{.Names}}' --filter "name=${filter}" --no-trunc --quiet` running_containers=`sudo /usr/bin/docker ps --format '{{.Names}}' --filter "name=${filter}" --no-trunc --quiet`
running_containers_stats=`sudo docker stats --format '{{.Name}}:{{.CPUPerc}}:{{.MemPerc}}' --no-stream` running_containers_stats=`sudo /usr/bin/docker stats --format '{{.Name}}:{{.CPUPerc}}:{{.MemPerc}}' --no-stream`
not_running_containers=`comm -23 <(echo $all_containers) <(echo $running_containers)` not_running_containers=`comm -23 <(echo $all_containers | /usr/bin/tr ' ' '\n') <(echo $running_containers | /usr/bin/tr ' ' '\n')`
# Format data. # Format data.
output='' output=''
...@@ -72,10 +72,10 @@ done ...@@ -72,10 +72,10 @@ done
# CPU and memory statistics for running containers. # CPU and memory statistics for running containers.
for container_stats in ${running_containers_stats}; do for container_stats in ${running_containers_stats}; do
name=`awk -F ':' '{print $1}' <(echo $container_stats)` name=`/usr/bin/awk -F ':' '{print $1}' <(echo $container_stats)`
[[ ! $name =~ ${filter} ]] && continue [[ ! $name =~ ${filter} ]] && continue
cpu=`awk -F ':' '{print +$2}' <(echo $container_stats)` cpu=`/usr/bin/awk -F ':' '{print +$2}' <(echo $container_stats)`
mem=`awk -F ':' '{print +$3}' <(echo $container_stats)` mem=`/usr/bin/awk -F ':' '{print +$3}' <(echo $container_stats)`
status='OK' status='OK'
[[ ${cpu%.*} -ge $cpu_threshold_warning ]] && status='WARNING' [[ ${cpu%.*} -ge $cpu_threshold_warning ]] && status='WARNING'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment