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); }
|
if (result.cache.l3) { result.cache.l3 = parseInt(result.cache.l3) * (result.cache.l3.indexOf('K') !== -1 ? 1024 : 1); }
|
||||||
|
|
||||||
// socket type
|
// 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) {
|
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');
|
lines2 = stdout2.toString().split('\n');
|
||||||
if (lines && lines.length) {
|
if (lines2 && lines2.length) {
|
||||||
result.socket = util.getValue(lines, 'Upgrade').replace('Socket', '').trim();
|
result.socket = util.getValue(lines2, 'Upgrade').replace('Socket', '').trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
// # processurs & # threads/core - method 1
|
// # processurs & # threads/core - method 1
|
||||||
let threadsPerCoreInt = 0;
|
let threadsPerCoreInt = 0;
|
||||||
lines = [];
|
let lines3 = [];
|
||||||
exec('cat /proc/cpuinfo | grep -E "physical id|core id"', function (error2, stdout3) {
|
exec('cat /proc/cpuinfo | grep -E "physical id|core id"', function (error2, stdout3) {
|
||||||
lines = stdout3.toString().split('\n');
|
lines3 = stdout3.toString().split('\n');
|
||||||
if (lines && lines.length) {
|
if (lines3 && lines3.length) {
|
||||||
result.processors = util.countUniqueLines(lines, 'physical id') || 1;
|
result.processors = util.countUniqueLines(lines3, 'physical id') || 1;
|
||||||
result.physicalCores = util.countUniqueLines(lines, 'core id') / result.processors;
|
result.physicalCores = util.countUniqueLines(lines3, 'core id') / result.processors;
|
||||||
if (result.physicalCores) {
|
if (result.physicalCores) {
|
||||||
threadsPerCoreInt = result.cores / result.physicalCores;
|
threadsPerCoreInt = result.cores / result.physicalCores;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user