diff options
author | Emile Joubert <emile@rabbitmq.com> | 2011-05-27 12:46:39 +0100 |
---|---|---|
committer | Emile Joubert <emile@rabbitmq.com> | 2011-05-27 12:46:39 +0100 |
commit | 78665867a6d8e1b574bfc9d680f27022c18bdcc1 (patch) | |
tree | ec188fd78ad5a48ffb6f1dbf98dceb47449e0c5a /src | |
parent | 2ea7604c16e0da630bdae45aef8e102af80c0ce4 (diff) | |
download | rabbitmq-server-78665867a6d8e1b574bfc9d680f27022c18bdcc1.tar.gz |
rabbitmqctl report listing consumers more consistently
Diffstat (limited to 'src')
-rw-r--r-- | src/rabbit_amqqueue.erl | 12 | ||||
-rw-r--r-- | src/rabbit_control.erl | 49 |
2 files changed, 38 insertions, 23 deletions
diff --git a/src/rabbit_amqqueue.erl b/src/rabbit_amqqueue.erl index d029ff1d..023eef49 100644 --- a/src/rabbit_amqqueue.erl +++ b/src/rabbit_amqqueue.erl @@ -22,7 +22,7 @@ check_exclusive_access/2, with_exclusive_access_or_die/3, stat/1, deliver/2, requeue/3, ack/4, reject/4]). -export([list/1, info_keys/0, info/1, info/2, info_all/1, info_all/2]). --export([consumers/1, consumers_all/1]). +-export([consumers/1, consumers_all/1, consumer_info_keys/0]). -export([basic_get/3, basic_consume/7, basic_cancel/4]). -export([notify_sent/2, unblock/2, flush_all/2]). -export([commit_all/3, rollback_all/3, notify_down_all/2, limit_all/3]). @@ -92,6 +92,7 @@ -spec(consumers/1 :: (rabbit_types:amqqueue()) -> [{pid(), rabbit_types:ctag(), boolean()}]). +-spec(consumer_info_keys/0 :: () -> rabbit_types:info_keys()). -spec(consumers_all/1 :: (rabbit_types:vhost()) -> [{name(), pid(), rabbit_types:ctag(), boolean()}]). @@ -159,6 +160,9 @@ %%---------------------------------------------------------------------------- +-define(CONSUMER_INFO_KEYS, + [queue_name, channel_pid, consumer_tag, ack_required]). + start() -> DurableQueues = find_durable_queues(), {ok, BQ} = application:get_env(rabbit, backing_queue_module), @@ -341,10 +345,14 @@ info_all(VHostPath, Items) -> map(VHostPath, fun (Q) -> info(Q, Items) end). consumers(#amqqueue{ pid = QPid }) -> delegate_call(QPid, consumers). +consumer_info_keys() -> ?CONSUMER_INFO_KEYS. + consumers_all(VHostPath) -> lists:append( map(VHostPath, - fun (Q) -> [{Q#amqqueue.name, ChPid, ConsumerTag, AckRequired} || + fun (Q) -> + [lists:zip(consumer_info_keys(), + [Q#amqqueue.name, ChPid, ConsumerTag, AckRequired]) || {ChPid, ConsumerTag, AckRequired} <- consumers(Q)] end)). diff --git a/src/rabbit_control.erl b/src/rabbit_control.erl index ef5fd420..64343849 100644 --- a/src/rabbit_control.erl +++ b/src/rabbit_control.erl @@ -274,14 +274,8 @@ action(list_channels, Node, Args, _Opts, Inform) -> action(list_consumers, Node, _Args, Opts, Inform) -> Inform("Listing consumers", []), VHostArg = list_to_binary(proplists:get_value(?VHOST_OPT, Opts)), - InfoKeys = [queue_name, channel_pid, consumer_tag, ack_required], - case rpc_call(Node, rabbit_amqqueue, consumers_all, [VHostArg]) of - L when is_list(L) -> display_info_list( - [lists:zip(InfoKeys, tuple_to_list(X)) || - X <- L], - InfoKeys); - Other -> Other - end; + display_info_list(rpc_call(Node, rabbit_amqqueue, consumers_all, [VHostArg]), + rabbit_amqqueue:consumer_info_keys()); action(trace_on, Node, [], Opts, Inform) -> VHost = proplists:get_value(?VHOST_OPT, Opts), @@ -313,21 +307,34 @@ action(list_permissions, Node, [], Opts, Inform) -> action(report, Node, _Args, _Opts, Inform) -> io:format("Reporting server status on ~p~n", [erlang:universaltime()]), - [action(status, ClusteredNode, [], [], Inform) || - ClusteredNode <- rpc_call(Node, rabbit_mnesia, running_clustered_nodes, [])], - Report = fun (Module, VHostArg) -> - io:format("%% ~p~n", [[Module] ++ VHostArg]), - case Results = rpc_call(Node, Module, info_all, VHostArg) of - [Row|_] -> {InfoItems,_} = lists:unzip(Row), - display_info_list(Results, InfoItems); - _ -> ok + [action(status, ClusterNode, [], [], Inform) || + ClusterNode <- rpc_call(Node, rabbit_mnesia, running_clustered_nodes, [])], + Report = fun ({Descr, Module, InfoFun, KeysFun}, VHostArg) -> + io:format("%% ~p~n", [[Descr] ++ VHostArg]), + case Results = rpc_call(Node, Module, InfoFun, VHostArg) of + [_|_] -> InfoItems = rpc_call(Node, Module, KeysFun, []), + display_info_list(Results, InfoItems); + _ -> ok end end, - GlobalQueries = [rabbit_channel], - VHostQueries = [rabbit_amqqueue, rabbit_exchange, rabbit_binding], - [Report(M, []) || M <- GlobalQueries], - [Report(M, [V]) || V <- rpc_call(Node, rabbit_vhost, list, []), - M <- VHostQueries], + GlobalQueries = [{"connections", rabbit_networking, connection_info_all, + connection_info_keys}, + {"channels", rabbit_channel, connection_info_all, + info_keys}], + VHostQueries = [{"queues", rabbit_amqqueue, info_all, info_keys}, + {"exchanges", rabbit_exchange, info_all, info_keys}, + {"bindings", rabbit_binding, info_all, info_keys}, + {"consumers", rabbit_amqqueue, consumers_all, + consumer_info_keys}], + VHosts = rpc_call(Node, rabbit_vhost, list, []), + [Report(Q, []) || Q <- GlobalQueries], + [Report(Q, [V]) || V <- VHosts, Q <- VHostQueries], + [begin + io:format("%% ~p~n", [["permissions" | [VHost]]]), + display_list(call(Node, + {rabbit_auth_backend_internal, list_vhost_permissions, + [binary_to_list(VHost)]})) + end || VHost <- VHosts], ok. %%---------------------------------------------------------------------------- |