1515
1616
1717defmodule RabbitMQ.CLI.Ctl.Commands.ListUnresponsiveQueuesCommand do
18+ require RabbitMQ.CLI.Ctl.InfoKeys
1819 require RabbitMQ.CLI.Ctl.RpcStream
1920
21+ alias RabbitMQ.CLI.Ctl.InfoKeys , as: InfoKeys
2022 alias RabbitMQ.CLI.Ctl.RpcStream , as: RpcStream
2123 alias RabbitMQ.CLI.Core.Helpers , as: Helpers
2224
@@ -25,35 +27,50 @@ defmodule RabbitMQ.CLI.Ctl.Commands.ListUnresponsiveQueuesCommand do
2527
2628 def formatter ( ) , do: RabbitMQ.CLI.Formatters.Table
2729
30+ @ info_keys ~w( name durable auto_delete
31+ arguments pid recoverable_slaves) a
32+
33+ def info_keys ( ) , do: @ info_keys
34+
2835 def scopes ( ) , do: [ :ctl , :diagnostics ]
2936
30- def validate ( _ , _ ) , do: :ok
37+ def validate ( args , _opts ) do
38+ case InfoKeys . validate_info_keys ( args , @ info_keys ) do
39+ { :ok , _ } -> :ok
40+ err -> err
41+ end
42+ end
3143
32- def merge_defaults ( args , opts ) do
44+ def merge_defaults ( [ _ | _ ] = args , opts ) do
3345 { args , Map . merge ( default_opts ( ) , opts ) }
3446 end
47+ def merge_defaults ( [ ] , opts ) do
48+ merge_defaults ( ~w( name) , opts )
49+ end
3550
3651 def switches ( ) , do: [ queue_timeout: :integer , local: :boolean ]
3752
3853 def usage ( ) do
39- "list_unresponsive_queues [--local] [--queue-timeout <queue-timeout>]"
54+ "list_unresponsive_queues [--local] [--queue-timeout <queue-timeout>] [<queueinfoitem> ...] "
4055 end
4156
42- def run ( [ ] , % { node: node_name , vhost: vhost , timeout: timeout ,
43- queue_timeout: queue_timeout , local: local_opt } ) do
57+ def run ( args , % { node: node_name , vhost: vhost , timeout: timeout ,
58+ queue_timeout: qtimeout , local: local_opt } ) do
59+ info_keys = InfoKeys . prepare_info_keys ( args )
60+ queue_timeout = qtimeout * 1000
4461 Helpers . with_nodes_in_cluster ( node_name , fn ( nodes ) ->
45- local_mfa = { :rabbit_amqqueue , :emit_unresponsive_local , [ vhost , queue_timeout ] }
46- all_mfa = { :rabbit_amqqueue , :emit_unresponsive , [ nodes , vhost , queue_timeout ] }
62+ local_mfa = { :rabbit_amqqueue , :emit_unresponsive_local , [ vhost , info_keys , queue_timeout ] }
63+ all_mfa = { :rabbit_amqqueue , :emit_unresponsive , [ nodes , vhost , info_keys , queue_timeout ] }
4764 { chunks , mfas } = case local_opt do
4865 true -> { 1 , [ local_mfa ] } ;
4966 false -> { Kernel . length ( nodes ) , [ all_mfa ] }
5067 end
51- RpcStream . receive_list_items ( node_name , mfas , timeout , [ :name ] , chunks )
68+ RpcStream . receive_list_items ( node_name , mfas , timeout , info_keys , chunks )
5269 end )
5370 end
5471
5572 defp default_opts ( ) do
56- % { vhost: "/" , local: false , queue_timeout: 30000 }
73+ % { vhost: "/" , local: false , queue_timeout: 15 }
5774 end
5875
5976 def banner ( _ , % { vhost: vhost } ) , do: "Listing unresponsive queues for vhost #{ vhost } ..."
0 commit comments