-
Notifications
You must be signed in to change notification settings - Fork 0
/
command_line_tools
37 lines (24 loc) · 1.81 KB
/
command_line_tools
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# https://www.rabbitmq.com/cli.html
######################### QUEUES ###########################################
#### Identify queues with messages > 0
rabbitmqctl list_queues --no-table-headers -q | awk '$2 > 0 { printf "%s\t%s\n", $0,"[X]" ; } $2 <= 0 { print $0 ;}'
### filter queue name starting with
rabbitmqctl list_queues --no-table-headers -q | sort -r -k1 -n |awk '/^PUTSTARTINGNAMEHERE/'
### filter queue name contain name
rabbitmqctl list_queues --no-table-headers -q | sort -r -k1 -n |awk '/PUTSUBSTRINGHERE/'
### filter queues with consumers
rabbitmqctl list_queues name messages consumers --no-table-headers -q | awk '$3 > 0 { printf "%s\t%s\n", $0,"" ; }'
################# CHANNLES #################
#### filter channels with ZERO consumers
rabbitmqctl list_channels name connection number consumer_count --no-table-headers -q |awk '$7 = 0 { printf "%s\t%s\n", $0,"" ; }'
#################### DELETE/PURGE WARNING!!!! #############################
### delete all the queues on the default vhost
for q in $(rabbitmqctl list_queues name -s) ; do rabbitmqctl delete_queue $q; done
### delete all the queues on the given a vhost
for q in $(rabbitmqctl list_queues name -s --vhost YOUR_VOST) ; do rabbitmqctl delete_queue --vhost YOUR_VOST $q; done
### purge all the queues on the given a vhost
for q in $(rabbitmqctl list_queues name -s --vhost YOUR_VOST) ; do rabbitmqctl purge_queue --vhost YOUR_VOST $q; done
### purge all the queues in all vhost !!!!!
for vh in $(rabbitmqctl list_vhosts -s); do for q in $(rabbitmqctl list_queues name -s --vhost $vh) ; do rabbitmqctl purge_queue --vhost $vh $q; done done
### delete all the queues in all vhost !!!!!
for vh in $(rabbitmqctl list_vhosts -s); do for q in $(rabbitmqctl list_queues name -s --vhost $vh) ; do rabbitmqctl delete_queue --vhost $vh $q; done done