cpuTemperature() added socket and chipset temp (linux)
This commit is contained in:
+47
-2
@@ -930,9 +930,32 @@ function cpuTemperature(callback) {
|
||||
let result = {
|
||||
main: null,
|
||||
cores: [],
|
||||
max: null
|
||||
max: null,
|
||||
socket: [],
|
||||
chipset: null
|
||||
};
|
||||
if (_linux) {
|
||||
// CPU Chipset, Socket
|
||||
try {
|
||||
const cmd = 'cat /sys/class/thermal/thermal_zone*/type; echo "-----"; cat /sys/class/thermal/thermal_zone*/temp;';
|
||||
const parts = execSync(cmd).toString().split('-----\n');
|
||||
if (parts.length === 2) {
|
||||
const lines = parts[0].split('\n');
|
||||
const lines2 = parts[1].split('\n');
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
const line = lines[i].trim();
|
||||
if (line.startsWith('acpi') && lines2[i]) {
|
||||
result.socket.push(Math.round(parseInt(lines2[i], 10) / 100) / 10);
|
||||
}
|
||||
if (line.startsWith('pch') && lines2[i]) {
|
||||
result.chipset = Math.round(parseInt(lines2[i], 10) / 100) / 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
util.noop();
|
||||
}
|
||||
|
||||
const cmd = 'for mon in /sys/class/hwmon/hwmon*; do for label in "$mon"/temp*_label; do if [ -f $label ]; then value=$(echo $label | rev | cut -c 7- | rev)_input; if [ -f "$value" ]; then echo $(cat "$label")___$(cat "$value"); fi; fi; done; done;';
|
||||
try {
|
||||
exec(cmd, function (error, stdout) {
|
||||
@@ -963,15 +986,37 @@ function cpuTemperature(callback) {
|
||||
resolve(result);
|
||||
return;
|
||||
}
|
||||
// }
|
||||
exec('sensors', function (error, stdout) {
|
||||
if (!error) {
|
||||
let lines = stdout.toString().split('\n');
|
||||
let tdieTemp = null;
|
||||
let newSectionStarts = true;
|
||||
let section = '';
|
||||
lines.forEach(function (line) {
|
||||
// determine section
|
||||
if (line.trim() === '') {
|
||||
newSectionStarts = true;
|
||||
} else if (newSectionStarts) {
|
||||
if (line.trim().toLowerCase().startsWith('acpi')) { section = 'acpi'; }
|
||||
if (line.trim().toLowerCase().startsWith('pch')) { section = 'pch'; }
|
||||
if (line.trim().toLowerCase().startsWith('core')) { section = 'core'; }
|
||||
newSectionStarts = false;
|
||||
}
|
||||
let regex = /[+-]([^°]*)/g;
|
||||
let temps = line.match(regex);
|
||||
let firstPart = line.split(':')[0].toUpperCase();
|
||||
if (section === 'acpi') {
|
||||
// socket temp
|
||||
if (firstPart.indexOf('TEMP') !== -1) {
|
||||
result.socket.push(parseFloat(temps));
|
||||
}
|
||||
} else if (section === 'pch') {
|
||||
// chipset temp
|
||||
if (firstPart.indexOf('TEMP') !== -1) {
|
||||
result.chipset = parseFloat(temps);
|
||||
}
|
||||
}
|
||||
// cpu temp
|
||||
if (firstPart.indexOf('PHYSICAL') !== -1 || firstPart.indexOf('PACKAGE') !== -1) {
|
||||
result.main = parseFloat(temps);
|
||||
}
|
||||
|
||||
Vendored
+2
@@ -104,6 +104,8 @@ export namespace Systeminformation {
|
||||
main: number;
|
||||
cores: number[];
|
||||
max: number;
|
||||
socket?: number[];
|
||||
chipset?: number;
|
||||
}
|
||||
|
||||
interface MemData {
|
||||
|
||||
Reference in New Issue
Block a user