From cb57b5c090b71d8f3ff7b793d7b204825d8f7e54 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Wed, 8 Apr 2020 15:43:16 +0200 Subject: [PATCH] cpu() fixed getting base frequency for AMD Ryzen --- CHANGELOG.md | 1 + docs/history.html | 5 +++++ docs/index.html | 4 ++-- docs/trademarks.html | 1 + lib/cpu.js | 13 ++++++------- lib/network.js | 32 +++++++++++++++++++++++++------- lib/osinfo.js | 8 ++++---- 7 files changed, 44 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d6e5a92..576e266 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.23.2 | 2020-04-08 | `cpu()` fixed getting base frequency for AMD Ryzen | | 4.23.1 | 2020-03-11 | `diskLayout()` optimized detection linux | | 4.23.0 | 2020-03-08 | `versions()` added param to specify which program/lib versions to detect | | 4.22.7 | 2020-03-08 | `diskLayout()` fixed linux | diff --git a/docs/history.html b/docs/history.html index 91d8124..1a3a1f3 100644 --- a/docs/history.html +++ b/docs/history.html @@ -83,6 +83,11 @@ + + 4.23.2 + 2020-04-08 + cpu() fixed getting base speed Ryzen CPUs + 4.23.1 2020-03-11 diff --git a/docs/index.html b/docs/index.html index 5f3561e..5f713c7 100644 --- a/docs/index.html +++ b/docs/index.html @@ -168,7 +168,7 @@
systeminformation
-
Current Version: 4.23.1
+
Current Version: 4.23.2
@@ -207,7 +207,7 @@
Downloads last month
-
255
+
261
Dependends
diff --git a/docs/trademarks.html b/docs/trademarks.html index 02b03eb..c8e196d 100644 --- a/docs/trademarks.html +++ b/docs/trademarks.html @@ -50,6 +50,7 @@
  • Windows is a registered trademark of Microsoft Corporation
  • Intel is a trademark of Intel Corporation
  • AMD is a trademark of Advanced Micro Devices Inc.
  • +
  • Ryzen is a trademark of Advanced Micro Devices Inc.
  • Raspberry Pi is a trademark of the Raspberry Pi Foundation
  • Debian is a trademark of the Debian Project
  • FreeBSD is a registered trademark of The FreeBSD Foundation
  • diff --git a/lib/cpu.js b/lib/cpu.js index f40d879..388e988 100644 --- a/lib/cpu.js +++ b/lib/cpu.js @@ -232,7 +232,7 @@ const AMDBaseFrequencies = { '7351P': '2.4', '2300X': '3.5', '2500X': '3.6', - '2600': '3.1', + '2600': '3.4', '2600E': '3.1', '2600X': '3.6', '2700': '3.2', @@ -452,7 +452,7 @@ function getCpu() { modelline = util.getValue(lines, 'model name') || modelline; result.brand = modelline.split('@')[0].trim(); result.speed = modelline.split('@')[1] ? parseFloat(modelline.split('@')[1].trim()).toFixed(2) : '0.00'; - if (result.speed === '0.00' && result.brand.indexOf('AMD') > -1) { + if (result.speed === '0.00' && (result.brand.indexOf('AMD') > -1 || result.brand.toLowerCase().indexOf('ryzen') > -1)) { result.speed = getAMDSpeed(result.brand); } if (result.speed === '0.00') { @@ -517,7 +517,7 @@ function getCpu() { } result.brand = modelline.split('@')[0].trim(); result.speed = modelline.split('@')[1] ? parseFloat(modelline.split('@')[1].trim()).toFixed(2) : '0.00'; - if (result.speed === '0.00' && result.brand.indexOf('AMD') > -1) { + if (result.speed === '0.00' && (result.brand.indexOf('AMD') > -1 || result.brand.toLowerCase().indexOf('ryzen') > -1)) { result.speed = getAMDSpeed(result.brand); } if (result.speed === '0.00') { @@ -582,12 +582,11 @@ function getCpu() { let name = util.getValue(lines, 'name', '=') || ''; if (name.indexOf('@') >= 0) { result.brand = name.split('@')[0].trim(); - result.speed = name.split('@')[1].trim(); - result.speed = parseFloat(result.speed.replace(/GHz+/g, '').trim()).toFixed(2); + result.speed = name.split('@')[1] ? parseFloat(name.split('@')[1].trim()).toFixed(2) : '0.00'; _cpu_speed = result.speed; } else { result.brand = name.trim(); - result.speed = 0; + result.speed = '0.00'; } result = cpuBrandManufacturer(result); result.revision = util.getValue(lines, 'revision', '='); @@ -600,7 +599,7 @@ function getCpu() { result.vendor = util.getValue(lines, 'manufacturer', '='); result.speedmax = Math.round(parseFloat(util.getValue(lines, 'maxclockspeed', '=').replace(/,/g, '.')) / 10.0) / 100; result.speedmax = result.speedmax ? parseFloat(result.speedmax).toFixed(2) : ''; - if (!result.speed && result.brand.indexOf('AMD') > -1) { + if (result.speed === '0.00' && (result.brand.indexOf('AMD') > -1 || result.brand.toLowerCase().indexOf('ryzen') > -1)) { result.speed = getAMDSpeed(result.brand); } if (result.speed === '0.00') { diff --git a/lib/network.js b/lib/network.js index ca48159..e5a69ce 100644 --- a/lib/network.js +++ b/lib/network.js @@ -198,7 +198,7 @@ function parseLinesWindowsNics(sections, nconfigsections) { let linesNicConfig = nconfigsections[i].trim().split('\r\n'); let netEnabled = util.getValue(lines, 'NetEnabled', '='); - if (netEnabled) { + if (netEnabled !== '') { const speed = parseInt(util.getValue(lines, 'speed', '=').trim(), 10) / 1000000; nics.push({ mac: util.getValue(lines, 'MACAddress', '=').toLowerCase(), @@ -560,13 +560,13 @@ function getLinuxIfaceDHCPstatus(iface, connectionName, DHCPNics) { let dhcStatus = resultFormat.split(' ').slice(1).toString(); switch (dhcStatus) { - case 'auto': - result = true; - break; + case 'auto': + result = true; + break; - default: - result = false; - break; + default: + result = false; + break; } return result; } catch (e) { @@ -656,6 +656,24 @@ function networkInterfaces(callback) { return new Promise((resolve) => { process.nextTick(() => { let ifaces = os.networkInterfaces(); + if (_windows) { + getWindowsNics().forEach(nic => { + let found = false; + Object.keys(ifaces).forEach(key => { + if (!found) { + ifaces[key].forEach(value => { + if (Object.keys(value).indexOf('mac') >= 0) { + found = value['mac'] === nic.mac; + } + }); + } + }); + + if (!found) { + ifaces[nic.name] = [{ mac: nic.mac }]; + } + }); + } let result = []; let nics = []; let dnsSuffixes = []; diff --git a/lib/osinfo.js b/lib/osinfo.js index 6e3d088..9d373a9 100644 --- a/lib/osinfo.js +++ b/lib/osinfo.js @@ -391,7 +391,7 @@ function versions(apps, callback) { return { versions: versionObject, counter: 26 - } + }; } if (!Array.isArray(apps)) { apps = apps.trim().toLowerCase().replace(/,+/g, '|').replace(/ /g, '|'); @@ -399,7 +399,7 @@ function versions(apps, callback) { const result = { versions: {}, counter: 0 - } + }; apps.forEach(el => { if (el) { for (let key in versionObject) { @@ -807,8 +807,8 @@ function versions(apps, callback) { }); } } catch (e) { - if (callback) { callback(result); } - resolve(result); + if (callback) { callback(appsObj.versions); } + resolve(appsObj.versions); } }); });