summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmile Joubert <emile@rabbitmq.com>2011-06-02 18:12:17 +0100
committerEmile Joubert <emile@rabbitmq.com>2011-06-02 18:12:17 +0100
commit661c972ae8ecad260471aa61a1fb1e5cb5dba0c1 (patch)
tree72ebf70c3bc0e9def3c34e3bacf01c15ce476330
parent75f46f88d89af44012ab16f8f77badbe7f226733 (diff)
downloadrabbitmq-server-git-661c972ae8ecad260471aa61a1fb1e5cb5dba0c1.tar.gz
Split rabbitmqctl status query
-rw-r--r--docs/rabbitmqctl.1.xml29
-rw-r--r--src/rabbit.erl23
-rw-r--r--src/rabbit_control.erl26
3 files changed, 57 insertions, 21 deletions
diff --git a/docs/rabbitmqctl.1.xml b/docs/rabbitmqctl.1.xml
index 6e57f4932b..ceb4e98b1a 100644
--- a/docs/rabbitmqctl.1.xml
+++ b/docs/rabbitmqctl.1.xml
@@ -184,8 +184,9 @@
<listitem>
<para>
Displays broker status information such as the running applications
- on the current Erlang node, RabbitMQ and Erlang versions, OS, memory
- and environment details and which nodes are clustered.
+ on the current Erlang node, RabbitMQ and Erlang versions and OS name.
+ (See the <command>cluster_status</command> command to find out which
+ nodes are clustered and running.)
</para>
<para>
Diagnostic information is displayed if the broker is not running,
@@ -381,6 +382,20 @@
</para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><cmdsynopsis><command>cluster_status</command></cmdsynopsis></term>
+ <listitem>
+ <para>
+ Displays all the nodes in the cluster grouped by node type,
+ together with the currently running nodes.
+ </para>
+ <para role="example-prefix">For example:</para>
+ <screen role="example">rabbitmqctl cluster_status</screen>
+ <para role="example">
+ This command displays the nodes in the cluster.
+ </para>
+ </listitem>
+ </varlistentry>
</variablelist>
</refsect2>
@@ -1284,6 +1299,16 @@
</listitem>
</varlistentry>
<varlistentry>
+ <term><cmdsynopsis><command>environment</command></cmdsynopsis></term>
+ <listitem>
+ <para>
+ Display the name and value of each variable in the application environment.
+ This can be used to verify that options specified for the rabbit
+ application in the configuration file have been read.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
<term><cmdsynopsis><command>report</command></cmdsynopsis></term>
<listitem>
<para>
diff --git a/src/rabbit.erl b/src/rabbit.erl
index 88b1647473..9a3de988a2 100644
--- a/src/rabbit.erl
+++ b/src/rabbit.erl
@@ -18,7 +18,7 @@
-behaviour(application).
--export([prepare/0, start/0, stop/0, stop_and_halt/0, status/0,
+-export([prepare/0, start/0, stop/0, stop_and_halt/0, status/0, environment/0,
rotate_logs/1]).
-export([start/2, stop/1]).
@@ -180,12 +180,10 @@
-spec(status/0 ::
() -> [{pid, integer()} |
{running_applications, [{atom(), string(), string()}]} |
- {os , {atom(), atom()}} |
- {erlang_version , string()} |
- {memory , any()} |
- {env , [{atom() | term()}]} |
- {nodes, [{rabbit_mnesia:node_type(), [node()]}]} |
- {running_nodes, [node()]}]).
+ {os, {atom(), atom()}} |
+ {erlang_version, string()} |
+ {memory, any()}]).
+-spec(environment/0 :: () -> [{atom() | term()}]).
-spec(log_location/1 :: ('sasl' | 'kernel') -> log_location()).
-spec(maybe_insert_default_data/0 :: () -> 'ok').
@@ -225,11 +223,12 @@ status() ->
{running_applications, application:which_applications()},
{os, os:type()},
{erlang_version, erlang:system_info(system_version)},
- {memory, erlang:memory()},
- {env, lists:filter(fun ({default_pass, _}) -> false;
- (_) -> true
- end, application:get_all_env(rabbit))}] ++
- rabbit_mnesia:status().
+ {memory, erlang:memory()}].
+
+environment() ->
+ lists:filter(fun ({default_pass, _}) -> false;
+ (_) -> true
+ end, application:get_all_env(rabbit)).
rotate_logs(BinarySuffix) ->
Suffix = binary_to_list(BinarySuffix),
diff --git a/src/rabbit_control.erl b/src/rabbit_control.erl
index 57a3fa55c0..1fcd3de0f0 100644
--- a/src/rabbit_control.erl
+++ b/src/rabbit_control.erl
@@ -192,11 +192,15 @@ action(wait, Node, [], _Opts, Inform) ->
action(status, Node, [], _Opts, Inform) ->
Inform("Status of node ~p", [Node]),
- case call(Node, {rabbit, status, []}) of
- {badrpc, _} = Res -> Res;
- Res -> io:format("~p~n", [Res]),
- ok
- end;
+ display_call_result(Node, {rabbit, status, []});
+
+action(cluster_status, Node, [], _Opts, Inform) ->
+ Inform("Cluster status of node ~p", [Node]),
+ display_call_result(Node, {rabbit_mnesia, status, []});
+
+action(environment, Node, _App, _Opts, Inform) ->
+ Inform("Application environment of node ~p", [Node]),
+ display_call_result(Node, {rabbit, environment, []});
action(rotate_logs, Node, [], _Opts, Inform) ->
Inform("Reopening logs for node ~p", [Node]),
@@ -333,8 +337,9 @@ action(list_permissions, Node, [], Opts, Inform) ->
action(report, Node, _Args, _Opts, Inform) ->
io:format("Reporting server status on ~p~n", [erlang:universaltime()]),
- [action(status, N, [], [], Inform) ||
- N <- rpc_call(Node, rabbit_mnesia, running_clustered_nodes, [])],
+ [ok = action(Action, N, [], [], Inform) ||
+ N <- rpc_call(Node, rabbit_mnesia, running_clustered_nodes, []),
+ Action <- [status, cluster_status, environment]],
VHosts = rpc_call(Node, rabbit_vhost, list, []),
[print_report(Node, Q) || Q <- ?GLOBAL_QUERIES],
[print_report(Node, Q, [V]) || Q <- ?VHOST_QUERIES, V <- VHosts],
@@ -416,6 +421,13 @@ display_list(L) when is_list(L) ->
ok;
display_list(Other) -> Other.
+display_call_result(Node, MFA) ->
+ case call(Node, MFA) of
+ {badrpc, _} = Res -> Res;
+ Res -> io:format("~p~n", [Res]),
+ ok
+ end.
+
call(Node, {Mod, Fun, Args}) ->
rpc_call(Node, Mod, Fun, lists:map(fun list_to_binary/1, Args)).