Skip to content

Instantly share code, notes, and snippets.

@johanrhodin
Created May 8, 2020 04:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johanrhodin/0611a777f217b3c50a6a44e9a0c9b28b to your computer and use it in GitHub Desktop.
Save johanrhodin/0611a777f217b3c50a6a44e9a0c9b28b to your computer and use it in GitHub Desktop.
Count vhosts that has started
bash << EOF
logpath=("/var/log/rabbitmq/rabbit@HOSTNAME.log")
numbervhosts=$(expr $(sudo rabbitmqctl list_vhosts | wc -l) - $num)
startnr=$(grep -n "Starting RabbitMQ" $logpath | tail -1 | cut -d : -f 1) # Last RabbitMQ Starting
startedvhosts=$(sed -n "$startnr"',$p' $logpath | grep -n "Starting message stores for vhost" | wc -l)
awk -v nvh="$numbervhosts" -v svh="$startedvhosts" 'BEGIN{ print int(svh/nvh*100) }'
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment