Skip to content

Commit e0917f2

Browse files
MB-47591: Add cpu_host_cores_available metric
Change-Id: I6b94342091a10fc8471300754aeb7720e8aaca79 Reviewed-on: https://review.couchbase.org/c/ns_server/+/174610 Well-Formed: Restriction Checker Well-Formed: Build Bot <[email protected]> Reviewed-by: Artem Stemkovski <[email protected]> Tested-by: Build Bot <[email protected]> Tested-by: Timofey Barmin <[email protected]>
1 parent b0a57de commit e0917f2

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/sigar.erl

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -168,18 +168,16 @@ unpack_global(Bin) ->
168168
CGroupMem = {maps:get(memory_max, CgroupsInfo, 0),
169169
maps:get(memory_current, CgroupsInfo, 0)},
170170
{MemLimit, _} = memory_quota:choose_limit(MemTotal, MemUsed, CGroupMem),
171+
%% Suppressing dialyzer warning here
172+
%% Dialyzer thinks that system_info can't return 'unknown', while according
173+
%% to doc it seems like it actually can. So, in order to avoid a warning
174+
%% the value is compared with 0 insead of explicit match to 'unknown'
175+
HostCoresAvailable = case erlang:system_info(logical_processors) of
176+
P when is_number(P), P > 0 -> P;
177+
_ -> 0
178+
end,
171179
CoresAvailable = case maps:get(num_cpu_prc, CgroupsInfo, undefined) of
172-
undefined ->
173-
%% Suppressing dialyzer warning here
174-
%% Dialyzer thinks that system_info can't return
175-
%% 'unknown', while according to doc it seems like
176-
%% it actually can. So, in order to avoid a warning
177-
%% the value is compared with 0 insead of explicit
178-
%% match to 'unknown'
179-
case erlang:system_info(logical_processors) of
180-
N when is_number(N), N > 0 -> N;
181-
_ -> 0
182-
end;
180+
undefined -> HostCoresAvailable;
183181
N -> N / 100 %% do not round it,
184182
%% cpu utilization will break
185183
end,
@@ -193,6 +191,7 @@ unpack_global(Bin) ->
193191

194192
Gauges =
195193
[{cpu_cores_available, CoresAvailable},
194+
{cpu_host_cores_available, HostCoresAvailable},
196195
{swap_total, SwapTotal},
197196
{swap_used, SwapUsed},
198197
{mem_limit, MemLimit},

0 commit comments

Comments
 (0)