summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDiana Corbacho <diana@rabbitmq.com>2019-05-28 23:43:46 +0100
committerDiana Corbacho <diana@rabbitmq.com>2019-05-28 23:43:46 +0100
commitd6f4bdc10a7e752e4b19a1db0e5c5a7d83a3fccd (patch)
tree2c4ac38817b8eca773669e4049e7356d8b1cefde /src
parent43dfd5021b0fb012316ec6e9ad388f2cae14ef02 (diff)
downloadrabbitmq-server-git-d6f4bdc10a7e752e4b19a1db0e5c5a7d83a3fccd.tar.gz
'check' function for health check of virtual hosts
[#163451547]
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_vhost_sup_sup.erl18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/rabbit_vhost_sup_sup.erl b/src/rabbit_vhost_sup_sup.erl
index 46a2b485f2..d9d6091c39 100644
--- a/src/rabbit_vhost_sup_sup.erl
+++ b/src/rabbit_vhost_sup_sup.erl
@@ -30,6 +30,7 @@
save_vhost_process/2]).
-export([delete_on_all_nodes/1, start_on_all_nodes/1]).
-export([is_vhost_alive/1]).
+-export([check/0]).
%% Internal
-export([stop_and_delete_vhost/1]).
@@ -260,3 +261,20 @@ vhost_restart_strategy() ->
transient -> transient;
permanent -> permanent
end.
+
+check() ->
+ VHosts = rabbit_vhost:list(),
+ lists:filter(
+ fun(V) ->
+ case rabbit_vhost_sup_sup:get_vhost_sup(V) of
+ {ok, Sup} ->
+ MsgStores = [Pid || {Name, Pid, _, _} <- supervisor:which_children(Sup),
+ lists:member(Name, [msg_store_persistent,
+ msg_store_transient])],
+ not is_vhost_alive(V) orelse (not lists:all(fun(P) ->
+ erlang:is_process_alive(P)
+ end, MsgStores));
+ {error, _} ->
+ true
+ end
+ end, VHosts).