getCPU() fix parsing lines
This commit is contained in:
parent
4f1bde9ec5
commit
e9fedd4d5b
18
lib/cpu.js
18
lib/cpu.js
@ -322,21 +322,21 @@ function getCpu() {
|
||||
if (result.cache.l3) { result.cache.l3 = parseInt(result.cache.l3) * (result.cache.l3.indexOf('K') !== -1 ? 1024 : 1); }
|
||||
|
||||
// socket type
|
||||
lines = [];
|
||||
let lines2 = [];
|
||||
exec('export LC_ALL=C; dmidecode –t 4 2>/dev/null | grep "Upgrade: Socket"; unset LC_ALL', function (error2, stdout2) {
|
||||
lines = stdout2.toString().split('\n');
|
||||
if (lines && lines.length) {
|
||||
result.socket = util.getValue(lines, 'Upgrade').replace('Socket', '').trim();
|
||||
lines2 = stdout2.toString().split('\n');
|
||||
if (lines2 && lines2.length) {
|
||||
result.socket = util.getValue(lines2, 'Upgrade').replace('Socket', '').trim();
|
||||
}
|
||||
|
||||
// # processurs & # threads/core - method 1
|
||||
let threadsPerCoreInt = 0;
|
||||
lines = [];
|
||||
let lines3 = [];
|
||||
exec('cat /proc/cpuinfo | grep -E "physical id|core id"', function (error2, stdout3) {
|
||||
lines = stdout3.toString().split('\n');
|
||||
if (lines && lines.length) {
|
||||
result.processors = util.countUniqueLines(lines, 'physical id') || 1;
|
||||
result.physicalCores = util.countUniqueLines(lines, 'core id') / result.processors;
|
||||
lines3 = stdout3.toString().split('\n');
|
||||
if (lines3 && lines3.length) {
|
||||
result.processors = util.countUniqueLines(lines3, 'physical id') || 1;
|
||||
result.physicalCores = util.countUniqueLines(lines3, 'core id') / result.processors;
|
||||
if (result.physicalCores) {
|
||||
threadsPerCoreInt = result.cores / result.physicalCores;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user