Merge pull request #8094 from zmstone/0531-skip-non-linux-os-for-sysmem-alarm-update

fix: ignore other os when updating sysmem alarm
This commit is contained in:
Zaiming (Stone) Shi 2022-05-31 12:33:03 +01:00 committed by GitHub
commit e0ff930d61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 10 deletions

View File

@ -168,17 +168,12 @@ start_cpu_check_timer() ->
_ -> start_timer(Interval, cpu_check)
end.
is_sysmem_check_supported() ->
{unix, linux} =:= os:type().
start_mem_check_timer() ->
Interval = emqx:get_config([sysmon, os, mem_check_interval]),
IsSupported =
case os:type() of
{unix, linux} ->
true;
_ ->
%% sorry Mac and windows, for now
false
end,
case is_integer(Interval) andalso IsSupported of
case is_integer(Interval) andalso is_sysmem_check_supported() of
true ->
start_timer(Interval, mem_check);
false ->
@ -196,7 +191,11 @@ update_mem_alarm_status(HWM) when HWM > 1.0 orelse HWM < 0.0 ->
#{},
<<"Deactivated mem usage alarm due to out of range threshold">>
);
update_mem_alarm_status(HWM0) ->
update_mem_alarm_status(HWM) ->
is_sysmem_check_supported() andalso
do_update_mem_alarm_status(HWM).
do_update_mem_alarm_status(HWM0) ->
HWM = HWM0 * 100,
Usage = current_sysmem_percent(),
case Usage > HWM of