Ver código fonte

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

fix: ignore other os when updating sysmem alarm
Zaiming (Stone) Shi 3 anos atrás
pai
commit
e0ff930d61
1 arquivos alterados com 9 adições e 10 exclusões
  1. 9 10
      apps/emqx/src/emqx_os_mon.erl

+ 9 - 10
apps/emqx/src/emqx_os_mon.erl

@@ -168,17 +168,12 @@ start_cpu_check_timer() ->
         _ -> start_timer(Interval, cpu_check)
         _ -> start_timer(Interval, cpu_check)
     end.
     end.
 
 
+is_sysmem_check_supported() ->
+    {unix, linux} =:= os:type().
+
 start_mem_check_timer() ->
 start_mem_check_timer() ->
     Interval = emqx:get_config([sysmon, os, mem_check_interval]),
     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 ->
         true ->
             start_timer(Interval, mem_check);
             start_timer(Interval, mem_check);
         false ->
         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">>
         <<"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,
     HWM = HWM0 * 100,
     Usage = current_sysmem_percent(),
     Usage = current_sysmem_percent(),
     case Usage > HWM of
     case Usage > HWM of