chore: return system total and used memory in node_info

This commit is contained in:
Zaiming (Stone) Shi 2022-06-26 21:16:55 +02:00
parent 52684ca944
commit c4f1c83003
1 changed files with 11 additions and 3 deletions

View File

@ -136,13 +136,13 @@ list_nodes() ->
lookup_node(Node) -> node_info(Node).
node_info(Node) when Node =:= node() ->
Memory = emqx_vm:get_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#{node => node(),
otp_release => iolist_to_binary(otp_rel()),
memory_total => proplists:get_value(allocated, Memory),
memory_used => proplists:get_value(used, Memory),
memory_total => Total,
memory_used => erlang:round(Total * UsedRatio),
process_available => erlang:system_info(process_limit),
process_used => erlang:system_info(process_count),
max_fds =>
@ -156,6 +156,14 @@ node_info(Node) when Node =:= node() ->
node_info(Node) ->
rpc_call(Node, node_info, [Node]).
get_sys_memory() ->
case os:type() of
{unix, linux} ->
load_ctl:get_sys_memory();
_ ->
{0, 0}
end.
stopped_node_info(Node) ->
#{name => Node, node_status => 'Stopped'}.