new option docker-status --stop to stop (end therefore restart) a container
This commit is contained in:
@@ -125,6 +125,7 @@ trap 'traperror "$? ${PIPESTATUS[@]}" $LINENO $BASH_LINENO "$BASH_COMMAND" "${FU
|
|||||||
|
|
||||||
######################################################### commandline parameter evaluation
|
######################################################### commandline parameter evaluation
|
||||||
exec=0
|
exec=0
|
||||||
|
stop=0
|
||||||
log=0
|
log=0
|
||||||
stacks=
|
stacks=
|
||||||
short=0
|
short=0
|
||||||
@@ -140,6 +141,7 @@ OPTIONS
|
|||||||
--help, -h show this help
|
--help, -h show this help
|
||||||
--log, -l show log command
|
--log, -l show log command
|
||||||
--exec, -e show exec command
|
--exec, -e show exec command
|
||||||
|
--stop, -x show stop command
|
||||||
--short, -s only show errors
|
--short, -s only show errors
|
||||||
|
|
||||||
stacks optional space separated list of stacks
|
stacks optional space separated list of stacks
|
||||||
@@ -152,6 +154,7 @@ EOF
|
|||||||
exit;;
|
exit;;
|
||||||
(--log|-l) log=1;;
|
(--log|-l) log=1;;
|
||||||
(--exec|-e) exec=1;;
|
(--exec|-e) exec=1;;
|
||||||
|
(--stop|-x) stop=1;;
|
||||||
(--short|-s) short=1;;
|
(--short|-s) short=1;;
|
||||||
(*) stacks="$*"; break;;
|
(*) stacks="$*"; break;;
|
||||||
esac
|
esac
|
||||||
@@ -171,19 +174,20 @@ services=$(for stack in ${stacks}; do
|
|||||||
"
|
"
|
||||||
for service in ${status}; do
|
for service in ${status}; do
|
||||||
time=${service%%;*}
|
time=${service%%;*}
|
||||||
echo "$(date -d "$(sed 's,about an* ,1 ,' <<<${time})");${service#*;}"
|
echo "$(date -d "$(sed 's,about an* ,1 ,;s,less than an* ,0 ,' <<<${time})");${service#*;}"
|
||||||
done
|
done
|
||||||
done | sort -hr)
|
done | sort -hr)
|
||||||
|
|
||||||
IFS="
|
IFS="
|
||||||
"
|
"
|
||||||
for service in ${services}; do
|
for service in ${services}; do
|
||||||
awk -F';' -v dolog=$log -v doexec=$exec -v doshort=$short '
|
awk -F';' -v dolog=$log -v doexec=$exec -v dostop=$stop -v doshort=$short '
|
||||||
{color="'"${green}"'"}
|
{color="'"${green}"'"}
|
||||||
$5 ~ /second|minute/ {color="'"${yellow}"'"}
|
$5 ~ /second|minute/ {color="'"${yellow}"'"}
|
||||||
$5 !~ /^Running/ {printf "'"${red}"'%-15s%-40s%s %s%s\n", $3, $2, $5, $7, "'"${normal}"'"}
|
$5 !~ /^Running/ {printf "'"${red}"'%-15s%-40s%s %s%s\n", $3, $2, $5, $7, "'"${normal}"'"}
|
||||||
$5 ~ /^Running/ && doshort==0 {printf "%s%-15s%-40s%s%s\n", color, $3, $2, $5, "'"${normal}"'"}
|
$5 ~ /^Running/ && doshort==0 {printf "%s%-15s%-40s%s%s\n", color, $3, $2, $5, "'"${normal}"'"}
|
||||||
dolog==1 && (doshort==0 || $5 !~ /^Running/) {printf "ssh %s docker logs -f %s.%s\n", $3, $2, $6}
|
dolog==1 && (doshort==0 || $5 !~ /^Running/) {printf "ssh %s docker logs -f %s.%s\n", $3, $2, $6}
|
||||||
doexec==1 && (dohort==0 || $5 !~ /^Running/) {printf "ssh %s docker exec -it %s.%s bash\n", $3, $2, $6}
|
doexec==1 && (dohort==0 || $5 !~ /^Running/) {printf "ssh -t %s docker exec -it %s.%s bash\n", $3, $2, $6}
|
||||||
|
dostop==1 && (dohort==0 || $5 !~ /^Running/) {printf "ssh %s docker stop %s.%s\n", $3, $2, $6}
|
||||||
' <<<${service}
|
' <<<${service}
|
||||||
done
|
done
|
||||||
|
Reference in New Issue
Block a user