cpuTemperature() fix sensors parsingg AMD (linux)
This commit is contained in:
parent
8bcc01bc51
commit
1cd012ea59
@ -90,6 +90,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page.
|
|||||||
|
|
||||||
| Version | Date | Comment |
|
| Version | Date | Comment |
|
||||||
| ------- | ---------- | --------------------------------------------------------------------------------------------------- |
|
| ------- | ---------- | --------------------------------------------------------------------------------------------------- |
|
||||||
|
| 5.27.16 | 2025-12-23 | `cpuTemperature()` fix sensors parsingg AMD (linux) |
|
||||||
| 5.27.15 | 2025-12-22 | Updated docs |
|
| 5.27.15 | 2025-12-22 | Updated docs |
|
||||||
| 5.27.14 | 2025-12-15 | `fsSize()` fix drive sanitation (windows) |
|
| 5.27.14 | 2025-12-15 | `fsSize()` fix drive sanitation (windows) |
|
||||||
| 5.27.13 | 2025-12-10 | `cpuCurrentSpeed()` fix hasOwnProperty |
|
| 5.27.13 | 2025-12-10 | `cpuCurrentSpeed()` fix hasOwnProperty |
|
||||||
|
|||||||
@ -57,6 +57,11 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">5.27.16</th>
|
||||||
|
<td>2025-12-23</td>
|
||||||
|
<td><span class="code">cpuTemperature()</span> fix sensor parsing for AMD (linux)</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">5.27.15</th>
|
<th scope="row">5.27.15</th>
|
||||||
<td>2025-12-22</td>
|
<td>2025-12-22</td>
|
||||||
|
|||||||
@ -170,7 +170,7 @@
|
|||||||
<img class="logo" src="assets/logo.png" alt="logo">
|
<img class="logo" src="assets/logo.png" alt="logo">
|
||||||
<div class="title">systeminformation</div>
|
<div class="title">systeminformation</div>
|
||||||
<div class="subtitle"><span id="typed"></span> </div>
|
<div class="subtitle"><span id="typed"></span> </div>
|
||||||
<div class="version">New Version: <span id="version">5.27.15</span></div>
|
<div class="version">New Version: <span id="version">5.27.16</span></div>
|
||||||
<button class="btn btn-light" onclick="location.href='https://github.com/sebhildebrandt/systeminformation'">View on Github <i class=" fab fa-github"></i></button>
|
<button class="btn btn-light" onclick="location.href='https://github.com/sebhildebrandt/systeminformation'">View on Github <i class=" fab fa-github"></i></button>
|
||||||
</div>
|
</div>
|
||||||
<div class="down">
|
<div class="down">
|
||||||
|
|||||||
63
lib/cpu.js
63
lib/cpu.js
@ -728,8 +728,8 @@ function getCpu() {
|
|||||||
result.flags = flags;
|
result.flags = flags;
|
||||||
result.virtualization = flags.indexOf('vmx') > -1 || flags.indexOf('svm') > -1;
|
result.virtualization = flags.indexOf('vmx') > -1 || flags.indexOf('svm') > -1;
|
||||||
if (_darwin) {
|
if (_darwin) {
|
||||||
exec('sysctl machdep.cpu hw.cpufrequency_max hw.cpufrequency_min hw.packages hw.physicalcpu_max hw.ncpu hw.tbfrequency hw.cpufamily hw.cpusubfamily', function (error, stdout) {
|
exec('sysctl machdep.cpu hw.cpufrequency_max hw.cpufrequency_min hw.packages hw.physicalcpu_max hw.ncpu hw.tbfrequency hw.cpufamily hw.cpusubfamily', (error, stdout) => {
|
||||||
let lines = stdout.toString().split('\n');
|
const lines = stdout.toString().split('\n');
|
||||||
const modelline = util.getValue(lines, 'machdep.cpu.brand_string');
|
const modelline = util.getValue(lines, 'machdep.cpu.brand_string');
|
||||||
const modellineParts = modelline.split('@');
|
const modellineParts = modelline.split('@');
|
||||||
result.brand = modellineParts[0].trim();
|
result.brand = modellineParts[0].trim();
|
||||||
@ -759,12 +759,12 @@ function getCpu() {
|
|||||||
const performanceCores = clusters.filter((line) => line.indexOf('"P"') >= 0).length;
|
const performanceCores = clusters.filter((line) => line.indexOf('"P"') >= 0).length;
|
||||||
result.efficiencyCores = efficiencyCores;
|
result.efficiencyCores = efficiencyCores;
|
||||||
result.performanceCores = performanceCores;
|
result.performanceCores = performanceCores;
|
||||||
} catch (e) {
|
} catch {
|
||||||
util.noop();
|
util.noop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (countProcessors) {
|
if (countProcessors) {
|
||||||
result.processors = parseInt(countProcessors) || 1;
|
result.processors = parseInt(countProcessors, 10) || 1;
|
||||||
}
|
}
|
||||||
if (countCores && countThreads) {
|
if (countCores && countThreads) {
|
||||||
result.cores = parseInt(countThreads) || util.cores();
|
result.cores = parseInt(countThreads) || util.cores();
|
||||||
@ -782,7 +782,7 @@ function getCpu() {
|
|||||||
if (os.cpus()[0] && os.cpus()[0].model) {
|
if (os.cpus()[0] && os.cpus()[0].model) {
|
||||||
modelline = os.cpus()[0].model;
|
modelline = os.cpus()[0].model;
|
||||||
}
|
}
|
||||||
exec('export LC_ALL=C; lscpu; echo -n "Governor: "; cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor 2>/dev/null; echo; unset LC_ALL', function (error, stdout) {
|
exec('export LC_ALL=C; lscpu; echo -n "Governor: "; cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor 2>/dev/null; echo; unset LC_ALL', (error, stdout) => {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
lines = stdout.toString().split('\n');
|
lines = stdout.toString().split('\n');
|
||||||
}
|
}
|
||||||
@ -866,7 +866,7 @@ function getCpu() {
|
|||||||
|
|
||||||
// socket type
|
// socket type
|
||||||
let lines2 = [];
|
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', (error2, stdout2) => {
|
||||||
lines2 = stdout2.toString().split('\n');
|
lines2 = stdout2.toString().split('\n');
|
||||||
if (lines2 && lines2.length) {
|
if (lines2 && lines2.length) {
|
||||||
result.socket = util.getValue(lines2, 'Upgrade').replace('Socket', '').trim() || result.socket;
|
result.socket = util.getValue(lines2, 'Upgrade').replace('Socket', '').trim() || result.socket;
|
||||||
@ -881,7 +881,7 @@ function getCpu() {
|
|||||||
if (os.cpus()[0] && os.cpus()[0].model) {
|
if (os.cpus()[0] && os.cpus()[0].model) {
|
||||||
modelline = os.cpus()[0].model;
|
modelline = os.cpus()[0].model;
|
||||||
}
|
}
|
||||||
exec('export LC_ALL=C; dmidecode -t 4; dmidecode -t 7 unset LC_ALL', function (error, stdout) {
|
exec('export LC_ALL=C; dmidecode -t 4; dmidecode -t 7 unset LC_ALL', (error, stdout) => {
|
||||||
let cache = [];
|
let cache = [];
|
||||||
if (!error) {
|
if (!error) {
|
||||||
const data = stdout.toString().split('# dmidecode');
|
const data = stdout.toString().split('# dmidecode');
|
||||||
@ -1275,7 +1275,7 @@ function cpuTemperature(callback) {
|
|||||||
});
|
});
|
||||||
if (result.cores.length > 0) {
|
if (result.cores.length > 0) {
|
||||||
result.main = Math.round(result.cores.reduce((a, b) => a + b, 0) / result.cores.length);
|
result.main = Math.round(result.cores.reduce((a, b) => a + b, 0) / result.cores.length);
|
||||||
let maxtmp = Math.max.apply(Math, result.cores);
|
const maxtmp = Math.max.apply(Math, result.cores);
|
||||||
result.max = maxtmp > result.main ? maxtmp : result.main;
|
result.max = maxtmp > result.main ? maxtmp : result.main;
|
||||||
} else {
|
} else {
|
||||||
if (result.main === null && tdieTemp !== null) {
|
if (result.main === null && tdieTemp !== null) {
|
||||||
@ -1283,6 +1283,9 @@ function cpuTemperature(callback) {
|
|||||||
result.max = tdieTemp;
|
result.max = tdieTemp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (result.main !== null && result.max === null) {
|
||||||
|
result.max = result.main;
|
||||||
|
}
|
||||||
if (result.main !== null || result.max !== null) {
|
if (result.main !== null || result.max !== null) {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(result);
|
callback(result);
|
||||||
@ -1358,27 +1361,25 @@ function cpuTemperature(callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (_darwin) {
|
if (_darwin) {
|
||||||
let osxTemp = null;
|
|
||||||
try {
|
try {
|
||||||
osxTemp = require('osx-temperature-sensor');
|
const osxTemp = require('osx-temperature-sensor');
|
||||||
} catch (er) {
|
|
||||||
osxTemp = null;
|
|
||||||
}
|
|
||||||
if (osxTemp) {
|
|
||||||
result = osxTemp.cpuTemperature();
|
result = osxTemp.cpuTemperature();
|
||||||
// round to 2 digits
|
|
||||||
if (result.main) {
|
if (result.main) {
|
||||||
|
// round to 2 digits
|
||||||
result.main = Math.round(result.main * 100) / 100;
|
result.main = Math.round(result.main * 100) / 100;
|
||||||
}
|
}
|
||||||
if (result.max) {
|
if (result.max) {
|
||||||
result.max = Math.round(result.max * 100) / 100;
|
result.max = Math.round(result.max * 100) / 100;
|
||||||
}
|
}
|
||||||
if (result.cores && result.cores.length) {
|
if (result?.cores.length) {
|
||||||
for (let i = 0; i < result.cores.length; i++) {
|
for (let i = 0; i < result.cores.length; i++) {
|
||||||
result.cores[i] = Math.round(result.cores[i] * 100) / 100;
|
result.cores[i] = Math.round(result.cores[i] * 100) / 100;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch {
|
||||||
|
util.noop();
|
||||||
}
|
}
|
||||||
|
// add new macOS temperature library here
|
||||||
|
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(result);
|
callback(result);
|
||||||
@ -1441,7 +1442,7 @@ function cpuFlags(callback) {
|
|||||||
let result = '';
|
let result = '';
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
try {
|
try {
|
||||||
exec('reg query "HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0" /v FeatureSet', util.execOptsWin, function (error, stdout) {
|
exec('reg query "HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0" /v FeatureSet', util.execOptsWin, (error, stdout) => {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
let flag_hex = stdout.split('0x').pop().trim();
|
let flag_hex = stdout.split('0x').pop().trim();
|
||||||
let flag_bin_unpadded = parseInt(flag_hex, 16).toString(2);
|
let flag_bin_unpadded = parseInt(flag_hex, 16).toString(2);
|
||||||
@ -1495,7 +1496,7 @@ function cpuFlags(callback) {
|
|||||||
}
|
}
|
||||||
resolve(result);
|
resolve(result);
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(result);
|
callback(result);
|
||||||
}
|
}
|
||||||
@ -1504,7 +1505,7 @@ function cpuFlags(callback) {
|
|||||||
}
|
}
|
||||||
if (_linux) {
|
if (_linux) {
|
||||||
try {
|
try {
|
||||||
exec('export LC_ALL=C; lscpu; unset LC_ALL', function (error, stdout) {
|
exec('export LC_ALL=C; lscpu; unset LC_ALL', (error, stdout) => {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
let lines = stdout.toString().split('\n');
|
let lines = stdout.toString().split('\n');
|
||||||
lines.forEach(function (line) {
|
lines.forEach(function (line) {
|
||||||
@ -1539,7 +1540,7 @@ function cpuFlags(callback) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_freebsd || _openbsd || _netbsd) {
|
if (_freebsd || _openbsd || _netbsd) {
|
||||||
exec('export LC_ALL=C; dmidecode -t 4 2>/dev/null; unset LC_ALL', function (error, stdout) {
|
exec('export LC_ALL=C; dmidecode -t 4 2>/dev/null; unset LC_ALL', (error, stdout) => {
|
||||||
let flags = [];
|
let flags = [];
|
||||||
if (!error) {
|
if (!error) {
|
||||||
let parts = stdout.toString().split('\tFlags:');
|
let parts = stdout.toString().split('\tFlags:');
|
||||||
@ -1559,7 +1560,7 @@ function cpuFlags(callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (_darwin) {
|
if (_darwin) {
|
||||||
exec('sysctl machdep.cpu.features', function (error, stdout) {
|
exec('sysctl machdep.cpu.features', (error, stdout) => {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
let lines = stdout.toString().split('\n');
|
let lines = stdout.toString().split('\n');
|
||||||
if (lines.length > 0 && lines[0].indexOf('machdep.cpu.features:') !== -1) {
|
if (lines.length > 0 && lines[0].indexOf('machdep.cpu.features:') !== -1) {
|
||||||
@ -1598,7 +1599,7 @@ function cpuCache(callback) {
|
|||||||
};
|
};
|
||||||
if (_linux) {
|
if (_linux) {
|
||||||
try {
|
try {
|
||||||
exec('export LC_ALL=C; lscpu; unset LC_ALL', function (error, stdout) {
|
exec('export LC_ALL=C; lscpu; unset LC_ALL', (error, stdout) => {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
let lines = stdout.toString().split('\n');
|
let lines = stdout.toString().split('\n');
|
||||||
lines.forEach(function (line) {
|
lines.forEach(function (line) {
|
||||||
@ -1630,7 +1631,7 @@ function cpuCache(callback) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_freebsd || _openbsd || _netbsd) {
|
if (_freebsd || _openbsd || _netbsd) {
|
||||||
exec('export LC_ALL=C; dmidecode -t 7 2>/dev/null; unset LC_ALL', function (error, stdout) {
|
exec('export LC_ALL=C; dmidecode -t 7 2>/dev/null; unset LC_ALL', (error, stdout) => {
|
||||||
let cache = [];
|
let cache = [];
|
||||||
if (!error) {
|
if (!error) {
|
||||||
const data = stdout.toString();
|
const data = stdout.toString();
|
||||||
@ -1661,7 +1662,7 @@ function cpuCache(callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (_darwin) {
|
if (_darwin) {
|
||||||
exec('sysctl hw.l1icachesize hw.l1dcachesize hw.l2cachesize hw.l3cachesize', function (error, stdout) {
|
exec('sysctl hw.l1icachesize hw.l1dcachesize hw.l2cachesize hw.l3cachesize', (error, stdout) => {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
let lines = stdout.toString().split('\n');
|
let lines = stdout.toString().split('\n');
|
||||||
lines.forEach(function (line) {
|
lines.forEach(function (line) {
|
||||||
@ -1788,7 +1789,7 @@ exports.cpuCache = cpuCache;
|
|||||||
function getLoad() {
|
function getLoad() {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
process.nextTick(() => {
|
process.nextTick(() => {
|
||||||
let loads = os.loadavg().map(function (x) {
|
let loads = os.loadavg().map( (x) => {
|
||||||
return x / util.cores();
|
return x / util.cores();
|
||||||
});
|
});
|
||||||
let avgLoad = parseFloat(Math.max.apply(Math, loads).toFixed(2));
|
let avgLoad = parseFloat(Math.max.apply(Math, loads).toFixed(2));
|
||||||
@ -1883,9 +1884,9 @@ function getLoad() {
|
|||||||
cores[i].rawLoadSteal = _cpus[i].loadSteal;
|
cores[i].rawLoadSteal = _cpus[i].loadSteal;
|
||||||
cores[i].rawLoadGuest = _cpus[i].loadGuest;
|
cores[i].rawLoadGuest = _cpus[i].loadGuest;
|
||||||
}
|
}
|
||||||
let totalTick = totalUser + totalSystem + totalNice + totalIrq + totalSteal + totalGuest + totalIdle;
|
const totalTick = totalUser + totalSystem + totalNice + totalIrq + totalSteal + totalGuest + totalIdle;
|
||||||
let totalLoad = totalUser + totalSystem + totalNice + totalIrq + totalSteal + totalGuest;
|
const totalLoad = totalUser + totalSystem + totalNice + totalIrq + totalSteal + totalGuest;
|
||||||
let currentTick = totalTick - _current_cpu.tick;
|
const currentTick = totalTick - _current_cpu.tick;
|
||||||
result = {
|
result = {
|
||||||
avgLoad: avgLoad,
|
avgLoad: avgLoad,
|
||||||
currentLoad: ((totalLoad - _current_cpu.load) / currentTick) * 100,
|
currentLoad: ((totalLoad - _current_cpu.load) / currentTick) * 100,
|
||||||
@ -1935,7 +1936,7 @@ function getLoad() {
|
|||||||
rawCurrentLoadGuest: result.rawCurrentLoadGuest
|
rawCurrentLoadGuest: result.rawCurrentLoadGuest
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
let cores = [];
|
const cores = [];
|
||||||
for (let i = 0; i < _corecount; i++) {
|
for (let i = 0; i < _corecount; i++) {
|
||||||
cores[i] = {};
|
cores[i] = {};
|
||||||
cores[i].load = (_cpus[i].load / _cpus[i].currentTick) * 100;
|
cores[i].load = (_cpus[i].load / _cpus[i].currentTick) * 100;
|
||||||
@ -2010,7 +2011,7 @@ function getFullLoad() {
|
|||||||
|
|
||||||
let result = 0;
|
let result = 0;
|
||||||
|
|
||||||
if (cpus && cpus.length) {
|
if (cpus?.length) {
|
||||||
for (let i = 0, len = cpus.length; i < len; i++) {
|
for (let i = 0, len = cpus.length; i < len; i++) {
|
||||||
const cpu = cpus[i].times;
|
const cpu = cpus[i].times;
|
||||||
totalUser += cpu.user;
|
totalUser += cpu.user;
|
||||||
@ -2019,7 +2020,7 @@ function getFullLoad() {
|
|||||||
totalIrq += cpu.irq;
|
totalIrq += cpu.irq;
|
||||||
totalIdle += cpu.idle;
|
totalIdle += cpu.idle;
|
||||||
}
|
}
|
||||||
let totalTicks = totalIdle + totalIrq + totalNice + totalSystem + totalUser;
|
const totalTicks = totalIdle + totalIrq + totalNice + totalSystem + totalUser;
|
||||||
result = ((totalTicks - totalIdle) / totalTicks) * 100.0;
|
result = ((totalTicks - totalIdle) / totalTicks) * 100.0;
|
||||||
}
|
}
|
||||||
resolve(result);
|
resolve(result);
|
||||||
|
|||||||
582
lib/network.js
582
lib/network.js
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user