Skip to content

Commit 661c972

Browse files
author
Emile Joubert
committed
Split rabbitmqctl status query
1 parent 75f46f8 commit 661c972

File tree

3 files changed

+57
-21
lines changed

3 files changed

+57
-21
lines changed

docs/rabbitmqctl.1.xml

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,9 @@
184184
<listitem>
185185
<para>
186186
Displays broker status information such as the running applications
187-
on the current Erlang node, RabbitMQ and Erlang versions, OS, memory
188-
and environment details and which nodes are clustered.
187+
on the current Erlang node, RabbitMQ and Erlang versions and OS name.
188+
(See the <command>cluster_status</command> command to find out which
189+
nodes are clustered and running.)
189190
</para>
190191
<para>
191192
Diagnostic information is displayed if the broker is not running,
@@ -381,6 +382,20 @@
381382
</para>
382383
</listitem>
383384
</varlistentry>
385+
<varlistentry>
386+
<term><cmdsynopsis><command>cluster_status</command></cmdsynopsis></term>
387+
<listitem>
388+
<para>
389+
Displays all the nodes in the cluster grouped by node type,
390+
together with the currently running nodes.
391+
</para>
392+
<para role="example-prefix">For example:</para>
393+
<screen role="example">rabbitmqctl cluster_status</screen>
394+
<para role="example">
395+
This command displays the nodes in the cluster.
396+
</para>
397+
</listitem>
398+
</varlistentry>
384399
</variablelist>
385400
</refsect2>
386401

@@ -1283,6 +1298,16 @@
12831298
</para>
12841299
</listitem>
12851300
</varlistentry>
1301+
<varlistentry>
1302+
<term><cmdsynopsis><command>environment</command></cmdsynopsis></term>
1303+
<listitem>
1304+
<para>
1305+
Display the name and value of each variable in the application environment.
1306+
This can be used to verify that options specified for the rabbit
1307+
application in the configuration file have been read.
1308+
</para>
1309+
</listitem>
1310+
</varlistentry>
12861311
<varlistentry>
12871312
<term><cmdsynopsis><command>report</command></cmdsynopsis></term>
12881313
<listitem>

src/rabbit.erl

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
-behaviour(application).
2020

21-
-export([prepare/0, start/0, stop/0, stop_and_halt/0, status/0,
21+
-export([prepare/0, start/0, stop/0, stop_and_halt/0, status/0, environment/0,
2222
rotate_logs/1]).
2323

2424
-export([start/2, stop/1]).
@@ -180,12 +180,10 @@
180180
-spec(status/0 ::
181181
() -> [{pid, integer()} |
182182
{running_applications, [{atom(), string(), string()}]} |
183-
{os , {atom(), atom()}} |
184-
{erlang_version , string()} |
185-
{memory , any()} |
186-
{env , [{atom() | term()}]} |
187-
{nodes, [{rabbit_mnesia:node_type(), [node()]}]} |
188-
{running_nodes, [node()]}]).
183+
{os, {atom(), atom()}} |
184+
{erlang_version, string()} |
185+
{memory, any()}]).
186+
-spec(environment/0 :: () -> [{atom() | term()}]).
189187
-spec(log_location/1 :: ('sasl' | 'kernel') -> log_location()).
190188

191189
-spec(maybe_insert_default_data/0 :: () -> 'ok').
@@ -225,11 +223,12 @@ status() ->
225223
{running_applications, application:which_applications()},
226224
{os, os:type()},
227225
{erlang_version, erlang:system_info(system_version)},
228-
{memory, erlang:memory()},
229-
{env, lists:filter(fun ({default_pass, _}) -> false;
230-
(_) -> true
231-
end, application:get_all_env(rabbit))}] ++
232-
rabbit_mnesia:status().
226+
{memory, erlang:memory()}].
227+
228+
environment() ->
229+
lists:filter(fun ({default_pass, _}) -> false;
230+
(_) -> true
231+
end, application:get_all_env(rabbit)).
233232

234233
rotate_logs(BinarySuffix) ->
235234
Suffix = binary_to_list(BinarySuffix),

src/rabbit_control.erl

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,15 @@ action(wait, Node, [], _Opts, Inform) ->
192192

193193
action(status, Node, [], _Opts, Inform) ->
194194
Inform("Status of node ~p", [Node]),
195-
case call(Node, {rabbit, status, []}) of
196-
{badrpc, _} = Res -> Res;
197-
Res -> io:format("~p~n", [Res]),
198-
ok
199-
end;
195+
display_call_result(Node, {rabbit, status, []});
196+
197+
action(cluster_status, Node, [], _Opts, Inform) ->
198+
Inform("Cluster status of node ~p", [Node]),
199+
display_call_result(Node, {rabbit_mnesia, status, []});
200+
201+
action(environment, Node, _App, _Opts, Inform) ->
202+
Inform("Application environment of node ~p", [Node]),
203+
display_call_result(Node, {rabbit, environment, []});
200204

201205
action(rotate_logs, Node, [], _Opts, Inform) ->
202206
Inform("Reopening logs for node ~p", [Node]),
@@ -333,8 +337,9 @@ action(list_permissions, Node, [], Opts, Inform) ->
333337

334338
action(report, Node, _Args, _Opts, Inform) ->
335339
io:format("Reporting server status on ~p~n", [erlang:universaltime()]),
336-
[action(status, N, [], [], Inform) ||
337-
N <- rpc_call(Node, rabbit_mnesia, running_clustered_nodes, [])],
340+
[ok = action(Action, N, [], [], Inform) ||
341+
N <- rpc_call(Node, rabbit_mnesia, running_clustered_nodes, []),
342+
Action <- [status, cluster_status, environment]],
338343
VHosts = rpc_call(Node, rabbit_vhost, list, []),
339344
[print_report(Node, Q) || Q <- ?GLOBAL_QUERIES],
340345
[print_report(Node, Q, [V]) || Q <- ?VHOST_QUERIES, V <- VHosts],
@@ -416,6 +421,13 @@ display_list(L) when is_list(L) ->
416421
ok;
417422
display_list(Other) -> Other.
418423

424+
display_call_result(Node, MFA) ->
425+
case call(Node, MFA) of
426+
{badrpc, _} = Res -> Res;
427+
Res -> io:format("~p~n", [Res]),
428+
ok
429+
end.
430+
419431
call(Node, {Mod, Fun, Args}) ->
420432
rpc_call(Node, Mod, Fun, lists:map(fun list_to_binary/1, Args)).
421433

0 commit comments

Comments
 (0)