From 496f4b309757cc608c7e1515ffaadc555874932d Mon Sep 17 00:00:00 2001 From: Tony Pujals Date: Mon, 15 Aug 2016 10:18:24 -0700 Subject: [PATCH] add a monitor function to the swarm script --- swarm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/swarm b/swarm index 060a90829..a3ad51e89 100755 --- a/swarm +++ b/swarm @@ -82,7 +82,7 @@ ROLE=infrastructure usage() { cat << USAGE >&2 Usage: - $(basename $0) [pull|start|stop|restart|ls] + $(basename $0) [pull|start|stop|restart|ls|monitor] $(basename $0) [ -h | --help ] Basic AMP swarm operations. @@ -98,6 +98,7 @@ Commands: restart Restart services (options: --min); same as stop, pull, start stop Remove services ls List running services + monitor Continually update running services list with current status USAGE exit 1 @@ -135,6 +136,9 @@ main() { ls) ls ;; + monitor) + monitor "${@:2}" + ;; -h) usage ;; @@ -197,6 +201,11 @@ ls() { docker service ls --filter "label=amp.swarm=$ROLE" } +monitor() { + interval=${1:-5} + clear; while true; do tput cup 0 0; docker service ls; sleep $interval; done +} + ampagent() { docker service create --network amp-swarm --name amp-agent \ --mode global \