diff --git a/CHANGELOG.md b/CHANGELOG.md index 4029a73..7cd7fc8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 * | diff --git a/README.md b/README.md index de680d3..d287483 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/docs/changes.html b/docs/changes.html index 2d21469..d913931 100644 --- a/docs/changes.html +++ b/docs/changes.html @@ -173,6 +173,7 @@
  • cpu(): extended socket list (win)
  • cpu(): added virtualization if cpu supports virtualization
  • cpu(): now flags are part of this function
  • +
  • cpuTemperature(): added socket and chipset temperature (linux)
  • fsSize(): added available
  • fsSize(): improved calculation of used
  • getData(): support for passing parameters and filters (see section General / getData)
  • diff --git a/docs/cpu.html b/docs/cpu.html index 5e9bad1..334e669 100644 --- a/docs/cpu.html +++ b/docs/cpu.html @@ -545,6 +545,26 @@ si.cpuCurrentSpeed().then(data => console.log(data)); @@ -552,7 +572,16 @@ si.cpuCurrentSpeed().then(data => console.log(data));const si = require('systeminformation'); si.cpuTemperature().then(data => console.log(data));
    -{ 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
    +}
     
    diff --git a/docs/history.html b/docs/history.html index 2078d9d..3690ba5 100644 --- a/docs/history.html +++ b/docs/history.html @@ -56,6 +56,11 @@ + + 5.6.0 + 2021-03-03 + cpuTemperature() added socket and chipset temp (linux) + 5.5.0 2021-02-25 diff --git a/docs/index.html b/docs/index.html index 8ad1f6a..662f62f 100644 --- a/docs/index.html +++ b/docs/index.html @@ -170,7 +170,7 @@
    systeminformation
     
    -
    New Version: 5.5.0
    +
    New Version: 5.6.0
    @@ -201,7 +201,7 @@
    -
    14,053
    +
    14,121
    Lines of code
    @@ -209,7 +209,7 @@
    Downloads last month
    -
    389
    +
    390
    Dependents
    diff --git a/lib/cpu.js b/lib/cpu.js index 1d83971..5c1dbc7 100644 --- a/lib/cpu.js +++ b/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); } diff --git a/lib/index.d.ts b/lib/index.d.ts index cf3fe46..36ccb91 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -104,6 +104,8 @@ export namespace Systeminformation { main: number; cores: number[]; max: number; + socket?: number[]; + chipset?: number; } interface MemData {