fix: hide cpu_status if os_check is not supported
This commit is contained in:
parent
b817e03c08
commit
8b23ee86b3
|
@ -390,18 +390,15 @@ compat_windows(Fun) ->
|
|||
|
||||
compat_windows(Fun, Args) ->
|
||||
try
|
||||
case is_windows() of
|
||||
true -> 0.0;
|
||||
false when Args =:= [] -> Fun();
|
||||
false -> Fun(Args)
|
||||
case emqx_os_mon:is_os_check_supported() of
|
||||
false -> 0.0;
|
||||
true when Args =:= [] -> Fun();
|
||||
true -> Fun(Args)
|
||||
end
|
||||
catch
|
||||
_:_ -> 0.0
|
||||
end.
|
||||
|
||||
is_windows() ->
|
||||
os:type() =:= {win32, nt}.
|
||||
|
||||
load(Avg) ->
|
||||
floor((Avg / 256) * 100) / 100.
|
||||
|
||||
|
|
|
@ -185,16 +185,27 @@ node_info(Nodes) ->
|
|||
stopped_node_info(Node) ->
|
||||
{Node, #{node => Node, node_status => 'stopped', role => core}}.
|
||||
|
||||
%% Hide cpu stats if os_check is not supported.
|
||||
vm_stats() ->
|
||||
Idle = vm_stats('cpu.idle'),
|
||||
{MemUsedRatio, MemTotal} = get_sys_memory(),
|
||||
[
|
||||
{run_queue, vm_stats('run.queue')},
|
||||
{cpu_idle, Idle},
|
||||
{cpu_use, 100 - Idle},
|
||||
{total_memory, MemTotal},
|
||||
{used_memory, erlang:round(MemTotal * MemUsedRatio)}
|
||||
].
|
||||
cpu_stats() ++
|
||||
[
|
||||
{run_queue, vm_stats('run.queue')},
|
||||
{total_memory, MemTotal},
|
||||
{used_memory, erlang:round(MemTotal * MemUsedRatio)}
|
||||
].
|
||||
|
||||
cpu_stats() ->
|
||||
case emqx_os_mon:is_os_check_supported() of
|
||||
false ->
|
||||
[];
|
||||
true ->
|
||||
Idle = vm_stats('cpu.idle'),
|
||||
[
|
||||
{cpu_idle, Idle},
|
||||
{cpu_use, 100 - Idle}
|
||||
]
|
||||
end.
|
||||
|
||||
vm_stats('cpu.idle') ->
|
||||
case emqx_vm:cpu_util([detailed]) of
|
||||
|
|
Loading…
Reference in New Issue