chore: replace recon by obsserver_cli 1.7.0

This commit is contained in:
zhongwencool 2021-08-25 13:36:27 +08:00 committed by turtleDeng
parent f4e3eeb2b2
commit 468102f462
5 changed files with 13 additions and 37 deletions

View File

@ -5,7 +5,7 @@ delayed {
max_delayed_messages = 0 max_delayed_messages = 0
} }
recon { observer_cli {
enable = true enable = true
} }

View File

@ -34,7 +34,7 @@ stop(_State) ->
maybe_enable_modules() -> maybe_enable_modules() ->
emqx:get_config([delayed, enable], true) andalso emqx_delayed:enable(), emqx:get_config([delayed, enable], true) andalso emqx_delayed:enable(),
emqx:get_config([telemetry, enable], true) andalso emqx_telemetry:enable(), emqx:get_config([telemetry, enable], true) andalso emqx_telemetry:enable(),
emqx:get_config([recon, enable], true) andalso emqx_recon:enable(), emqx:get_config([observer_cli, enable], true) andalso emqx_observer_cli:enable(),
emqx_event_message:enable(), emqx_event_message:enable(),
emqx_rewrite:enable(), emqx_rewrite:enable(),
emqx_topic_metrics:enable(). emqx_topic_metrics:enable().
@ -42,7 +42,7 @@ maybe_enable_modules() ->
maybe_disable_modules() -> maybe_disable_modules() ->
emqx:get_config([delayed, enable], true) andalso emqx_delayed:disable(), emqx:get_config([delayed, enable], true) andalso emqx_delayed:disable(),
emqx:get_config([telemetry, enable], true) andalso emqx_telemetry:disable(), emqx:get_config([telemetry, enable], true) andalso emqx_telemetry:disable(),
emqx:get_config([recon, enable], true) andalso emqx_recon:disable(), emqx:get_config([observer_cli, enable], true) andalso emqx_observer_cli:disable(),
emqx_event_message:disable(), emqx_event_message:disable(),
emqx_rewrite:disable(), emqx_rewrite:disable(),
emqx_topic_metrics:disable(). emqx_topic_metrics:disable().

View File

@ -14,7 +14,7 @@
%% limitations under the License. %% limitations under the License.
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
-module(emqx_recon). -module(emqx_observer_cli).
-export([ enable/0 -export([ enable/0
, disable/0 , disable/0
@ -27,51 +27,27 @@
%% enable/disable %% enable/disable
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
enable() -> enable() ->
emqx_ctl:register_command(recon, {?MODULE, cmd}, []),
emqx_ctl:register_command(observer, {?MODULE, cmd}, []). emqx_ctl:register_command(observer, {?MODULE, cmd}, []).
disable() -> disable() ->
emqx_ctl:unregister_command(recon),
emqx_ctl:unregister_command(observer). emqx_ctl:unregister_command(observer).
cmd(["status"]) -> cmd(["status"]) ->
observer_cli:start(); observer_cli:start();
cmd(["memory"]) ->
Print = fun(Key, Keyword) ->
emqx_ctl:print("~-20s: ~w~n", [concat(Key, Keyword), recon_alloc:memory(Key, Keyword)])
end,
[Print(Key, Keyword) || Key <- [usage, used, allocated, unused], Keyword <- [current, max]];
cmd(["allocated"]) ->
Print = fun(Keyword, Key, Val) -> emqx_ctl:print("~-20s: ~w~n", [concat(Key, Keyword), Val]) end,
Alloc = fun(Keyword) -> recon_alloc:memory(allocated_types, Keyword) end,
[Print(Keyword, Key, Val) || Keyword <- [current, max], {Key, Val} <- Alloc(Keyword)];
cmd(["bin_leak"]) -> cmd(["bin_leak"]) ->
[emqx_ctl:print("~p~n", [Row]) || Row <- recon:bin_leak(100)]; [emqx_ctl:print("~p~n", [Row]) || Row <- recon:bin_leak(100)];
cmd(["node_stats"]) -> cmd(["load", Mod]) ->
recon:node_stats_print(10, 1000); Module = list_to_existing_atom(Mod),
Nodes = nodes(),
cmd(["remote_load", Mod]) -> Res = remote_load(Nodes, Module),
emqx_ctl:print("~p~n", [remote_load(list_to_atom(Mod))]); emqx_ctl:print("Loaded ~p module on ~p on ~n", [Mod, Nodes, Res]);
cmd(["proc_count", Attr, N]) ->
emqx_ctl:print("~p~n", [recon:proc_count(list_to_atom(Attr), list_to_integer(N))]);
cmd(_) -> cmd(_) ->
emqx_ctl:usage([{"observer status", "observer_cli:start()"}, emqx_ctl:usage([{"observer status", "observer_cli:start()"},
{"recon memory", "recon_alloc:memory/2"}, {"observer bin_leak", "recon:bin_leak(100)"},
{"recon allocated", "recon_alloc:memory(allocated_types, current|max)"}, {"observer load Mod", "recon:remote_load(Mod) to all nodes"}]).
{"recon bin_leak", "recon:bin_leak(100)"},
{"recon node_stats", "recon:node_stats(10, 1000)"},
{"recon remote_load Mod", "recon:remote_load(Mod)"},
{"recon proc_count Attr N","recon:proc_count(Attr, N)"}]).
concat(Key, Keyword) ->
lists:concat([atom_to_list(Key), "/", atom_to_list(Keyword)]).
remote_load(Module) -> remote_load(nodes(), Module).
%% recon:remote_load/1 has a bug, when nodes() returns [], it is %% recon:remote_load/1 has a bug, when nodes() returns [], it is
%% taken by recon as a node name. %% taken by recon as a node name.

View File

@ -681,7 +681,7 @@ case "$1" in
shift shift
relx_nodetool rpc emqx_ctl run_command "$@" relx_nodetool rpc_infinity emqx_ctl run_command "$@"
;; ;;
rpc) rpc)
assert_node_alive assert_node_alive

View File

@ -57,7 +57,7 @@
, {pbkdf2, {git, "https://github.com/emqx/erlang-pbkdf2.git", {tag, "2.0.4"}}} , {pbkdf2, {git, "https://github.com/emqx/erlang-pbkdf2.git", {tag, "2.0.4"}}}
, {emqtt, {git, "https://github.com/emqx/emqtt", {tag, "1.4.2"}}} , {emqtt, {git, "https://github.com/emqx/emqtt", {tag, "1.4.2"}}}
, {rulesql, {git, "https://github.com/emqx/rulesql", {tag, "0.1.2"}}} , {rulesql, {git, "https://github.com/emqx/rulesql", {tag, "0.1.2"}}}
, {observer_cli, "1.6.1"} % NOTE: depends on recon 2.5.x , {observer_cli, "1.7.0"} % NOTE: depends on recon 2.5.x
, {getopt, "1.0.2"} , {getopt, "1.0.2"}
, {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "0.14.1"}}} , {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "0.14.1"}}}
, {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.12.1"}}} , {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.12.1"}}}