diff --git a/rebar.config b/rebar.config index 7ae5f1d87..65dcb2f0f 100644 --- a/rebar.config +++ b/rebar.config @@ -3,7 +3,7 @@ {cowboy, "2.6.1"}, % hex {gproc, "0.8.0"}, % hex {esockd, "5.5.0"}, %hex - {ekka, "0.6.0"}, %hex + {ekka, "0.6.1"}, %hex {gen_rpc, {git, "https://github.com/emqx/gen_rpc", {tag, "2.4.1"}}}, {cuttlefish, {git, "https://github.com/emqx/cuttlefish", {tag, "v3.0.0"}}} ]}. diff --git a/src/emqx_sys_mon.erl b/src/emqx_sys_mon.erl index 7d7bdae21..f63dd95f6 100644 --- a/src/emqx_sys_mon.erl +++ b/src/emqx_sys_mon.erl @@ -57,6 +57,10 @@ start_link(Opts) -> init([Opts]) -> erlang:system_monitor(self(), parse_opt(Opts)), emqx_logger:set_proc_metadata(#{sysmon => true}), + + %% Monitor cluster partition event + ekka:monitor(partition, fun handle_partition_event/1), + {ok, start_timer(#{timer => undefined, events => []})}. start_timer(State) -> @@ -156,6 +160,15 @@ terminate(_Reason, #{timer := TRef}) -> code_change(_OldVsn, State, _Extra) -> {ok, State}. +%%-------------------------------------------------------------------- +%% Internal Functions +%%-------------------------------------------------------------------- + +handle_partition_event({partition, {occurred, Node}}) -> + alarm_handler:set_alarm({partitioned, Node}); +handle_partition_event({partition, {healed, Node}}) -> + alarm_handler:clear_alarm(partitioned). + suppress(Key, SuccFun, State = #{events := Events}) -> case lists:member(Key, Events) of true -> {noreply, State};