Created
August 31, 2017 12:36
-
-
Save TomK/277d582ebe902901f202c06e662b9336 to your computer and use it in GitHub Desktop.
Close all rabbit connections with state of 'closed'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CONC=10 | |
HOST="--host=rabbit.fortifi.uk" | |
echo "Listing connections..." | |
rabbitapi $HOST -f tsv -q list connections name state |grep closed |awk '{$NF=""; print $0}' > conn.txt | |
echo "Found $(wc -l conn.txt) closed connections" | |
I=0 | |
while read -r name | |
do | |
echo "Closing $name" | |
rabbitapi $HOST -q close connection name="${name}" & | |
I=$(( $I + 1 )) | |
if [ $I -ge $CONC ] | |
then | |
wait | |
I=0 | |
fi | |
done < conn.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment