summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rabbit.erl2
-rw-r--r--src/rabbit_consumer.erl42
-rw-r--r--src/rabbit_control.erl33
-rw-r--r--src/rabbit_networking.erl26
-rw-r--r--src/rabbit_tests.erl2
5 files changed, 81 insertions, 24 deletions
diff --git a/src/rabbit.erl b/src/rabbit.erl
index e6e80b4aac..7b507ff18e 100644
--- a/src/rabbit.erl
+++ b/src/rabbit.erl
@@ -217,6 +217,8 @@ stop_and_halt() ->
status() ->
[{pid, list_to_integer(os:getpid())},
+ {os, os:type()},
+ {erlang_version, erlang:system_info(system_version)},
{running_applications, application:which_applications()}] ++
rabbit_mnesia:status().
diff --git a/src/rabbit_consumer.erl b/src/rabbit_consumer.erl
new file mode 100644
index 0000000000..1c9d106467
--- /dev/null
+++ b/src/rabbit_consumer.erl
@@ -0,0 +1,42 @@
+%% The contents of this file are subject to the Mozilla Public License
+%% Version 1.1 (the "License"); you may not use this file except in
+%% compliance with the License. You may obtain a copy of the License
+%% at http://www.mozilla.org/MPL/
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+%% the License for the specific language governing rights and
+%% limitations under the License.
+%%
+%% The Original Code is RabbitMQ.
+%%
+%% The Initial Developer of the Original Code is VMware, Inc.
+%% Copyright (c) 2007-2011 VMware, Inc. All rights reserved.
+%%
+
+-module(rabbit_consumer).
+
+-export([info_all/1]).
+
+-include("rabbit.hrl").
+
+%%----------------------------------------------------------------------------
+
+-ifdef(use_specs).
+
+-spec(info_all/1 :: (rabbit_types:vhost()) -> [rabbit_types:infos()]).
+
+-endif.
+
+%%----------------------------------------------------------------------------
+
+info_all(VHostPath) ->
+ [[{queue_name, QName#resource.name},
+ {channel_pid, ChPid},
+ {consumer_tag, ConsumerTag},
+ {ack_required, AckRequired}] ||
+ #amqqueue{pid=QPid, name=QName} <- rabbit_amqqueue:list(VHostPath),
+ {ChPid, ConsumerTag, AckRequired} <-
+ delegate:invoke(QPid, fun (P) ->
+ gen_server2:call(P, consumers, infinity)
+ end)].
diff --git a/src/rabbit_control.erl b/src/rabbit_control.erl
index 8172f8040c..8ced9dd6e5 100644
--- a/src/rabbit_control.erl
+++ b/src/rabbit_control.erl
@@ -260,7 +260,7 @@ action(list_bindings, Node, Args, Opts, Inform) ->
action(list_connections, Node, Args, _Opts, Inform) ->
Inform("Listing connections", []),
ArgAtoms = default_if_empty(Args, [user, peer_address, peer_port, state]),
- display_info_list(rpc_call(Node, rabbit_networking, connection_info_all,
+ display_info_list(rpc_call(Node, rabbit_networking, info_all,
[ArgAtoms]),
ArgAtoms);
@@ -275,13 +275,8 @@ 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_consumer, info_all, [VHostArg]),
+ InfoKeys);
action(trace_on, Node, [], Opts, Inform) ->
VHost = proplists:get_value(?VHOST_OPT, Opts),
@@ -309,7 +304,27 @@ action(list_permissions, Node, [], Opts, Inform) ->
VHost = proplists:get_value(?VHOST_OPT, Opts),
Inform("Listing permissions in vhost ~p", [VHost]),
display_list(call(Node, {rabbit_auth_backend_internal,
- list_vhost_permissions, [VHost]})).
+ list_vhost_permissions, [VHost]}));
+
+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
+ end
+ end,
+ GlobalQueries = [rabbit_networking, rabbit_channel],
+ VHostQueries = [rabbit_amqqueue, rabbit_exchange, rabbit_binding,
+ rabbit_consumer],
+ [Report(M, []) || M <- GlobalQueries],
+ [Report(M, [V]) || V <- rpc_call(Node, rabbit_vhost, list, []),
+ M <- VHostQueries],
+ ok.
%%----------------------------------------------------------------------------
diff --git a/src/rabbit_networking.erl b/src/rabbit_networking.erl
index 451e56e8cb..72442aaa1e 100644
--- a/src/rabbit_networking.erl
+++ b/src/rabbit_networking.erl
@@ -18,10 +18,8 @@
-export([boot/0, start/0, start_tcp_listener/1, start_ssl_listener/2,
stop_tcp_listener/1, on_node_down/1, active_listeners/0,
- node_listeners/1, connections/0, connection_info_keys/0,
- connection_info/1, connection_info/2,
- connection_info_all/0, connection_info_all/1,
- close_connection/2]).
+ node_listeners/1, connections/0, info_keys/0, info/1, info/2,
+ info_all/0, info_all/1, close_connection/2]).
%%used by TCP-based transports, e.g. STOMP adapter
-export([check_tcp_listener_address/2,
@@ -59,14 +57,14 @@
-spec(active_listeners/0 :: () -> [rabbit_types:listener()]).
-spec(node_listeners/1 :: (node()) -> [rabbit_types:listener()]).
-spec(connections/0 :: () -> [rabbit_types:connection()]).
--spec(connection_info_keys/0 :: () -> rabbit_types:info_keys()).
--spec(connection_info/1 ::
+-spec(info_keys/0 :: () -> rabbit_types:info_keys()).
+-spec(info/1 ::
(rabbit_types:connection()) -> rabbit_types:infos()).
--spec(connection_info/2 ::
+-spec(info/2 ::
(rabbit_types:connection(), rabbit_types:info_keys())
-> rabbit_types:infos()).
--spec(connection_info_all/0 :: () -> [rabbit_types:infos()]).
--spec(connection_info_all/1 ::
+-spec(info_all/0 :: () -> [rabbit_types:infos()]).
+-spec(info_all/1 ::
(rabbit_types:info_keys()) -> [rabbit_types:infos()]).
-spec(close_connection/2 :: (pid(), string()) -> 'ok').
-spec(on_node_down/1 :: (node()) -> 'ok').
@@ -275,13 +273,13 @@ connections() ->
{_, ConnSup, supervisor, _}
<- supervisor:which_children({rabbit_tcp_client_sup, Node})].
-connection_info_keys() -> rabbit_reader:info_keys().
+info_keys() -> rabbit_reader:info_keys().
-connection_info(Pid) -> rabbit_reader:info(Pid).
-connection_info(Pid, Items) -> rabbit_reader:info(Pid, Items).
+info(Pid) -> rabbit_reader:info(Pid).
+info(Pid, Items) -> rabbit_reader:info(Pid, Items).
-connection_info_all() -> cmap(fun (Q) -> connection_info(Q) end).
-connection_info_all(Items) -> cmap(fun (Q) -> connection_info(Q, Items) end).
+info_all() -> cmap(fun (Q) -> info(Q) end).
+info_all(Items) -> cmap(fun (Q) -> info(Q, Items) end).
close_connection(Pid, Explanation) ->
case lists:member(Pid, connections()) of
diff --git a/src/rabbit_tests.erl b/src/rabbit_tests.erl
index 1a37cdfffa..dce94c56f6 100644
--- a/src/rabbit_tests.erl
+++ b/src/rabbit_tests.erl
@@ -1162,7 +1162,7 @@ test_server_status() ->
{ok, _C} = gen_tcp:connect(H, P, []),
timer:sleep(100),
ok = info_action(list_connections,
- rabbit_networking:connection_info_keys(), false),
+ rabbit_networking:info_keys(), false),
%% close_connection
[ConnPid] = rabbit_networking:connections(),
ok = control_action(close_connection, [rabbit_misc:pid_to_string(ConnPid),