From e9fedd4d5b9512edeacb4d56937e258ee6e717ce Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Sun, 13 Oct 2019 10:35:27 +0200 Subject: [PATCH 01/30] getCPU() fix parsing lines --- lib/cpu.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/cpu.js b/lib/cpu.js index 63934df..654f2f4 100644 --- a/lib/cpu.js +++ b/lib/cpu.js @@ -322,21 +322,21 @@ function getCpu() { if (result.cache.l3) { result.cache.l3 = parseInt(result.cache.l3) * (result.cache.l3.indexOf('K') !== -1 ? 1024 : 1); } // socket type - lines = []; + let lines2 = []; exec('export LC_ALL=C; dmidecode –t 4 2>/dev/null | grep "Upgrade: Socket"; unset LC_ALL', function (error2, stdout2) { - lines = stdout2.toString().split('\n'); - if (lines && lines.length) { - result.socket = util.getValue(lines, 'Upgrade').replace('Socket', '').trim(); + lines2 = stdout2.toString().split('\n'); + if (lines2 && lines2.length) { + result.socket = util.getValue(lines2, 'Upgrade').replace('Socket', '').trim(); } // # processurs & # threads/core - method 1 let threadsPerCoreInt = 0; - lines = []; + let lines3 = []; exec('cat /proc/cpuinfo | grep -E "physical id|core id"', function (error2, stdout3) { - lines = stdout3.toString().split('\n'); - if (lines && lines.length) { - result.processors = util.countUniqueLines(lines, 'physical id') || 1; - result.physicalCores = util.countUniqueLines(lines, 'core id') / result.processors; + lines3 = stdout3.toString().split('\n'); + if (lines3 && lines3.length) { + result.processors = util.countUniqueLines(lines3, 'physical id') || 1; + result.physicalCores = util.countUniqueLines(lines3, 'core id') / result.processors; if (result.physicalCores) { threadsPerCoreInt = result.cores / result.physicalCores; } From 6821fc43749a6d81e874ca327aec165ed0dfce89 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Sun, 13 Oct 2019 22:32:07 +0200 Subject: [PATCH 02/30] getCpu() fix physicalCores --- lib/cpu.js | 56 ++++++++++++++++++++++++++++++----------------------- lib/util.js | 8 +++++++- 2 files changed, 39 insertions(+), 25 deletions(-) diff --git a/lib/cpu.js b/lib/cpu.js index 654f2f4..26a6f0e 100644 --- a/lib/cpu.js +++ b/lib/cpu.js @@ -321,6 +321,13 @@ function getCpu() { result.cache.l3 = util.getValue(lines, 'l3 cache'); if (result.cache.l3) { result.cache.l3 = parseInt(result.cache.l3) * (result.cache.l3.indexOf('K') !== -1 ? 1024 : 1); } + const threadsPerCore = util.getValue(lines, 'thread(s) per core') || '1'; + const processors = util.getValue(lines, 'socket(s)') || '1'; + let threadsPerCoreInt = parseInt(threadsPerCore, 10); + let processorsInt = parseInt(processors, 10); + result.physicalCores = result.cores / threadsPerCoreInt; + result.processors = processorsInt; + // socket type let lines2 = []; exec('export LC_ALL=C; dmidecode –t 4 2>/dev/null | grep "Upgrade: Socket"; unset LC_ALL', function (error2, stdout2) { @@ -328,31 +335,32 @@ function getCpu() { if (lines2 && lines2.length) { result.socket = util.getValue(lines2, 'Upgrade').replace('Socket', '').trim(); } + resolve(result); - // # processurs & # threads/core - method 1 - let threadsPerCoreInt = 0; - let lines3 = []; - exec('cat /proc/cpuinfo | grep -E "physical id|core id"', function (error2, stdout3) { - lines3 = stdout3.toString().split('\n'); - if (lines3 && lines3.length) { - result.processors = util.countUniqueLines(lines3, 'physical id') || 1; - result.physicalCores = util.countUniqueLines(lines3, 'core id') / result.processors; - if (result.physicalCores) { - threadsPerCoreInt = result.cores / result.physicalCores; - } - } - // # threads/core - method 2 - if (threadsPerCoreInt === 0) { - const threadsPerCore = util.getValue(lines, 'thread(s) per core'); - if (threadsPerCore) { - threadsPerCoreInt = parseInt(threadsPerCore, 10); - if (!isNaN(threadsPerCoreInt)) { - result.physicalCores = result.cores / threadsPerCoreInt; - } - } - } - resolve(result); - }); + // // # processurs & # threads/core - method 1 + // let threadsPerCoreInt = 0; + // let lines3 = []; + // exec('cat /proc/cpuinfo | grep -E "physical id|core id"', function (error2, stdout3) { + // lines3 = stdout3.toString().split('\n'); + // if (lines3 && lines3.length) { + // result.processors = util.countUniqueLines(lines3, 'physical id') || 1; + // result.physicalCores = util.countLinesStartingWith(lines3, 'core id') / result.processors; + // if (result.physicalCores) { + // threadsPerCoreInt = result.cores / result.physicalCores; + // } + // } + // // # threads/core - method 2 + // if (threadsPerCoreInt === 0) { + // const threadsPerCore = util.getValue(lines, 'thread(s) per core'); + // if (threadsPerCore) { + // threadsPerCoreInt = parseInt(threadsPerCore, 10); + // if (!isNaN(threadsPerCoreInt)) { + // result.physicalCores = result.cores / threadsPerCoreInt; + // } + // } + // } + // resolve(result); + // }); }); }); } diff --git a/lib/util.js b/lib/util.js index 7f39f58..7d49b45 100644 --- a/lib/util.js +++ b/lib/util.js @@ -178,7 +178,7 @@ function parseDateTime(dt) { // Dateformat: mm/dd/yyyy result.date = dtparts[2] + '-' + ('0' + dtparts[0]).substr(-2) + '-' + ('0' + dtparts[1]).substr(-2); } else { - // Dateformat: dd/mm/yyyy + // Dateformat: dd/mm/yyyy result.date = dtparts[2] + '-' + ('0' + dtparts[1]).substr(-2) + '-' + ('0' + dtparts[0]).substr(-2); } } @@ -454,6 +454,12 @@ function countUniqueLines(lines, startingWith) { }); return uniqueLines.length; } + +// function countLinesStartingWith(lines, startingWith) { +// startingWith = startingWith || ''; +// return lines.filter(el => el.startsWith(startingWith)).length; +// } + function noop() { } exports.toInt = toInt; From 1e2522a0956ebb84774d1079ba54cbb5f227a12a Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Mon, 14 Oct 2019 16:31:24 +0200 Subject: [PATCH 03/30] getCpu() fix physicalCores (linux) --- CHANGELOG.md | 1 + README.md | 2 +- docs/history.html | 5 +++++ docs/index.html | 4 ++-- lib/cpu.js | 25 ------------------------- lib/util.js | 5 ----- 6 files changed, 9 insertions(+), 33 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 45b0980..7363a38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page. | Version | Date | Comment | | -------------- | -------------- | -------- | +| 4.14.12 | 2019-10-14 | getCpu() fixed multi socket detection (linux) | | 4.14.11 | 2019-10-01 | type definitions fix dockerInfo | | 4.14.10 | 2019-10-01 | type definitions fix memLayout | | 4.14.9 | 2019-10-01 | `processLoad()` fix windows | diff --git a/README.md b/README.md index ce10d1a..90e52ac 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ [![Caretaker][caretaker-image]][caretaker-url] [![MIT license][license-img]][license-url] -**2019-03-12** - 5th birthday of systeminformation. This is amazing. Started as a small projekt just for myself, it now has > 8,000 lines of code, > 200 versions published, up to 100,000 downloads per month, > 1 Mio downloads overall. Thank you to all who contributed to this project! +This is amazing. Started as a small projekt just for myself, it now has > 9,000 lines of code, > 200 versions published, up to 150,000 downloads per month, > 1 Mio downloads overall. Thank you to all who contributed to this project! ## New Version 4.0 diff --git a/docs/history.html b/docs/history.html index fc5914f..75eb7e6 100644 --- a/docs/history.html +++ b/docs/history.html @@ -83,6 +83,11 @@ + + 4.14.12 + 2019-10-14 + getCpu() fixed multi socket detection (linux) + 4.14.11 2019-10-01 diff --git a/docs/index.html b/docs/index.html index dc1f279..a2edab7 100644 --- a/docs/index.html +++ b/docs/index.html @@ -168,7 +168,7 @@
systeminformation
-
Current Version: 4.14.11
+
Current Version: 4.14.12
@@ -199,7 +199,7 @@
Downloads last month
-
192
+
200
Dependends
diff --git a/lib/cpu.js b/lib/cpu.js index 26a6f0e..21c7930 100644 --- a/lib/cpu.js +++ b/lib/cpu.js @@ -336,31 +336,6 @@ function getCpu() { result.socket = util.getValue(lines2, 'Upgrade').replace('Socket', '').trim(); } resolve(result); - - // // # processurs & # threads/core - method 1 - // let threadsPerCoreInt = 0; - // let lines3 = []; - // exec('cat /proc/cpuinfo | grep -E "physical id|core id"', function (error2, stdout3) { - // lines3 = stdout3.toString().split('\n'); - // if (lines3 && lines3.length) { - // result.processors = util.countUniqueLines(lines3, 'physical id') || 1; - // result.physicalCores = util.countLinesStartingWith(lines3, 'core id') / result.processors; - // if (result.physicalCores) { - // threadsPerCoreInt = result.cores / result.physicalCores; - // } - // } - // // # threads/core - method 2 - // if (threadsPerCoreInt === 0) { - // const threadsPerCore = util.getValue(lines, 'thread(s) per core'); - // if (threadsPerCore) { - // threadsPerCoreInt = parseInt(threadsPerCore, 10); - // if (!isNaN(threadsPerCoreInt)) { - // result.physicalCores = result.cores / threadsPerCoreInt; - // } - // } - // } - // resolve(result); - // }); }); }); } diff --git a/lib/util.js b/lib/util.js index 7d49b45..a72e1cd 100644 --- a/lib/util.js +++ b/lib/util.js @@ -455,11 +455,6 @@ function countUniqueLines(lines, startingWith) { return uniqueLines.length; } -// function countLinesStartingWith(lines, startingWith) { -// startingWith = startingWith || ''; -// return lines.filter(el => el.startsWith(startingWith)).length; -// } - function noop() { } exports.toInt = toInt; From 782b92df027dad8f7b3f275314d6e3c04e648124 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Mon, 14 Oct 2019 16:31:31 +0200 Subject: [PATCH 04/30] 4.14.12 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6f46073..6a7d46b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "systeminformation", - "version": "4.14.11", + "version": "4.14.12", "description": "Simple system and OS information library", "license": "MIT", "author": "Sebastian Hildebrandt (https://plus-innovations.com)", From 33196e47978d200f47bee744f320390e88e1b8db Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Tue, 15 Oct 2019 22:32:11 +0200 Subject: [PATCH 05/30] networkConnections() fixed parsing (linux) --- CHANGELOG.md | 3 ++- README.md | 2 +- docs/history.html | 5 +++++ docs/index.html | 2 +- lib/network.js | 2 +- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7363a38..b546199 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,7 +30,8 @@ For major (breaking) changes - version 3 and 2 see end of page. | Version | Date | Comment | | -------------- | -------------- | -------- | -| 4.14.12 | 2019-10-14 | getCpu() fixed multi socket detection (linux) | +| 4.14.13 | 2019-10-15 | `networkConnections()` fixed parsing (linux) | +| 4.14.12 | 2019-10-14 | `getCpu()` fixed multi socket detection (linux) | | 4.14.11 | 2019-10-01 | type definitions fix dockerInfo | | 4.14.10 | 2019-10-01 | type definitions fix memLayout | | 4.14.9 | 2019-10-01 | `processLoad()` fix windows | diff --git a/README.md b/README.md index 90e52ac..403315b 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ [![Caretaker][caretaker-image]][caretaker-url] [![MIT license][license-img]][license-url] -This is amazing. Started as a small projekt just for myself, it now has > 9,000 lines of code, > 200 versions published, up to 150,000 downloads per month, > 1 Mio downloads overall. Thank you to all who contributed to this project! +This is amazing. Started as a small projekt just for myself, it now has > 9,000 lines of code, > 250 versions published, up to 200,000 downloads per month, > 1 Mio downloads overall. Thank you to all who contributed to this project! ## New Version 4.0 diff --git a/docs/history.html b/docs/history.html index 75eb7e6..6a95eac 100644 --- a/docs/history.html +++ b/docs/history.html @@ -83,6 +83,11 @@ + + 4.14.13 + 2019-10-15 + networkConnections() fixed parsing (linux) + 4.14.12 2019-10-14 diff --git a/docs/index.html b/docs/index.html index a2edab7..a09e6bb 100644 --- a/docs/index.html +++ b/docs/index.html @@ -168,7 +168,7 @@
systeminformation
-
Current Version: 4.14.12
+
Current Version: 4.14.13
diff --git a/lib/network.js b/lib/network.js index 457fc16..eb073f1 100644 --- a/lib/network.js +++ b/lib/network.js @@ -785,7 +785,7 @@ function networkConnections(callback) { let lines = stdout.toString().split('\n'); lines.forEach(function (line) { line = line.replace(/ +/g, ' ').split(' '); - if (line.length >= 6) { + if (line.length >= 7) { let localip = line[3]; let localport = ''; let localaddress = line[3].split(':'); From 3e01751f28debd596996e3376ea4b2565454f978 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Tue, 15 Oct 2019 22:32:18 +0200 Subject: [PATCH 06/30] 4.14.13 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6a7d46b..9f88cf0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "systeminformation", - "version": "4.14.12", + "version": "4.14.13", "description": "Simple system and OS information library", "license": "MIT", "author": "Sebastian Hildebrandt (https://plus-innovations.com)", From c560a62e9f3413c7bda24b9da5a1872d5720b01f Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Fri, 18 Oct 2019 14:27:46 +0200 Subject: [PATCH 07/30] powerShell() fixed error handling (windows) --- CHANGELOG.md | 1 + README.md | 2 +- docs/history.html | 5 +++++ docs/index.html | 2 +- lib/util.js | 5 +++++ 5 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b546199..e2ecc1e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page. | Version | Date | Comment | | -------------- | -------------- | -------- | +| 4.14.14 | 2019-10-18 | `powerShell()` fixed error handling (windows) | | 4.14.13 | 2019-10-15 | `networkConnections()` fixed parsing (linux) | | 4.14.12 | 2019-10-14 | `getCpu()` fixed multi socket detection (linux) | | 4.14.11 | 2019-10-01 | type definitions fix dockerInfo | diff --git a/README.md b/README.md index 403315b..b46bf65 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ [![Caretaker][caretaker-image]][caretaker-url] [![MIT license][license-img]][license-url] -This is amazing. Started as a small projekt just for myself, it now has > 9,000 lines of code, > 250 versions published, up to 200,000 downloads per month, > 1 Mio downloads overall. Thank you to all who contributed to this project! +This is amazing. Started as a small project just for myself, it now has > 9,000 lines of code, > 250 versions published, up to 200,000 downloads per month, > 1 Mio downloads overall. Thank you to all who contributed to this project! ## New Version 4.0 diff --git a/docs/history.html b/docs/history.html index 6a95eac..c282dcf 100644 --- a/docs/history.html +++ b/docs/history.html @@ -83,6 +83,11 @@ + + 4.14.14 + 2019-10-18 + powershell() fixed error handling (windows) + 4.14.13 2019-10-15 diff --git a/docs/index.html b/docs/index.html index a09e6bb..77b8285 100644 --- a/docs/index.html +++ b/docs/index.html @@ -168,7 +168,7 @@
systeminformation
-
Current Version: 4.14.13
+
Current Version: 4.14.14
diff --git a/lib/util.js b/lib/util.js index a72e1cd..46f691b 100644 --- a/lib/util.js +++ b/lib/util.js @@ -321,6 +321,11 @@ function powerShell(cmd) { stdio: 'pipe' }); + if (child && !child.pid) { + child.on('error', function () { + resolve(result); + }); + } if (child && child.pid) { child.stdout.on('data', function (data) { result = result + data.toString('utf8'); From 85fa8fb07482b47cb560a9e0ca02f30eeb1421b3 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Fri, 18 Oct 2019 14:28:01 +0200 Subject: [PATCH 08/30] 4.14.14 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9f88cf0..6256155 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "systeminformation", - "version": "4.14.13", + "version": "4.14.14", "description": "Simple system and OS information library", "license": "MIT", "author": "Sebastian Hildebrandt (https://plus-innovations.com)", From 0ccc0abc3833fbd464f5a4be8f8b4672cca9b21d Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Fri, 18 Oct 2019 16:57:18 +0200 Subject: [PATCH 09/30] graphics() fallback display detection (windows) --- CHANGELOG.md | 1 + docs/history.html | 5 +++++ docs/index.html | 2 +- lib/graphics.js | 18 ++++++++++++++++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2ecc1e..9ea7598 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page. | Version | Date | Comment | | -------------- | -------------- | -------- | +| 4.14.15 | 2019-10-18 | `graphics()` fallback display detection (windows) | | 4.14.14 | 2019-10-18 | `powerShell()` fixed error handling (windows) | | 4.14.13 | 2019-10-15 | `networkConnections()` fixed parsing (linux) | | 4.14.12 | 2019-10-14 | `getCpu()` fixed multi socket detection (linux) | diff --git a/docs/history.html b/docs/history.html index c282dcf..fa616ff 100644 --- a/docs/history.html +++ b/docs/history.html @@ -83,6 +83,11 @@ + + 4.14.15 + 2019-10-18 + graphics() fallback display detection (windows) + 4.14.14 2019-10-18 diff --git a/docs/index.html b/docs/index.html index 77b8285..a7b26a5 100644 --- a/docs/index.html +++ b/docs/index.html @@ -168,7 +168,7 @@
systeminformation
-
Current Version: 4.14.14
+
Current Version: 4.14.15
diff --git a/lib/graphics.js b/lib/graphics.js index dfc3f6f..9807fbc 100644 --- a/lib/graphics.js +++ b/lib/graphics.js @@ -687,6 +687,8 @@ function graphics(callback) { vendor = util.getValue(linesDisplay, 'MonitorManufacturer', '='); model = util.getValue(linesDisplay, 'Name', '='); deviceID = util.getValue(linesDisplay, 'PNPDeviceID', '=').replace(/&/g, '&').toLowerCase(); + resolutionx = parseInt((util.getValue(linesDisplay, 'ScreenWidth', '=') || '0'), 10); + resolutionx = parseInt((util.getValue(linesDisplay, 'ScreenHeight', '=') || '0'), 10); } for (let i = 0; i < ssections.length; i++) { @@ -722,6 +724,22 @@ function graphics(callback) { }); } } + if (ssections.length === 0) { + displays.push({ + vendor, + model, + main: true, + resolutionx, + resolutiony, + sizex: -1, + sizey: -1, + pixeldepth: -1, + currentResX: resolutionx, + currentResY: resolutiony, + positionX: 0, + positionY: 0 + }); + } return displays; } From 7cbb8ac52ff48ccf5f47b93cf615698769cc77a5 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Fri, 18 Oct 2019 16:57:38 +0200 Subject: [PATCH 10/30] 4.14.15 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6256155..260fc03 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "systeminformation", - "version": "4.14.14", + "version": "4.14.15", "description": "Simple system and OS information library", "license": "MIT", "author": "Sebastian Hildebrandt (https://plus-innovations.com)", From 8acd0ece146e5256e5deef932e0a3dac3be5575b Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Fri, 18 Oct 2019 17:02:28 +0200 Subject: [PATCH 11/30] graphics() improving display detection (windows) --- lib/graphics.js | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/lib/graphics.js b/lib/graphics.js index 9807fbc..70c8ae6 100644 --- a/lib/graphics.js +++ b/lib/graphics.js @@ -561,6 +561,7 @@ function graphics(callback) { workload.push(util.powerShell('Get-CimInstance -Namespace root\\wmi -ClassName WmiMonitorBasicDisplayParams | fl')); workload.push(util.powerShell('Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.Screen]::AllScreens')); workload.push(util.powerShell('Get-CimInstance -Namespace root\\wmi -ClassName WmiMonitorConnectionParams | fl')); + workload.push(util.powerShell('gwmi WmiMonitorID -Namespace root\\wmi | ForEach-Object {(($_.ManufacturerName -notmatch 0 | foreach {[char]$_}) -join "") + "|" + (($_.ProductCodeID -notmatch 0 | foreach {[char]$_}) -join "") + "|" + (($_.UserFriendlyName -notmatch 0 | foreach {[char]$_}) -join "") + "|" + (($_.SerialNumberID -notmatch 0 | foreach {[char]$_}) -join "") + "|" + $_.InstanceName}')); Promise.all( workload @@ -587,19 +588,34 @@ function graphics(callback) { let tsections = data[4].split(/\n\s*\n/); tsections.shift(); - result.displays = parseLinesWindowsDisplaysPowershell(ssections, msections, dsections, tsections); + // monitor ID (powershell) - model / vendor + const res = data[5].split(/\r/); + let isections = []; + res.forEach(element => { + const parts = element.split('|'); + if (parts.length === 5) { + isections.push({ + vendor: parts[0], + code: parts[1], + model: parts[2], + serial: parts[3], + instanceId: parts[4] + }); + } + }); + result.displays = parseLinesWindowsDisplaysPowershell(ssections, msections, dsections, tsections, isections); if (result.controllers.length === 1 && result.displays.length === 1) { if (_resolutionx) { - result.displays[0].currentResX = _resolutionx; - if (!result.displays[0].resolutionx) { - result.displays[0].resolutionx = _resolutionx; + result.displays[0].resolutionx = _resolutionx; + if (!result.displays[0].currentResX) { + result.displays[0].currentResX = _resolutionx; } } if (_resolutiony) { - result.displays[0].currentResY = _resolutiony; - if (result.displays[0].resolutiony === 0) { - result.displays[0].resolutiony = _resolutiony; + result.displays[0].resolutiony = _resolutiony; + if (result.displays[0].currentResY === 0) { + result.displays[0].currentResY = _resolutiony; } } if (_pixeldepth) { @@ -677,7 +693,7 @@ function graphics(callback) { // return displays; // } - function parseLinesWindowsDisplaysPowershell(ssections, msections, dsections, tsections) { + function parseLinesWindowsDisplaysPowershell(ssections, msections, dsections, tsections, isections) { let displays = []; let vendor = ''; let model = ''; @@ -706,9 +722,17 @@ function graphics(callback) { const sizey = util.getValue(linesMonitor, 'MaxVerticalImageSize'); const instanceName = util.getValue(linesMonitor, 'InstanceName').toLowerCase(); const videoOutputTechnology = util.getValue(linesConnection, 'VideoOutputTechnology'); + let displayVendor = ''; + let displayModel = ''; + isections.forEach(element => { + if (element.instanceId.toLowerCase() === instanceName) { + displayVendor = element.vendor; + displayModel = element.model; + } + }); displays.push({ - vendor: instanceName.startsWith(deviceID) ? vendor : '', - model: instanceName.startsWith(deviceID) ? model : '', + vendor: instanceName.startsWith(deviceID) && displayVendor === '' ? vendor : displayVendor, + model: instanceName.startsWith(deviceID) && displayModel === '' ? model : displayModel, main: primary.toLowerCase() === 'true', builtin: videoOutputTechnology === '2147483648', connection: videoOutputTechnology && videoTypes[videoOutputTechnology] ? videoTypes[videoOutputTechnology] : '', From 8e41e8331787412c5804035ae827d0a7e8ada2d5 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Sat, 19 Oct 2019 16:42:43 +0200 Subject: [PATCH 12/30] graphics() improving display detection (windows) --- lib/graphics.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/graphics.js b/lib/graphics.js index 70c8ae6..0b62046 100644 --- a/lib/graphics.js +++ b/lib/graphics.js @@ -605,7 +605,7 @@ function graphics(callback) { }); result.displays = parseLinesWindowsDisplaysPowershell(ssections, msections, dsections, tsections, isections); - if (result.controllers.length === 1 && result.displays.length === 1) { + if (result.displays.length === 1) { if (_resolutionx) { result.displays[0].resolutionx = _resolutionx; if (!result.displays[0].currentResX) { @@ -659,10 +659,10 @@ function graphics(callback) { vram: parseInt(util.getValue(lines, 'AdapterRAM', '='), 10) / 1024 / 1024, vramDynamic: (util.getValue(lines, 'VideoMemoryType', '=') === '2') }); - _resolutionx = util.toInt(util.getValue(lines, 'CurrentHorizontalResolution', '=')); - _resolutiony = util.toInt(util.getValue(lines, 'CurrentVerticalResolution', '=')); - _refreshrate = util.toInt(util.getValue(lines, 'CurrentRefreshRate', '=')); - _pixeldepth = util.toInt(util.getValue(lines, 'CurrentBitsPerPixel', '=')); + _resolutionx = util.toInt(util.getValue(lines, 'CurrentHorizontalResolution', '=')) || _resolutionx; + _resolutiony = util.toInt(util.getValue(lines, 'CurrentVerticalResolution', '=')) || _resolutiony; + _refreshrate = util.toInt(util.getValue(lines, 'CurrentRefreshRate', '=')) || _refreshrate; + _pixeldepth = util.toInt(util.getValue(lines, 'CurrentBitsPerPixel', '=')) || _pixeldepth; } } } @@ -725,7 +725,7 @@ function graphics(callback) { let displayVendor = ''; let displayModel = ''; isections.forEach(element => { - if (element.instanceId.toLowerCase() === instanceName) { + if (element.instanceId.toLowerCase().startsWith(instanceName)) { displayVendor = element.vendor; displayModel = element.model; } From a4609a92fb03c33d9c2d5567171e882780145091 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Sat, 19 Oct 2019 17:50:48 +0200 Subject: [PATCH 13/30] graphics() improving display detection (windows) --- lib/graphics.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/graphics.js b/lib/graphics.js index 0b62046..a2e0ffa 100644 --- a/lib/graphics.js +++ b/lib/graphics.js @@ -698,15 +698,16 @@ function graphics(callback) { let vendor = ''; let model = ''; let deviceID = ''; + let resolutionx = 0; + let resolutiony = 0; if (dsections && dsections.length) { let linesDisplay = dsections[0].split(os.EOL); vendor = util.getValue(linesDisplay, 'MonitorManufacturer', '='); model = util.getValue(linesDisplay, 'Name', '='); deviceID = util.getValue(linesDisplay, 'PNPDeviceID', '=').replace(/&/g, '&').toLowerCase(); - resolutionx = parseInt((util.getValue(linesDisplay, 'ScreenWidth', '=') || '0'), 10); - resolutionx = parseInt((util.getValue(linesDisplay, 'ScreenHeight', '=') || '0'), 10); + resolutionx = util.toInt(util.getValue(linesDisplay, 'ScreenWidth', '=')); + resolutiony = util.toInt(util.getValue(linesDisplay, 'ScreenHeight', '=')); } - for (let i = 0; i < ssections.length; i++) { if (ssections[i].trim() !== '') { ssections[i] = 'BitsPerPixel ' + ssections[i]; From f1bcd2b66124c05b7883c94a03018e6c05ca1440 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Sat, 19 Oct 2019 23:07:28 +0200 Subject: [PATCH 14/30] graphics() improved display detection (windows) --- CHANGELOG.md | 1 + README.md | 2 +- docs/history.html | 5 +++++ docs/index.html | 6 +++--- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ea7598..3782211 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page. | Version | Date | Comment | | -------------- | -------------- | -------- | +| 4.14.16 | 2019-10-19 | `graphics()` improved display detection (windows) | | 4.14.15 | 2019-10-18 | `graphics()` fallback display detection (windows) | | 4.14.14 | 2019-10-18 | `powerShell()` fixed error handling (windows) | | 4.14.13 | 2019-10-15 | `networkConnections()` fixed parsing (linux) | diff --git a/README.md b/README.md index b46bf65..ecc21e5 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ [![Caretaker][caretaker-image]][caretaker-url] [![MIT license][license-img]][license-url] -This is amazing. Started as a small project just for myself, it now has > 9,000 lines of code, > 250 versions published, up to 200,000 downloads per month, > 1 Mio downloads overall. Thank you to all who contributed to this project! +This is amazing. Started as a small project just for myself, it now has > 9,000 lines of code, > 250 versions published, up to 300,000 downloads per month, > 1 Mio downloads overall. Thank you to all who contributed to this project! ## New Version 4.0 diff --git a/docs/history.html b/docs/history.html index fa616ff..d1e148b 100644 --- a/docs/history.html +++ b/docs/history.html @@ -83,6 +83,11 @@ + + 4.14.16 + 2019-10-19 + graphics() improved display detection (windows) + 4.14.15 2019-10-18 diff --git a/docs/index.html b/docs/index.html index a7b26a5..e80420f 100644 --- a/docs/index.html +++ b/docs/index.html @@ -168,7 +168,7 @@
systeminformation
-
Current Version: 4.14.15
+
Current Version: 4.14.16
@@ -191,7 +191,7 @@
-
9,273
+
9,305
Lines of code
@@ -199,7 +199,7 @@
Downloads last month
-
200
+
203
Dependends
From 1cc0c99768d8b079905c471330364f6d59062b5f Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Sat, 19 Oct 2019 23:07:37 +0200 Subject: [PATCH 15/30] 4.14.16 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 260fc03..8da28a9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "systeminformation", - "version": "4.14.15", + "version": "4.14.16", "description": "Simple system and OS information library", "license": "MIT", "author": "Sebastian Hildebrandt (https://plus-innovations.com)", From e5d2f69f2f1e712f4989014ad8a07b85fc6207f1 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Tue, 22 Oct 2019 19:43:30 +0200 Subject: [PATCH 16/30] graphics() improved display detection (windows) --- CHANGELOG.md | 1 + README.md | 2 +- docs/history.html | 5 +++++ docs/index.html | 2 +- lib/graphics.js | 4 ++-- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3782211..02ad75d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page. | Version | Date | Comment | | -------------- | -------------- | -------- | +| 4.14.17 | 2019-10-22 | `graphics()` improved display detection (windows) | | 4.14.16 | 2019-10-19 | `graphics()` improved display detection (windows) | | 4.14.15 | 2019-10-18 | `graphics()` fallback display detection (windows) | | 4.14.14 | 2019-10-18 | `powerShell()` fixed error handling (windows) | diff --git a/README.md b/README.md index ecc21e5..9cc5983 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ [![Caretaker][caretaker-image]][caretaker-url] [![MIT license][license-img]][license-url] -This is amazing. Started as a small project just for myself, it now has > 9,000 lines of code, > 250 versions published, up to 300,000 downloads per month, > 1 Mio downloads overall. Thank you to all who contributed to this project! +This is amazing. Started as a small project just for myself, it now has > 9,000 lines of code, > 250 versions published, up to 400,000 downloads per month, > 1 Mio downloads overall. Thank you to all who contributed to this project! ## New Version 4.0 diff --git a/docs/history.html b/docs/history.html index d1e148b..e2d13fc 100644 --- a/docs/history.html +++ b/docs/history.html @@ -83,6 +83,11 @@ + + 4.14.17 + 2019-10-22 + graphics() improved display detection (windows) + 4.14.16 2019-10-19 diff --git a/docs/index.html b/docs/index.html index e80420f..43d27d5 100644 --- a/docs/index.html +++ b/docs/index.html @@ -168,7 +168,7 @@
systeminformation
-
Current Version: 4.14.16
+
Current Version: 4.14.17
diff --git a/lib/graphics.js b/lib/graphics.js index a2e0ffa..ccc2970 100644 --- a/lib/graphics.js +++ b/lib/graphics.js @@ -589,7 +589,7 @@ function graphics(callback) { tsections.shift(); // monitor ID (powershell) - model / vendor - const res = data[5].split(/\r/); + const res = data[5].split(/\r\n/); let isections = []; res.forEach(element => { const parts = element.split('|'); @@ -726,7 +726,7 @@ function graphics(callback) { let displayVendor = ''; let displayModel = ''; isections.forEach(element => { - if (element.instanceId.toLowerCase().startsWith(instanceName)) { + if (element.instanceId.toLowerCase().startsWith(instanceName) && vendor.startsWith('(') && model.startsWith('PnP')) { displayVendor = element.vendor; displayModel = element.model; } From 4da52a35076038923e6eb61ecd92b01cfed51a30 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Tue, 22 Oct 2019 19:43:36 +0200 Subject: [PATCH 17/30] 4.14.17 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8da28a9..0033cd4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "systeminformation", - "version": "4.14.16", + "version": "4.14.17", "description": "Simple system and OS information library", "license": "MIT", "author": "Sebastian Hildebrandt (https://plus-innovations.com)", From a4af64e57cb9f413f90adb2f444c9f0f81eba7cc Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Sun, 10 Nov 2019 12:29:44 +0100 Subject: [PATCH 18/30] cpu() added governor (linux) --- .gitignore | 1 + README.md | 4 ++- docs/cpu.html | 10 ++++++++ docs/history.html | 5 ++++ docs/index.html | 6 ++--- docs/processes.html | 2 +- lib/cpu.js | 60 +++++++++++++++++++++++++++++++++++++++++++-- 7 files changed, 81 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index d234c9b..bdb756c 100644 --- a/.gitignore +++ b/.gitignore @@ -60,6 +60,7 @@ npm* CVS .eslintrc.json package-lock.json +yarn.lock test/ dist/ diff --git a/README.md b/README.md index 9cc5983..3f0bc82 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,7 @@ si.cpu() (last 7 major and minor version releases) +- Version 4.15.0: `cpu()` added governor (linux) - Version 4.14.0: `processes()` added process path and params - Version 4.13.0: `networkConnections()` added PID, process - Version 4.12.0: `networkInterfaces()` added property virtual @@ -162,6 +163,7 @@ I also created a nice little command line tool called [mmon][mmon-github-url] ( | | speed | X | X | X | X | | in GHz e.g. '3.40' | | | speedmin | X | | X | X | | in GHz e.g. '0.80' | | | speedmax | X | X | X | X | | in GHz e.g. '3.90' | +| | governor | X | | | | | e.g. 'powersave' | | | cores | X | X | X | X | | # cores | | | physicalCores | X | X | X | X | | # physical cores | | | processors | X | X | X | X | | # processors | @@ -302,7 +304,7 @@ I also created a nice little command line tool called [mmon][mmon-github-url] ( | Function | Result object | Linux | BSD | Mac | Win | Sun | Comments | | --------------- | ------------- | ----- | ------- | --- | --- | --- | -------- | | si.currentLoad(cb) | {...} | X | | X | X | X | CPU-Load | -| | avgload | X | | X | X | X | average load | +| | avgload | X | | X | | X | average load | | | currentload | X | | X | X | X | CPU load in % | | | currentload_user | X | | X | X | X | CPU load user in % | | | currentload_system | X | | X | X | X | CPU load system in % | diff --git a/docs/cpu.html b/docs/cpu.html index f28ffad..851e02c 100644 --- a/docs/cpu.html +++ b/docs/cpu.html @@ -125,6 +125,16 @@ in GHz e.g. '3.90' + + + governor + X + + + + + e.g. 'powersave' + cores diff --git a/docs/history.html b/docs/history.html index e2d13fc..d59fcad 100644 --- a/docs/history.html +++ b/docs/history.html @@ -83,6 +83,11 @@ + + 4.15.0 + 2019-11-10 + cpu() added governor (linux) + 4.14.17 2019-10-22 diff --git a/docs/index.html b/docs/index.html index 43d27d5..cc3e782 100644 --- a/docs/index.html +++ b/docs/index.html @@ -168,7 +168,7 @@
systeminformation
-
Current Version: 4.14.17
+
Current Version: 4.15.0
@@ -191,7 +191,7 @@
-
9,305
+
9,361
Lines of code
@@ -199,7 +199,7 @@
Downloads last month
-
203
+
215
Dependends
diff --git a/docs/processes.html b/docs/processes.html index 3abfcf4..05d69cf 100644 --- a/docs/processes.html +++ b/docs/processes.html @@ -81,7 +81,7 @@ X X - X + X average load diff --git a/lib/cpu.js b/lib/cpu.js index 21c7930..7ada024 100644 --- a/lib/cpu.js +++ b/lib/cpu.js @@ -122,7 +122,61 @@ const AMDBaseFrequencies = { '7251': '2.1', '7551P': '2.0', '7401P': '2.0', - '7351P': '2.4' + '7351P': '2.4', + '2300X': '3.5', + '2500X': '3.6', + '2600': '3.1', + '2600E': '3.1', + '2600X': '3.6', + '2700': '3.2', + '2700E': '2.8', + '2700X': '3.7', + 'Pro 2700X': '3.6', + '2920': '3.5', + '2950': '3.5', + '2970WX': '3.0', + '2990WX': '3.0', + '3200U': '2.6', + '3300U': '2.1', + '3500U': '2.1', + '3550H': '2.1', + '3580U': '2.1', + '3700U': '2.3', + '3750H': '2.3', + '3780U': '2.3', + '3500X': '3.6', + '3600': '3.6', + 'Pro 3600': '3.6', + '3600X': '3.8', + 'Pro 3700': '3.6', + '3700X': '3.6', + '3800X': '3.9', + '3900': '3.1', + 'Pro 3900': '3.1', + '3900X': '3.8', + '3950X': '3.5', + '3960X': '3.8', + '3970X': '3.7', + '7232P': '3.1', + '7302P': '3.0', + '7402P': '2.8', + '7502P': '2.5', + '7702P': '2.0', + '7252': '3.1', + '7262': '3.2', + '7272': '2.9', + '7282': '2.8', + '7302': '3.0', + '7352': '2.3', + '7402': '2.8', + '7452': '2.35', + '7502': '2.5', + '7542': '2.9', + '7552': '2.2', + '7642': '2.3', + '7702': '2.0', + '7742': '2.25', + '7H12': '2.6' }; const socketTypes = { @@ -240,6 +294,7 @@ function getCpu() { speed: '0.00', speedmin: '', speedmax: '', + governor: '', cores: util.cores(), physicalCores: util.cores(), processors: 1, @@ -283,7 +338,7 @@ function getCpu() { let modelline = ''; let lines = []; if (os.cpus()[0] && os.cpus()[0].model) modelline = os.cpus()[0].model; - exec('export LC_ALL=C; lscpu; 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', function (error, stdout) { if (!error) { lines = stdout.toString().split('\n'); } @@ -327,6 +382,7 @@ function getCpu() { let processorsInt = parseInt(processors, 10); result.physicalCores = result.cores / threadsPerCoreInt; result.processors = processorsInt; + result.governor = util.getValue(lines, 'governor') || ''; // socket type let lines2 = []; From 24e8145a43d7abd4b08573ad2cd196851b393aa7 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Sun, 10 Nov 2019 12:29:55 +0100 Subject: [PATCH 19/30] 4.15.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0033cd4..17a7b08 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "systeminformation", - "version": "4.14.17", + "version": "4.15.0", "description": "Simple system and OS information library", "license": "MIT", "author": "Sebastian Hildebrandt (https://plus-innovations.com)", From 0fd3c2047432c25673329a9efcf8964f9c05377b Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Sun, 10 Nov 2019 15:15:14 +0100 Subject: [PATCH 20/30] diskLayout() support for older versions of lsblk --- lib/filesystem.js | 90 ++++++++++++++++++++++++++--------------------- 1 file changed, 50 insertions(+), 40 deletions(-) diff --git a/lib/filesystem.js b/lib/filesystem.js index 9ce7d50..8cc47ef 100644 --- a/lib/filesystem.js +++ b/lib/filesystem.js @@ -244,7 +244,8 @@ function parseBlk(lines) { 'model': disk.model, 'serial': disk.serial, 'removable': disk.rm === '1', - 'protocol': disk.tran + 'protocol': disk.tran, + 'group': disk.group, }); }); @@ -269,6 +270,7 @@ function blkStdoutToObject(stdout) { .replace(/LABEL=/g, ',"label":') .replace(/MODEL=/g, ',"model":') .replace(/OWNER=/g, ',"owner":') + .replace(/GROUP=/g, ',"group":') .replace(/\n/g, '}\n'); } @@ -715,45 +717,54 @@ function diskLayout(callback) { if (!error) { try { const out = stdout.toString().trim(); - const outJSON = JSON.parse(out); - if (outJSON && outJSON.hasOwnProperty('blockdevices')) { - let devices = outJSON.blockdevices.filter(item => { return item.group === 'disk' && item.size > 0 && item.model !== null; }); - devices.forEach((device) => { - let mediumType = ''; - const BSDName = '/dev/' + device.name; - const logical = device.name; - try { - mediumType = execSync('cat /sys/block/' + logical + '/queue/rotational').toString().split('\n')[0]; - } catch (e) { - util.noop(); - } - let interfaceType = device.tran ? device.tran.toUpperCase().trim() : ''; - if (interfaceType === 'NVME') { - mediumType = '2'; - interfaceType = 'PCIe'; - } - result.push({ - device: BSDName, - type: (mediumType === '0' ? 'SSD' : (mediumType === '1' ? 'HD' : (mediumType === '2' ? 'NVMe' : (device.model && device.model.indexOf('SSD') > -1 ? 'SSD' : (device.model && device.model.indexOf('NVM') > -1 ? 'NVMe' : 'HD'))))), - name: device.model || '', - vendor: getVendorFromModel(device.model) || (device.vendor ? device.vendor.trim() : ''), - size: device.size || 0, - bytesPerSector: -1, - totalCylinders: -1, - totalHeads: -1, - totalSectors: -1, - totalTracks: -1, - tracksPerCylinder: -1, - sectorsPerTrack: -1, - firmwareRevision: device.rev ? device.rev.trim() : '', - serialNum: device.serial ? device.serial.trim() : '', - interfaceType: interfaceType, - smartStatus: 'unknown', - BSDName: BSDName - }); - cmd = cmd + 'printf "\n' + BSDName + '|"; smartctl -H ' + BSDName + ' | grep overall;'; - }); + let devices = []; + try { + const outJSON = JSON.parse(out); + if (outJSON && outJSON.hasOwnProperty('blockdevices')) { + devices = outJSON.blockdevices.filter(item => { return item.group === 'disk' && item.size > 0 && item.model !== null; }); + } + } catch (e) { + // fallback to older version of lsblk + const out2 = execSync('export LC_ALL=C; lsblk -bPo NAME,TYPE,SIZE,FSTYPE,MOUNTPOINT,UUID,ROTA,RO,RM,LABEL,MODEL,OWNER,GROUP; unset LC_ALL').toString(); + let lines = blkStdoutToObject(out2).split('\n'); + const data = parseBlk(lines); + devices = data.filter(item => { return item.group === 'disk' && item.size > 0 && item.model !== null && item.model !== ''; }); } + devices.forEach((device) => { + let mediumType = ''; + const BSDName = '/dev/' + device.name; + const logical = device.name; + try { + mediumType = execSync('cat /sys/block/' + logical + '/queue/rotational').toString().split('\n')[0]; + } catch (e) { + util.noop(); + } + let interfaceType = device.tran ? device.tran.toUpperCase().trim() : ''; + if (interfaceType === 'NVME') { + mediumType = '2'; + interfaceType = 'PCIe'; + } + result.push({ + device: BSDName, + type: (mediumType === '0' ? 'SSD' : (mediumType === '1' ? 'HD' : (mediumType === '2' ? 'NVMe' : (device.model && device.model.indexOf('SSD') > -1 ? 'SSD' : (device.model && device.model.indexOf('NVM') > -1 ? 'NVMe' : 'HD'))))), + name: device.model || '', + vendor: getVendorFromModel(device.model) || (device.vendor ? device.vendor.trim() : ''), + size: device.size || 0, + bytesPerSector: -1, + totalCylinders: -1, + totalHeads: -1, + totalSectors: -1, + totalTracks: -1, + tracksPerCylinder: -1, + sectorsPerTrack: -1, + firmwareRevision: device.rev ? device.rev.trim() : '', + serialNum: device.serial ? device.serial.trim() : '', + interfaceType: interfaceType, + smartStatus: 'unknown', + BSDName: BSDName + }); + cmd = cmd + 'printf "\n' + BSDName + '|"; smartctl -H ' + BSDName + ' | grep overall;'; + }); } catch (e) { util.noop(); } @@ -811,7 +822,6 @@ function diskLayout(callback) { if (callback) { callback(result); } resolve(result); } - if (_darwin) { exec('system_profiler SPSerialATADataType SPNVMeDataType', function (error, stdout) { if (!error) { From 657ec538ff430a6ef63b1252875ec0a755af4195 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Sun, 10 Nov 2019 15:48:35 +0100 Subject: [PATCH 21/30] diskLayout() support for older versions of lsblk --- CHANGELOG.md | 2 ++ README.md | 3 +-- docs/history.html | 5 +++++ docs/index.html | 4 ++-- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 02ad75d..c4ab944 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,8 @@ For major (breaking) changes - version 3 and 2 see end of page. | Version | Date | Comment | | -------------- | -------------- | -------- | +| 4.15.1 | 2019-11-10 | `diskLayout()` added support for older lsblk versions (linux) | +| 4.15.0 | 2019-11-10 | `cpu()` added governor (linux) | | 4.14.17 | 2019-10-22 | `graphics()` improved display detection (windows) | | 4.14.16 | 2019-10-19 | `graphics()` improved display detection (windows) | | 4.14.15 | 2019-10-18 | `graphics()` fallback display detection (windows) | diff --git a/README.md b/README.md index 3f0bc82..8ad39ab 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ [![Caretaker][caretaker-image]][caretaker-url] [![MIT license][license-img]][license-url] -This is amazing. Started as a small project just for myself, it now has > 9,000 lines of code, > 250 versions published, up to 400,000 downloads per month, > 1 Mio downloads overall. Thank you to all who contributed to this project! +This is amazing. Started as a small project just for myself, it now has > 9,000 lines of code, > 250 versions published, up to 900,000 downloads per month, > 2 Mio downloads overall. Thank you to all who contributed to this project! ## New Version 4.0 @@ -91,7 +91,6 @@ si.cpu() - Version 4.11.0: `wifiNetworks()` added available wifi networks - Version 4.10.0: `graphics()` added windows multiple display support, added display size, connection, ... - Version 4.9.0: `graphics()` added vendor, refresh rate, current resolution -- Version 4.8.0: added `vboxInfo()` detailed virtual box info - ... You can find all changes here: [detailed changelog][changelog-url] diff --git a/docs/history.html b/docs/history.html index d59fcad..ebee879 100644 --- a/docs/history.html +++ b/docs/history.html @@ -83,6 +83,11 @@ + + 4.15.0 + 2019-11-10 + diskLayout() added support for older lsblk versions (linux) + 4.15.0 2019-11-10 diff --git a/docs/index.html b/docs/index.html index cc3e782..88ba57f 100644 --- a/docs/index.html +++ b/docs/index.html @@ -168,7 +168,7 @@
systeminformation
-
Current Version: 4.15.0
+
Current Version: 4.15.1
@@ -191,7 +191,7 @@
-
9,361
+
9,371
Lines of code
From a15de2063b9a9a983d0264f9b869a919549e61ed Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Sun, 10 Nov 2019 15:48:46 +0100 Subject: [PATCH 22/30] 4.15.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 17a7b08..845ab9e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "systeminformation", - "version": "4.15.0", + "version": "4.15.1", "description": "Simple system and OS information library", "license": "MIT", "author": "Sebastian Hildebrandt (https://plus-innovations.com)", From 780835fd693a7b34567adaf6a6c041a9a4c47ae8 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Sun, 10 Nov 2019 20:56:42 +0100 Subject: [PATCH 23/30] mem() improved calculation linux --- lib/memory.js | 63 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 21 deletions(-) diff --git a/lib/memory.js b/lib/memory.js index 841af22..fa19b0f 100644 --- a/lib/memory.js +++ b/lib/memory.js @@ -93,17 +93,30 @@ const OSX_RAM_manufacturers = { // /procs/meminfo - sample (all in kB) // -// MemTotal: 32806380 kB -// MemFree: 19220948 kB -// MemAvailable: 20851100 kB -// Buffers: 532892 kB -// Cached: 1935000 kB -// SwapCached: 0 kB -// Active: 11953672 kB -// Inactive: 1069288 kB -// SwapTotal: 16768892 kB -// SwapFree: 16768892 kB - +// MemTotal: 32806380 kB +// MemFree: 17977744 kB +// MemAvailable: 19768972 kB +// Buffers: 517028 kB +// Cached: 2161876 kB +// SwapCached: 456 kB +// Active: 12081176 kB +// Inactive: 2164616 kB +// Active(anon): 10832884 kB +// Inactive(anon): 1477272 kB +// Active(file): 1248292 kB +// Inactive(file): 687344 kB +// Unevictable: 0 kB +// Mlocked: 0 kB +// SwapTotal: 16768892 kB +// SwapFree: 16768304 kB +// Dirty: 268 kB +// Writeback: 0 kB +// AnonPages: 11568832 kB +// Mapped: 719992 kB +// Shmem: 743272 kB +// Slab: 335716 kB +// SReclaimable: 256364 kB +// SUnreclaim: 79352 kB function mem(callback) { @@ -117,6 +130,9 @@ function mem(callback) { active: os.totalmem() - os.freemem(), // temporarily (fallback) available: os.freemem(), // temporarily (fallback) + buffers: 0, + cache: 0, + slab: 0, buffcache: 0, swaptotal: 0, @@ -134,20 +150,25 @@ function mem(callback) { result.free = result.free ? result.free * 1024 : os.freemem(); result.used = result.total - result.free; - let buffers = parseInt(util.getValue(lines, 'buffers'), 10); - buffers = buffers ? buffers * 1024 : 0; - let cached = parseInt(util.getValue(lines, 'cached'), 10); - cached = cached ? cached * 1024 : 0; - result.buffcache = buffers + cached; + result.buffers = parseInt(util.getValue(lines, 'buffers'), 10); + result.buffers = result.buffers ? result.buffers * 1024 : 0; + result.cached = parseInt(util.getValue(lines, 'cached'), 10); + result.cached = result.cached ? result.cached * 1024 : 0; + result.slab = parseInt(util.getValue(lines, 'slab'), 10); + result.slab = result.slab ? result.slab * 1024 : 0; + result.buffcache = result.buffers + result.cached + result.slab; - result.available = parseInt(util.getValue(lines, 'memavailable'), 10); - result.available = result.available ? result.available * 1024 : os.freemem(); + let available = parseInt(util.getValue(lines, 'memavailable'), 10) + result.available = available ? available * 1024 : result.buffers + result.cache + result.free + result.slab + // result.available = result.available ? result.available * 1024 : os.freemem(); // result.active = result.total - result.free - result.buffcache; - result.active = parseInt(util.getValue(lines, 'active'), 10); - result.active = result.active ? result.active * 1024 : 0; - result.buffcache = result.total - result.free - result.active; + // result.active = parseInt(util.getValue(lines, 'active'), 10); + // result.active = result.active ? result.active * 1024 : 0; + // result.buffcache = result.total - result.free - result.active; + + result.active = result.total - result.available; result.swaptotal = parseInt(util.getValue(lines, 'swaptotal'), 10); result.swaptotal = result.swaptotal ? result.swaptotal * 1024 : 0; From 2eb0f98ffcac6aeeabce9cc02a14d1750d65d749 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Sun, 10 Nov 2019 22:17:22 +0100 Subject: [PATCH 24/30] mem() improved calculation linux --- lib/memory.js | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/lib/memory.js b/lib/memory.js index fa19b0f..8a6bcdd 100644 --- a/lib/memory.js +++ b/lib/memory.js @@ -131,7 +131,7 @@ function mem(callback) { active: os.totalmem() - os.freemem(), // temporarily (fallback) available: os.freemem(), // temporarily (fallback) buffers: 0, - cache: 0, + cached: 0, slab: 0, buffcache: 0, @@ -158,16 +158,8 @@ function mem(callback) { result.slab = result.slab ? result.slab * 1024 : 0; result.buffcache = result.buffers + result.cached + result.slab; - let available = parseInt(util.getValue(lines, 'memavailable'), 10) - result.available = available ? available * 1024 : result.buffers + result.cache + result.free + result.slab - // result.available = result.available ? result.available * 1024 : os.freemem(); - - // result.active = result.total - result.free - result.buffcache; - - // result.active = parseInt(util.getValue(lines, 'active'), 10); - // result.active = result.active ? result.active * 1024 : 0; - // result.buffcache = result.total - result.free - result.active; - + let available = parseInt(util.getValue(lines, 'memavailable'), 10); + result.available = available ? available * 1024 : result.free + result.buffcache; result.active = result.total - result.available; result.swaptotal = parseInt(util.getValue(lines, 'swaptotal'), 10); From f0370c0e611cbd7693d042c1328e00117bbcdab9 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Sun, 10 Nov 2019 22:21:51 +0100 Subject: [PATCH 25/30] mem() improved calculation linux --- CHANGELOG.md | 1 + docs/history.html | 7 ++++++- docs/index.html | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4ab944..030f5d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page. | Version | Date | Comment | | -------------- | -------------- | -------- | +| 4.15.2 | 2019-11-11 | `mem()` improved calculation linux | | 4.15.1 | 2019-11-10 | `diskLayout()` added support for older lsblk versions (linux) | | 4.15.0 | 2019-11-10 | `cpu()` added governor (linux) | | 4.14.17 | 2019-10-22 | `graphics()` improved display detection (windows) | diff --git a/docs/history.html b/docs/history.html index ebee879..94a1f9c 100644 --- a/docs/history.html +++ b/docs/history.html @@ -84,7 +84,12 @@ - 4.15.0 + 4.15.2 + 2019-11-10 + mem() improved calculation linux + + + 4.15.1 2019-11-10 diskLayout() added support for older lsblk versions (linux) diff --git a/docs/index.html b/docs/index.html index 88ba57f..39f31d0 100644 --- a/docs/index.html +++ b/docs/index.html @@ -168,7 +168,7 @@
systeminformation
-
Current Version: 4.15.1
+
Current Version: 4.15.2
From aa22a890fdeca4dc4f88c794e428bca212a0d058 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Sun, 10 Nov 2019 22:22:32 +0100 Subject: [PATCH 26/30] 4.15.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 845ab9e..73e273c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "systeminformation", - "version": "4.15.1", + "version": "4.15.2", "description": "Simple system and OS information library", "license": "MIT", "author": "Sebastian Hildebrandt (https://plus-innovations.com)", From e8a2ead0e5b553fb1f93ff78519166c75f9cf76b Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Sun, 10 Nov 2019 22:38:18 +0100 Subject: [PATCH 27/30] type definitions and docs update --- CHANGELOG.md | 3 ++- README.md | 3 +++ docs/history.html | 5 +++++ docs/memory.html | 30 ++++++++++++++++++++++++++++++ lib/index.d.ts | 4 ++++ 5 files changed, 44 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 030f5d9..9eb4a3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,7 +30,8 @@ For major (breaking) changes - version 3 and 2 see end of page. | Version | Date | Comment | | -------------- | -------------- | -------- | -| 4.15.2 | 2019-11-11 | `mem()` improved calculation linux | +| 4.15.2 | 2019-11-10 | type definitions and docs update | +| 4.15.2 | 2019-11-10 | `mem()` improved calculation linux | | 4.15.1 | 2019-11-10 | `diskLayout()` added support for older lsblk versions (linux) | | 4.15.0 | 2019-11-10 | `cpu()` added governor (linux) | | 4.14.17 | 2019-10-22 | `graphics()` improved display detection (windows) | diff --git a/README.md b/README.md index 8ad39ab..3b84853 100644 --- a/README.md +++ b/README.md @@ -204,6 +204,9 @@ I also created a nice little command line tool called [mmon][mmon-github-url] ( | | used | X | X | X | X | X | used (incl. buffers/cache) | | | active | X | X | X | X | X | used actively (excl. buffers/cache) | | | buffcache | X | X | X | | X | used by buffers+cache | +| | buffers | X | | | | | used by buffers | +| | cached | X | | | | | used by cache | +| | slab | X | | | | | used by slab | | | available | X | X | X | X | X | potentially available (total - active) | | | swaptotal | X | X | X | X | X | | | | swapused | X | X | X | X | X | | diff --git a/docs/history.html b/docs/history.html index 94a1f9c..4b5c709 100644 --- a/docs/history.html +++ b/docs/history.html @@ -83,6 +83,11 @@ + + 4.15.3 + 2019-11-10 + type definitions and docs update + 4.15.2 2019-11-10 diff --git a/docs/memory.html b/docs/memory.html index 2b72317..eb401f3 100644 --- a/docs/memory.html +++ b/docs/memory.html @@ -125,6 +125,36 @@ X used by buffers+cache + + + buffers + X + + + + + used by buffers + + + + cached + X + + + + + used by cache + + + + slab + X + + + + + used by slab + available diff --git a/lib/index.d.ts b/lib/index.d.ts index 996fd71..c4991bf 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -63,6 +63,7 @@ export namespace Systeminformation { speed: string; speedmin: string; speedmax: string; + governor: string; cores: number; physicalCores: number; processors: number; @@ -101,6 +102,9 @@ export namespace Systeminformation { active: number; available: number; buffcache: number; + buffers: number; + cached: number; + slab: number; swaptotal: number; swapused: number; swapfree: number; From dc5858bdde0eb22e2e7ae0e1d76dc0678504ae4b Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Sun, 10 Nov 2019 22:38:50 +0100 Subject: [PATCH 28/30] 4.15.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 73e273c..1652be6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "systeminformation", - "version": "4.15.2", + "version": "4.15.3", "description": "Simple system and OS information library", "license": "MIT", "author": "Sebastian Hildebrandt (https://plus-innovations.com)", From 9f38d346dd62d176df96b4e4f00736e876180335 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Sun, 10 Nov 2019 22:40:50 +0100 Subject: [PATCH 29/30] docs update --- docs/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.html b/docs/index.html index 39f31d0..536300b 100644 --- a/docs/index.html +++ b/docs/index.html @@ -168,7 +168,7 @@
systeminformation
-
Current Version: 4.15.2
+
Current Version: 4.15.3
From 09a2a901f37e4c86ffbbbf3db0b280ff6427b866 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Mon, 11 Nov 2019 19:53:10 +0100 Subject: [PATCH 30/30] networkGatewayDefault() added --- README.md | 1 + docs/index.html | 2 +- docs/network.html | 10 +++++++ lib/index.d.ts | 1 + lib/index.js | 1 + lib/network.js | 70 +++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 84 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3b84853..9fa10d1 100644 --- a/README.md +++ b/README.md @@ -435,6 +435,7 @@ I also created a nice little command line tool called [mmon][mmon-github-url] ( | | [0].speed | X | | X | X | | speed in MBit / s | | | [0].carrierChanges | X | | | | | # changes up/down | | si.networkInterfaceDefault(cb) | : string | X | X | X | X | X | get name of default network interface | +| si.networkGatewayDefault(cb) | : string | X | X | X | X | X | get default network gateway | | si.networkStats(ifaces,cb) | [{...}] | X | X | X | X | | current network stats of given interfaces
iface list: space or comma separated
iface parameter is optional
defaults to first external network interface,
Pass '*' for all interfaces | | | [0].iface | X | X | X | X | | interface | | | [0].operstate | X | X | X | X | | up / down | diff --git a/docs/index.html b/docs/index.html index 536300b..ad733b3 100644 --- a/docs/index.html +++ b/docs/index.html @@ -191,7 +191,7 @@
-
9,371
+
9,445
Lines of code
diff --git a/docs/network.html b/docs/network.html index a55f65c..89865b7 100644 --- a/docs/network.html +++ b/docs/network.html @@ -215,6 +215,16 @@ X get name of default network interface + + si.networkGatewayDefault(cb) + : string + X + X + X + X + X + get default network gateway + si.networkStats(iface,cb) [{...}] diff --git a/lib/index.d.ts b/lib/index.d.ts index c4991bf..f7f5435 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -643,6 +643,7 @@ export function disksIO(cb?: (data: Systeminformation.DisksIoData) => any): Prom export function diskLayout(cb?: (data: Systeminformation.DiskLayoutData[]) => any): Promise; export function networkInterfaceDefault(cb?: (data: string) => any): Promise; +export function networkGatewayDefault(cb?: (data: string) => any): Promise; export function networkInterfaces(cb?: (data: Systeminformation.NetworkInterfacesData[]) => any): Promise; export function networkStats(ifaces?: string, cb?: (data: Systeminformation.NetworkStatsData[]) => any): Promise; diff --git a/lib/index.js b/lib/index.js index c2057be..07e62a0 100644 --- a/lib/index.js +++ b/lib/index.js @@ -347,6 +347,7 @@ exports.disksIO = filesystem.disksIO; exports.diskLayout = filesystem.diskLayout; exports.networkInterfaceDefault = network.networkInterfaceDefault; +exports.networkGatewayDefault = network.networkGatewayDefault; exports.networkInterfaces = network.networkInterfaces; exports.networkStats = network.networkStats; exports.networkConnections = network.networkConnections; diff --git a/lib/network.js b/lib/network.js index eb073f1..61afdb5 100644 --- a/lib/network.js +++ b/lib/network.js @@ -1002,3 +1002,73 @@ function networkConnections(callback) { } exports.networkConnections = networkConnections; + +function networkGatewayDefault(callback) { + + return new Promise((resolve) => { + process.nextTick(() => { + let result = ''; + if (_linux || _freebsd || _openbsd || _netbsd) { + let cmd = 'ip route get 1'; + try { + exec(cmd, { maxBuffer: 1024 * 20000 }, function (error, stdout) { + if (!error) { + let lines = stdout.toString().split('\n'); + const line = lines && lines[0] ? lines[0] : ''; + let parts = line.split(' via '); + if (parts && parts[1]) { + parts = parts[1].split(' '); + result = parts[0]; + } + if (callback) { + callback(result); + } + resolve(result); + } + }); + } catch (e) { + if (callback) { callback(result); } + resolve(result); + } + } + if (_darwin) { + let cmd = 'route -n get default'; + try { + exec(cmd, { maxBuffer: 1024 * 20000 }, function (error, stdout) { + if (!error) { + let lines = stdout.toString().split('\n').map(line => line.trim()); + result = util.getValue(lines, 'gateway'); + if (callback) { + callback(result); + } + resolve(result); + } + }); + } catch (e) { + if (callback) { callback(result); } + resolve(result); + } + } + if (_windows) { + try { + util.powerShell('Get-CimInstance -ClassName Win32_IP4RouteTable | Where-Object { $_.Destination -eq \'0.0.0.0\' -and $_.Mask -eq \'0.0.0.0\' }).InterfaceIndex') + .then(data => { + let lines = data.toString().split('\r\n'); + result = lines && lines[0] ? lines[0] : ''; + if (callback) { + callback(result); + } + resolve(result); + + }); + } catch (e) { + if (callback) { callback(result); } + resolve(result); + } + } + }); + }); +} + + +exports.networkGatewayDefault = networkGatewayDefault;