fix(emqx_os_mon): call load_ctl (lc) to get accurate memory stats

Prior to this commit, the RAM usage ratio reported by memsup is
used to trigger EMQX alarm.
This ratio counted system cache as 'used', so quite often
a false alarm is triggered.
With lc 0.3.0, the usage is caculated without cached RAM
This commit is contained in:
Zaiming (Stone) Shi 2022-05-11 17:27:56 +02:00
parent eb592df275
commit 95f81126ca
1 changed files with 4 additions and 10 deletions

View File

@ -77,17 +77,11 @@ set_procmem_high_watermark(Float) ->
memsup:set_procmem_high_watermark(Float).
current_sysmem_percent() ->
case erlang:whereis(memsup) of
undefined ->
case load_ctl:get_memory_usage() of
0 ->
undefined;
_Pid ->
{Total, Allocated, _Worst} = memsup:get_memory_data(),
case Total =/= 0 of
true ->
erlang:floor((Allocated / Total) * 10000) / 100;
false ->
undefined
end
Ratio ->
erlang:floor(Ratio * 10000) / 100
end.
%%--------------------------------------------------------------------