From 5605b84b779851260cfa40565a7e7b0768b3413d Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Tue, 12 Jul 2022 06:23:58 +0200 Subject: [PATCH] cpu() fix physical cores parsing --- lib/cpu.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/cpu.js b/lib/cpu.js index 149e166..09c501a 100644 --- a/lib/cpu.js +++ b/lib/cpu.js @@ -713,8 +713,10 @@ function getCpu() { // const coresPerSocketInt = parseInt(util.getValue(lines, 'cores(s) per socket') || '1', 10); const processors = util.getValue(lines, 'socket(s)') || '1'; let threadsPerCoreInt = parseInt(threadsPerCore, 10); - let processorsInt = parseInt(processors, 10); - result.physicalCores = result.cores / threadsPerCoreInt; + let processorsInt = parseInt(processors, 10) || 1; + const cpus = (parseInt(util.getValue(lines, 'cpu(s)'), 10) || 1); + const coresPerSocket = parseInt(util.getValue(lines, 'core(s) per socket'), 10); + result.physicalCores = coresPerSocket ? coresPerSocket * processorsInt : result.cores / threadsPerCoreInt; result.processors = processorsInt; result.governor = util.getValue(lines, 'governor') || '';