fix(emqx_mgmt): return 0 for non-linux systems

This commit is contained in:
Zaiming (Stone) Shi 2022-05-31 14:09:56 +02:00
parent f4886206ef
commit a2db7226c9
1 changed files with 9 additions and 1 deletions

View File

@ -121,7 +121,7 @@ list_nodes() ->
lookup_node(Node) -> node_info(Node).
node_info() ->
{UsedRatio, Total} = load_ctl:get_sys_memory(),
{UsedRatio, Total} = get_sys_memory(),
Info = maps:from_list([{K, list_to_binary(V)} || {K, V} <- emqx_vm:loads()]),
BrokerInfo = emqx_sys:info(),
Info#{
@ -142,6 +142,14 @@ node_info() ->
role => mria_rlog:role()
}.
get_sys_memory() ->
case os:type() of
{unix, linux} ->
load_ctl:get_sys_memory();
_ ->
{0, 0}
end.
node_info(Node) ->
wrap_rpc(emqx_management_proto_v1:node_info(Node)).