cpuTemperature() added socket and chipset temp (linux)
This commit is contained in:
parent
d40b85c1ac
commit
bb82868bce
@ -46,6 +46,7 @@ We had to make **several interface changes** to keep systeminformation as consis
|
||||
- `cpu()`: extended socket list (win)
|
||||
- `cpu()`: added virtualization if cpu supports virtualization
|
||||
- `cpu()`: now flags are part of this function
|
||||
- `cpuTemperature()` added added socket and chipset temp (linux)
|
||||
- `diskLayout()`: added USB drives (mac OS)
|
||||
- `fsSize()`: added available
|
||||
- `fsSize()`: improved calculation of used
|
||||
@ -76,6 +77,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page.
|
||||
|
||||
| Version | Date | Comment |
|
||||
| -------------- | -------------- | -------- |
|
||||
| 5.6.0 | 2021-03-03 | `cpuTemperature()` added socket and chipset temp (linux) |
|
||||
| 5.5.0 | 2021-02-25 | `dockerVolumes()` added |
|
||||
| 5.4.0 | 2021-02-24 | `dockerImages()` added |
|
||||
| 5.3.5 | 2021-02-23 | `dockerContainerStats()` fixed parameter * |
|
||||
|
||||
@ -103,14 +103,13 @@ si.cpu()
|
||||
|
||||
(last 7 major and minor version releases)
|
||||
|
||||
- Version 5.6.0: `cpuTemperature()` added added socket and chipset temp (linux)
|
||||
- Version 5.5.0: `dockerVolumes()` added
|
||||
- Version 5.4.0: `dockerImages()` added
|
||||
- Version 5.3.0: `osInfo()` added remoteSession (win only)
|
||||
- Version 5.2.0: `wifiInterfaces()` and `wifiConnections()` added
|
||||
- Version 5.1.0: `memLayout()` added ECC flag, `bios()` added language, features (linux)
|
||||
- Version 5.0.0: new version 5 - attention there are some breaking changes. See [detailed version 5 changes here][changes5-url].
|
||||
- Version 4.34.0: `system()` added flag virtual (linux, windows)
|
||||
- Version 4.33.0: `graphics()` added nvidia-smi support (linux, windows)
|
||||
- ...
|
||||
|
||||
You can find all changes here: [detailed changelog][changelog-url]
|
||||
@ -224,6 +223,8 @@ Full function reference with examples can be found at [https://systeminformation
|
||||
| | main | X | X | X | X | | main temperature (avg) |
|
||||
| | cores | X | X | X | X | | array of temperatures |
|
||||
| | max | X | X | X | X | | max temperature |
|
||||
| | socket | X | | | | | array socket temperatures |
|
||||
| | chipset | X | | | | | chipset temperature |
|
||||
|
||||
#### 4. Memory
|
||||
|
||||
|
||||
@ -173,6 +173,7 @@
|
||||
<li><span class="code">cpu()</span>: extended socket list (win)</li>
|
||||
<li><span class="code">cpu()</span>: added <span class="code">virtualization</span> if cpu supports virtualization</li>
|
||||
<li><span class="code">cpu()</span>: now <span class="code">flags</span> are part of this function</li>
|
||||
<li><span class="code">cpuTemperature()</span>: added socket and chipset temperature (linux)</li>
|
||||
<li><span class="code">fsSize()</span>: added <span class="code">available</span></li>
|
||||
<li><span class="code">fsSize()</span>: improved calculation of <span class="code">used</span></li>
|
||||
<li><span class="code">getData()</span>: support for passing parameters and filters (see <a href="general.html">section General / getData</a>)</li>
|
||||
|
||||
@ -545,6 +545,26 @@ si.cpuCurrentSpeed().then(data => console.log(data));</code></pre class="example
|
||||
<td></td>
|
||||
<td>max temperature</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>socket</td>
|
||||
<td>X</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>array socket temperatures</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>chipset</td>
|
||||
<td>X</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>chipset temperature</td>
|
||||
</tr>
|
||||
<tr class="example">
|
||||
<td></td>
|
||||
<td colspan="7">
|
||||
@ -552,7 +572,16 @@ si.cpuCurrentSpeed().then(data => console.log(data));</code></pre class="example
|
||||
<pre><code class="js">const si = require('systeminformation');
|
||||
si.cpuTemperature().then(data => console.log(data));</code></pre class="example">
|
||||
<pre class="example">
|
||||
{ main: 42, cores: [], max: 42 }
|
||||
{
|
||||
main: 42,
|
||||
cores: [
|
||||
34, 35, 33, 32,
|
||||
37, 32, 35, 33
|
||||
],
|
||||
max: 42,
|
||||
socket: [ 16.8, 27.8 ],
|
||||
chipset: 49
|
||||
}
|
||||
</pre>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
@ -56,6 +56,11 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row">5.6.0</th>
|
||||
<td>2021-03-03</td>
|
||||
<td><span class="code">cpuTemperature()</span> added socket and chipset temp (linux)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">5.5.0</th>
|
||||
<td>2021-02-25</td>
|
||||
|
||||
@ -170,7 +170,7 @@
|
||||
<img class="logo" src="assets/logo.png">
|
||||
<div class="title">systeminformation</div>
|
||||
<div class="subtitle"><span id="typed"></span> </div>
|
||||
<div class="version">New Version: <span id="version">5.5.0</span></div>
|
||||
<div class="version">New Version: <span id="version">5.6.0</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">
|
||||
@ -201,7 +201,7 @@
|
||||
</div>
|
||||
<div class="row number-section">
|
||||
<div class="col-xl-4 col-lg-4 col-md-4 col-12">
|
||||
<div class="numbers">14,053</div>
|
||||
<div class="numbers">14,121</div>
|
||||
<div class="title">Lines of code</div>
|
||||
</div>
|
||||
<div class="col-xl-4 col-lg-4 col-md-4 col-12">
|
||||
@ -209,7 +209,7 @@
|
||||
<div class="title">Downloads last month</div>
|
||||
</div>
|
||||
<div class="col-xl-4 col-lg-4 col-md-4 col-12">
|
||||
<div class="numbers">389</div>
|
||||
<div class="numbers">390</div>
|
||||
<div class="title">Dependents</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
49
lib/cpu.js
49
lib/cpu.js
@ -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);
|
||||
}
|
||||
|
||||
2
lib/index.d.ts
vendored
2
lib/index.d.ts
vendored
@ -104,6 +104,8 @@ export namespace Systeminformation {
|
||||
main: number;
|
||||
cores: number[];
|
||||
max: number;
|
||||
socket?: number[];
|
||||
chipset?: number;
|
||||
}
|
||||
|
||||
interface MemData {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user