Removed trash, fixet collumed log, added docker status

This commit is contained in:
2019-04-22 23:11:59 +03:00
parent 07d14695b5
commit 03db17718d

32
60-docker Executable file
View File

@@ -0,0 +1,32 @@
#!/bin/bash
# set column width
COLUMNS=2
# colors
green="\e[1;32m"
red="\e[1;31m"
undim="\e[0m"
mapfile -t containers < <(docker ps -a | sed 's/([[:digit:]]*)//' | awk '{ print $11,$7 }' | sed '/^\s*$/d' | tail -n +2)
IFS=$'\n' containers=($(sort <<<"${containers[*]}"))
unset IFS
out=""
for i in "${!containers[@]}"; do
IFS=" " read name status <<< ${containers[i]}
# color green if service is active, else red
if [[ "${status}" == "Up" ]]; then
out+="${name}:,${green}${status,,}${undim},"
else
out+="${name}:,${red}${status,,}${undim},"
fi
# insert \n every $COLUMNS column
if [ $((($i+1) % $COLUMNS)) -eq 0 ]; then
out+="\n"
fi
done
out+="\n"
printf "\nDocker status:\n"
printf "$out" | column -ts $',' | sed -e 's/^/ /'