diff options
| author | Michael Klishin <michael@clojurewerkz.org> | 2016-03-02 20:12:53 +0300 |
|---|---|---|
| committer | Michael Klishin <michael@clojurewerkz.org> | 2016-03-02 20:12:53 +0300 |
| commit | 98182a9a70db53d6d99845780832ca318141a655 (patch) | |
| tree | 1b0d78fe3bcdafa0077e8d34c0820777b7a25adb | |
| parent | c2b0c69b4d6eb366c215933e0d8320f2b66bc4ab (diff) | |
| parent | 188d7a06e21d75220d0d0a718164f717a92cb70e (diff) | |
| download | rabbitmq-server-git-98182a9a70db53d6d99845780832ca318141a655.tar.gz | |
Merge branch 'rabbitmq-server-398' into stable
| -rw-r--r-- | docs/rabbitmqctl.1.xml | 15 | ||||
| -rw-r--r-- | include/rabbit_cli.hrl | 2 | ||||
| -rw-r--r-- | src/rabbit_cli.erl | 10 | ||||
| -rw-r--r-- | src/rabbit_control_main.erl | 17 | ||||
| -rw-r--r-- | src/rabbit_plugins_main.erl | 4 |
5 files changed, 35 insertions, 13 deletions
diff --git a/docs/rabbitmqctl.1.xml b/docs/rabbitmqctl.1.xml index fe24a47376..1ecf8d4d3a 100644 --- a/docs/rabbitmqctl.1.xml +++ b/docs/rabbitmqctl.1.xml @@ -1829,6 +1829,21 @@ </varlistentry> <varlistentry> + <term><cmdsynopsis><command>node_health_check</command></cmdsynopsis></term> + <listitem> + <para> + Health check of the RabbitMQ node. Verifies the rabbit application is + running, list_queues and list_channels return, and alarms are not set. + </para> + <para role="example-prefix">For example:</para> + <screen role="example">rabbitmqctl node_health_check -n rabbit@stringer</screen> + <para role="example"> + This command performs a health check on the RabbitMQ node. + </para> + </listitem> + </varlistentry> + + <varlistentry> <term><cmdsynopsis><command>environment</command></cmdsynopsis></term> <listitem> <para> diff --git a/include/rabbit_cli.hrl b/include/rabbit_cli.hrl index 2e687e2eb8..7f5db6053b 100644 --- a/include/rabbit_cli.hrl +++ b/include/rabbit_cli.hrl @@ -47,8 +47,6 @@ -define(OFFLINE_DEF, {?OFFLINE_OPT, flag}). -define(ONLINE_DEF, {?ONLINE_OPT, flag}). --define(RPC_TIMEOUT, infinity). - %% Subset of standartized exit codes from sysexits.h, see %% https://github.com/rabbitmq/rabbitmq-server/issues/396 for discussion. -define(EX_OK , 0). diff --git a/src/rabbit_cli.erl b/src/rabbit_cli.erl index 4aad3c0916..6679d9329e 100644 --- a/src/rabbit_cli.erl +++ b/src/rabbit_cli.erl @@ -255,14 +255,10 @@ print_badrpc_diagnostics(Nodes) -> %% a timeout unless we set our ticktime to be the same. So let's do %% that. rpc_call(Node, Mod, Fun, Args) -> - rpc_call(Node, Mod, Fun, Args, ?RPC_TIMEOUT). + rabbit_misc:rpc_call(Node, Mod, Fun, Args). rpc_call(Node, Mod, Fun, Args, Timeout) -> - case rpc:call(Node, net_kernel, get_net_ticktime, [], Timeout) of - {badrpc, _} = E -> E; - Time -> net_kernel:set_net_ticktime(Time, 0), - rpc:call(Node, Mod, Fun, Args, Timeout) - end. + rabbit_misc:rpc_call(Node, Mod, Fun, Args, Timeout). rpc_call(Node, Mod, Fun, Args, Ref, Pid, Timeout) -> - rpc_call(Node, Mod, Fun, Args++[Ref, Pid], Timeout). + rabbit_misc:rpc_call(Node, Mod, Fun, Args, Ref, Pid, Timeout). diff --git a/src/rabbit_control_main.erl b/src/rabbit_control_main.erl index 4cb7eb094b..b805d21e48 100644 --- a/src/rabbit_control_main.erl +++ b/src/rabbit_control_main.erl @@ -17,12 +17,13 @@ -module(rabbit_control_main). -include("rabbit.hrl"). -include("rabbit_cli.hrl"). +-include("rabbit_misc.hrl"). -export([start/0, stop/0, parse_arguments/2, action/5, action/6, sync_queue/1, cancel_sync_queue/1, become/1, purge_queue/1]). --import(rabbit_cli, [rpc_call/4, rpc_call/5, rpc_call/7]). +-import(rabbit_misc, [rpc_call/4, rpc_call/5, rpc_call/7]). -define(EXTERNAL_CHECK_INTERVAL, 1000). @@ -83,6 +84,7 @@ report, set_cluster_name, eval, + node_health_check, close_connection, {trace_on, [?VHOST_DEF]}, @@ -111,7 +113,7 @@ [stop, stop_app, start_app, wait, reset, force_reset, rotate_logs, join_cluster, change_cluster_node_type, update_cluster_nodes, forget_cluster_node, rename_cluster_node, cluster_status, status, - environment, eval, force_boot, help]). + environment, eval, force_boot, help, node_health_check]). -define(COMMANDS_WITH_TIMEOUT, [list_user_permissions, list_policies, list_queues, list_exchanges, @@ -547,6 +549,17 @@ action(eval, Node, [Expr], _Opts, _Inform) -> action(help, _Node, _Args, _Opts, _Inform) -> io:format("~s", [rabbit_ctl_usage:usage()]); +action(node_health_check, Node, _Args, _Opts, Inform) -> + Inform("Checking health of node ~p", [Node]), + try + rabbit_health_check:node(Node), + io:format("Health check passed~n") + catch + {node_is_ko, ErrorMsg, ErrorCode} -> + io:format("Heath check failed:~n~s~n", [ErrorMsg]), + halt(ErrorCode) + end; + action(Command, Node, Args, Opts, Inform) -> %% For backward compatibility, run commands accepting a timeout with %% the default timeout. diff --git a/src/rabbit_plugins_main.erl b/src/rabbit_plugins_main.erl index 4aeed4826c..e248989a7a 100644 --- a/src/rabbit_plugins_main.erl +++ b/src/rabbit_plugins_main.erl @@ -173,7 +173,7 @@ format_plugins(Node, Pattern, Opts, #cli{all = All, EnabledImplicitly = Implicit -- Enabled, {StatusMsg, Running} = - case rabbit_cli:rpc_call(Node, rabbit_plugins, active, []) of + case rabbit_misc:rpc_call(Node, rabbit_plugins, active, []) of {badrpc, _} -> {"[failed to contact ~s - status not shown]", []}; Active -> {"* = running on ~s", Active} end, @@ -279,7 +279,7 @@ sync(Node, ForceOnline, #cli{file = File}) -> rpc_call(Node, Online, Mod, Fun, Args) -> io:format("~nApplying plugin configuration to ~s...", [Node]), - case rabbit_cli:rpc_call(Node, Mod, Fun, Args) of + case rabbit_misc:rpc_call(Node, Mod, Fun, Args) of {ok, [], []} -> io:format(" nothing to do.~n", []); {ok, Start, []} -> |
