cpuTemperature() fix sensors parsingg AMD (linux)

This commit is contained in:
Sebastian Hildebrandt 2025-12-23 06:30:26 +01:00
parent 8bcc01bc51
commit 1cd012ea59
5 changed files with 401 additions and 252 deletions

View File

@ -90,6 +90,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page.
| 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.14 | 2025-12-15 | `fsSize()` fix drive sanitation (windows) |
| 5.27.13 | 2025-12-10 | `cpuCurrentSpeed()` fix hasOwnProperty |

View File

@ -57,6 +57,11 @@
</tr>
</thead>
<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>
<th scope="row">5.27.15</th>
<td>2025-12-22</td>

View File

@ -170,7 +170,7 @@
<img class="logo" src="assets/logo.png" alt="logo">
<div class="title">systeminformation</div>
<div class="subtitle"><span id="typed"></span>&nbsp;</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>
</div>
<div class="down">

View File

@ -728,8 +728,8 @@ function getCpu() {
result.flags = flags;
result.virtualization = flags.indexOf('vmx') > -1 || flags.indexOf('svm') > -1;
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) {
let lines = stdout.toString().split('\n');
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) => {
const lines = stdout.toString().split('\n');
const modelline = util.getValue(lines, 'machdep.cpu.brand_string');
const modellineParts = modelline.split('@');
result.brand = modellineParts[0].trim();
@ -759,12 +759,12 @@ function getCpu() {
const performanceCores = clusters.filter((line) => line.indexOf('"P"') >= 0).length;
result.efficiencyCores = efficiencyCores;
result.performanceCores = performanceCores;
} catch (e) {
} catch {
util.noop();
}
}
if (countProcessors) {
result.processors = parseInt(countProcessors) || 1;
result.processors = parseInt(countProcessors, 10) || 1;
}
if (countCores && countThreads) {
result.cores = parseInt(countThreads) || util.cores();
@ -782,7 +782,7 @@ function getCpu() {
if (os.cpus()[0] && 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) {
lines = stdout.toString().split('\n');
}
@ -866,7 +866,7 @@ function getCpu() {
// socket type
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');
if (lines2 && lines2.length) {
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) {
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 = [];
if (!error) {
const data = stdout.toString().split('# dmidecode');
@ -1275,7 +1275,7 @@ function cpuTemperature(callback) {
});
if (result.cores.length > 0) {
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;
} else {
if (result.main === null && tdieTemp !== null) {
@ -1283,6 +1283,9 @@ function cpuTemperature(callback) {
result.max = tdieTemp;
}
}
if (result.main !== null && result.max === null) {
result.max = result.main;
}
if (result.main !== null || result.max !== null) {
if (callback) {
callback(result);
@ -1358,27 +1361,25 @@ function cpuTemperature(callback) {
});
}
if (_darwin) {
let osxTemp = null;
try {
osxTemp = require('osx-temperature-sensor');
} catch (er) {
osxTemp = null;
}
if (osxTemp) {
const osxTemp = require('osx-temperature-sensor');
result = osxTemp.cpuTemperature();
// round to 2 digits
if (result.main) {
// round to 2 digits
result.main = Math.round(result.main * 100) / 100;
}
if (result.max) {
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++) {
result.cores[i] = Math.round(result.cores[i] * 100) / 100;
}
}
} catch {
util.noop();
}
// add new macOS temperature library here
if (callback) {
callback(result);
@ -1441,7 +1442,7 @@ function cpuFlags(callback) {
let result = '';
if (_windows) {
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) {
let flag_hex = stdout.split('0x').pop().trim();
let flag_bin_unpadded = parseInt(flag_hex, 16).toString(2);
@ -1495,7 +1496,7 @@ function cpuFlags(callback) {
}
resolve(result);
});
} catch (e) {
} catch {
if (callback) {
callback(result);
}
@ -1504,7 +1505,7 @@ function cpuFlags(callback) {
}
if (_linux) {
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) {
let lines = stdout.toString().split('\n');
lines.forEach(function (line) {
@ -1539,7 +1540,7 @@ function cpuFlags(callback) {
}
}
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 = [];
if (!error) {
let parts = stdout.toString().split('\tFlags:');
@ -1559,7 +1560,7 @@ function cpuFlags(callback) {
});
}
if (_darwin) {
exec('sysctl machdep.cpu.features', function (error, stdout) {
exec('sysctl machdep.cpu.features', (error, stdout) => {
if (!error) {
let lines = stdout.toString().split('\n');
if (lines.length > 0 && lines[0].indexOf('machdep.cpu.features:') !== -1) {
@ -1598,7 +1599,7 @@ function cpuCache(callback) {
};
if (_linux) {
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) {
let lines = stdout.toString().split('\n');
lines.forEach(function (line) {
@ -1630,7 +1631,7 @@ function cpuCache(callback) {
}
}
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 = [];
if (!error) {
const data = stdout.toString();
@ -1661,7 +1662,7 @@ function cpuCache(callback) {
});
}
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) {
let lines = stdout.toString().split('\n');
lines.forEach(function (line) {
@ -1788,7 +1789,7 @@ exports.cpuCache = cpuCache;
function getLoad() {
return new Promise((resolve) => {
process.nextTick(() => {
let loads = os.loadavg().map(function (x) {
let loads = os.loadavg().map( (x) => {
return x / util.cores();
});
let avgLoad = parseFloat(Math.max.apply(Math, loads).toFixed(2));
@ -1883,9 +1884,9 @@ function getLoad() {
cores[i].rawLoadSteal = _cpus[i].loadSteal;
cores[i].rawLoadGuest = _cpus[i].loadGuest;
}
let totalTick = totalUser + totalSystem + totalNice + totalIrq + totalSteal + totalGuest + totalIdle;
let totalLoad = totalUser + totalSystem + totalNice + totalIrq + totalSteal + totalGuest;
let currentTick = totalTick - _current_cpu.tick;
const totalTick = totalUser + totalSystem + totalNice + totalIrq + totalSteal + totalGuest + totalIdle;
const totalLoad = totalUser + totalSystem + totalNice + totalIrq + totalSteal + totalGuest;
const currentTick = totalTick - _current_cpu.tick;
result = {
avgLoad: avgLoad,
currentLoad: ((totalLoad - _current_cpu.load) / currentTick) * 100,
@ -1935,7 +1936,7 @@ function getLoad() {
rawCurrentLoadGuest: result.rawCurrentLoadGuest
};
} else {
let cores = [];
const cores = [];
for (let i = 0; i < _corecount; i++) {
cores[i] = {};
cores[i].load = (_cpus[i].load / _cpus[i].currentTick) * 100;
@ -2010,7 +2011,7 @@ function getFullLoad() {
let result = 0;
if (cpus && cpus.length) {
if (cpus?.length) {
for (let i = 0, len = cpus.length; i < len; i++) {
const cpu = cpus[i].times;
totalUser += cpu.user;
@ -2019,7 +2020,7 @@ function getFullLoad() {
totalIrq += cpu.irq;
totalIdle += cpu.idle;
}
let totalTicks = totalIdle + totalIrq + totalNice + totalSystem + totalUser;
const totalTicks = totalIdle + totalIrq + totalNice + totalSystem + totalUser;
result = ((totalTicks - totalIdle) / totalTicks) * 100.0;
}
resolve(result);

File diff suppressed because it is too large Load Diff