systeminformation 5.7.3 → 5.7.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -53,8 +53,8 @@ We had to make **several interface changes** to keep systeminformation as consis
53
53
  - `getData()`: support for passing parameters and filters (see section General / getData)
54
54
  - `graphics()`: extended nvidia-smi parsing
55
55
  - `networkInterfaces()`: type detection improved (win - wireless)
56
- - `memoryLayout()`: extended manufacturer list (decoding)
57
- - `memoryLayout()`: added ECC flag
56
+ - `memLayout()`: extended manufacturer list (decoding)
57
+ - `memLayout()`: added ECC flag
58
58
  - `osInfo()`: better fqdn (win)
59
59
  - `osinfo()`: added hypervizor if hyper-v is enabled (win only)
60
60
  - `osInfo()`: added remoteSession (win only)
@@ -77,6 +77,10 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page.
77
77
 
78
78
  | Version | Date | Comment |
79
79
  | -------------- | -------------- | -------- |
80
+ | 5.7.7 | 2021-06-15 | `graphics()` improved detection screen resolution (macOS) |
81
+ | 5.7.6 | 2021-06-09 | `battery()` improved detection (additional batteries windows) |
82
+ | 5.7.5 | 2021-06-08 | `memLayout()` improved clock speed detection (windows) |
83
+ | 5.7.4 | 2021-05-27 | `osInfo()`, `cpu()` improved hypervisor, virtualization detection (windows) |
80
84
  | 5.7.3 | 2021-05-26 | `osInfo()` improved UEFI detection (windows) |
81
85
  | 5.7.2 | 2021-05-24 | `system()` virtual detection improvement |
82
86
  | 5.7.1 | 2021-05-20 | `graphics()` Check for qwMemorySize on Windows |
package/lib/battery.js CHANGED
@@ -27,6 +27,40 @@ const _openbsd = (_platform === 'openbsd');
27
27
  const _netbsd = (_platform === 'netbsd');
28
28
  const _sunos = (_platform === 'sunos');
29
29
 
30
+ function parseWinBatteryPart(lines, designCapacity, fullChargeCapacity) {
31
+ const result = {};
32
+ let status = util.getValue(lines, 'BatteryStatus', '=').trim();
33
+ // 1 = "Discharging"
34
+ // 2 = "On A/C"
35
+ // 3 = "Fully Charged"
36
+ // 4 = "Low"
37
+ // 5 = "Critical"
38
+ // 6 = "Charging"
39
+ // 7 = "Charging High"
40
+ // 8 = "Charging Low"
41
+ // 9 = "Charging Critical"
42
+ // 10 = "Undefined"
43
+ // 11 = "Partially Charged"
44
+ if (status >= 0) {
45
+ const statusValue = status ? parseInt(status) : 0;
46
+ result.status = statusValue;
47
+ result.hasBattery = true;
48
+ result.maxCapacity = fullChargeCapacity || parseInt(util.getValue(lines, 'DesignCapacity', '=') || 0);
49
+ result.designCapacity = parseInt(util.getValue(lines, 'DesignCapacity', '=') || designCapacity);
50
+ result.voltage = parseInt(util.getValue(lines, 'DesignVoltage', '=') || 0) / 1000.0;
51
+ result.capacityUnit = 'mWh';
52
+ result.percent = parseInt(util.getValue(lines, 'EstimatedChargeRemaining', '=') || 0);
53
+ result.currentCapacity = parseInt(result.maxCapacity * result.percent / 100);
54
+ result.isCharging = (statusValue >= 6 && statusValue <= 9) || statusValue === 11 || (!(statusValue === 3) && !(statusValue === 1) && result.percent < 100);
55
+ result.acConnected = result.ischarging || statusValue === 2;
56
+ result.model = util.getValue(lines, 'DeviceID', '=');
57
+ } else {
58
+ result.status = -1;
59
+ }
60
+
61
+ return result;
62
+ }
63
+
30
64
  module.exports = function (callback) {
31
65
 
32
66
  return new Promise((resolve) => {
@@ -175,32 +209,76 @@ module.exports = function (callback) {
175
209
  }
176
210
  if (_windows) {
177
211
  try {
178
- util.wmic('Path Win32_Battery Get BatteryStatus, DesignCapacity, EstimatedChargeRemaining, DesignVoltage, FullChargeCapacity /value').then((stdout) => {
179
- if (stdout) {
180
- let lines = stdout.split('\r\n');
181
- let status = util.getValue(lines, 'BatteryStatus', '=').trim();
182
- // 1 = "Discharging"
183
- // 2 = "On A/C"
184
- // 3 = "Fully Charged"
185
- // 4 = "Low"
186
- // 5 = "Critical"
187
- // 6 = "Charging"
188
- // 7 = "Charging High"
189
- // 8 = "Charging Low"
190
- // 9 = "Charging Critical"
191
- // 10 = "Undefined"
192
- // 11 = "Partially Charged"
193
- if (status && status != '10') {
194
- const statusValue = parseInt(status);
195
- result.hasBattery = true;
196
- result.maxCapacity = parseInt(util.getValue(lines, 'DesignCapacity', '=') || 0);
197
- result.designCapacity = parseInt(util.getValue(lines, 'DesignCapacity', '=') || 0);
198
- result.voltage = parseInt(util.getValue(lines, 'DesignVoltage', '=') || 0) / 1000.0;
199
- result.capacityUnit = 'mWh';
200
- result.percent = parseInt(util.getValue(lines, 'EstimatedChargeRemaining', '=') || 0);
201
- result.currentCapacity = parseInt(result.maxcapacity * result.percent / 100);
202
- result.isCharging = (statusValue >= 6 && statusValue <= 9) || statusValue === 11 || (!(statusValue === 3) && !(statusValue === 1) && result.percent < 100);
203
- result.acConnected = result.ischarging || statusValue === 2;
212
+ const workload = [];
213
+ workload.push(util.wmic('Path Win32_Battery Get /value'));
214
+ workload.push(util.powerShell('(Get-WmiObject -Class BatteryStaticData -Namespace ROOT/WMI).DesignedCapacity'));
215
+ workload.push(util.powerShell('(Get-WmiObject -Class BatteryFullChargedCapacity -Namespace ROOT/WMI).FullChargedCapacity'));
216
+ util.promiseAll(
217
+ workload
218
+ ).then(data => {
219
+ if (data) {
220
+ // let parts = data.results[0].split(/\n\s*\n/);
221
+ let parts = data.results[0].split('\r\n');
222
+ let batteries = [];
223
+ for (let i = 0; i < parts.length; i++) {
224
+ const hasValue = value => /\S/.test(value);
225
+ if (hasValue(parts[i]) && (!batteries.length || !hasValue(parts[i - 1]))) {
226
+ batteries.push([]);
227
+ }
228
+ if (hasValue(parts[i])) {
229
+ batteries[batteries.length - 1].push(parts[i]);
230
+ }
231
+ }
232
+ let designCapacities = data.results[1].split('\r\n');
233
+ let fullChargeCapacities = data.results[2].split('\r\n');
234
+ if (batteries.length) {
235
+ let first = false;
236
+ let additionalBatteries = [];
237
+ for (let i = 0; i < batteries.length; i++) {
238
+ let lines = batteries[i];
239
+ const designCapacity = designCapacities && designCapacities.length >= (i + 1) && designCapacities[i] ? util.toInt(designCapacities[i]) : 0;
240
+ const fullChargeCapacity = fullChargeCapacities && fullChargeCapacities.length >= (i + 1) && fullChargeCapacities[i] ? util.toInt(fullChargeCapacities[i]) : 0;
241
+ const parsed = parseWinBatteryPart(lines, designCapacity, fullChargeCapacity);
242
+ if (!first && parsed.status > 0 && parsed.status !== 10) {
243
+ result.hasBattery = parsed.hasBattery;
244
+ result.maxCapacity = parsed.maxCapacity;
245
+ result.designCapacity = parsed.designCapacity;
246
+ result.voltage = parsed.voltage;
247
+ result.capacityUnit = parsed.capacityUnit;
248
+ result.percent = parsed.percent;
249
+ result.currentCapacity = parsed.currentCapacity;
250
+ result.isCharging = parsed.isCharging;
251
+ result.acConnected = parsed.acConnected;
252
+ result.model = parsed.model;
253
+ first = true;
254
+ } else if (parsed.status !== -1) {
255
+ additionalBatteries.push(
256
+ {
257
+ hasBattery: parsed.hasBattery,
258
+ maxCapacity: parsed.maxCapacity,
259
+ designCapacity: parsed.designCapacity,
260
+ voltage: parsed.voltage,
261
+ capacityUnit: parsed.capacityUnit,
262
+ percent: parsed.percent,
263
+ currentCapacity: parsed.currentCapacity,
264
+ isCharging: parsed.isCharging,
265
+ timeRemaining: null,
266
+ acConnected: parsed.acConnected,
267
+ model: parsed.model,
268
+ type: '',
269
+ manufacturer: '',
270
+ serial: ''
271
+ }
272
+ );
273
+ }
274
+ }
275
+ if (!first && additionalBatteries.length) {
276
+ result = additionalBatteries[0];
277
+ additionalBatteries.shift();
278
+ }
279
+ if (additionalBatteries.length) {
280
+ result.additionalBatteries = additionalBatteries;
281
+ }
204
282
  }
205
283
  }
206
284
  if (callback) { callback(result); }
package/lib/cpu.js CHANGED
@@ -550,14 +550,14 @@ function getCpu() {
550
550
  cpuFlags().then(flags => {
551
551
  result.flags = flags;
552
552
  result.virtualization = flags.indexOf('vmx') > -1 || flags.indexOf('svm') > -1;
553
- if (_windows) {
554
- try {
555
- const systeminfo = execSync('systeminfo', util.execOptsWin).toString();
556
- result.virtualization = result.virtualization || (systeminfo.indexOf('Virtualization Enabled In Firmware: Yes') !== -1) || (systeminfo.indexOf('Virtualisierung in Firmware aktiviert: Ja') !== -1) || (systeminfo.indexOf('Virtualisation activée dans le microprogramme : Qiu') !== -1);
557
- } catch (e) {
558
- util.noop();
559
- }
560
- }
553
+ // if (_windows) {
554
+ // try {
555
+ // const systeminfo = execSync('systeminfo', util.execOptsWin).toString();
556
+ // result.virtualization = result.virtualization || (systeminfo.indexOf('Virtualization Enabled In Firmware: Yes') !== -1) || (systeminfo.indexOf('Virtualisierung in Firmware aktiviert: Ja') !== -1) || (systeminfo.indexOf('Virtualisation activée dans le microprogramme : Qiu') !== -1);
557
+ // } catch (e) {
558
+ // util.noop();
559
+ // }
560
+ // }
561
561
  if (_darwin) {
562
562
  exec('sysctl machdep.cpu hw.cpufrequency_max hw.cpufrequency_min hw.packages hw.physicalcpu_max hw.ncpu hw.tbfrequency hw.cpufamily hw.cpusubfamily', function (error, stdout) {
563
563
  let lines = stdout.toString().split('\n');
@@ -753,6 +753,7 @@ function getCpu() {
753
753
  const workload = [];
754
754
  workload.push(util.wmic('cpu get /value'));
755
755
  workload.push(util.wmic('path Win32_CacheMemory get CacheType,InstalledSize,Purpose'));
756
+ workload.push(util.powerShell('Get-ComputerInfo -property "HyperV*"'));
756
757
 
757
758
  Promise.all(
758
759
  workload
@@ -831,6 +832,10 @@ function getCpu() {
831
832
  }
832
833
  }
833
834
  });
835
+ lines = data[2].split('\r\n');
836
+ result.virtualization = (util.getValue(lines, 'HyperVRequirementVirtualizationFirmwareEnabled').toLowerCase() === 'true');
837
+ result.virtualization = (util.getValue(lines, 'HyperVisorPresent').toLowerCase() === 'true');
838
+
834
839
  resolve(result);
835
840
  });
836
841
  } catch (e) {
@@ -1608,5 +1613,3 @@ function fullLoad(callback) {
1608
1613
  }
1609
1614
 
1610
1615
  exports.fullLoad = fullLoad;
1611
-
1612
-
package/lib/graphics.js CHANGED
@@ -172,10 +172,20 @@ function graphics(callback) {
172
172
  if (4 === level) { // display controller details level
173
173
  if (parts.length > 1 && parts[0].replace(/ +/g, '').toLowerCase().indexOf('resolution') !== -1) {
174
174
  let resolution = parts[1].split('x');
175
- currentDisplay.resolutionX = (resolution.length > 1 ? parseInt(resolution[0]) : 0);
176
- currentDisplay.resolutionY = (resolution.length > 1 ? parseInt(resolution[1]) : 0);
177
- currentDisplay.currentResX = currentDisplay.resolutionX;
178
- currentDisplay.currentResY = currentDisplay.resolutionY;
175
+ if (resolution.length > 1) {
176
+ let xpart = resolution[0];
177
+ if (xpart.indexOf('(') !== -1) {
178
+ xpart = xpart.split('(').slice(-1)[0];
179
+ }
180
+ let ypart = resolution[1];
181
+ if (ypart.indexOf(')') !== -1) {
182
+ ypart = ypart.split(')')[0];
183
+ }
184
+ currentDisplay.resolutionX = parseInt(xpart) || 0;
185
+ currentDisplay.resolutionY = parseInt(ypart) || 0;
186
+ currentDisplay.currentResX = currentDisplay.resolutionX;
187
+ currentDisplay.currentResY = currentDisplay.resolutionY;
188
+ }
179
189
  }
180
190
  if (parts.length > 1 && parts[0].replace(/ +/g, '').toLowerCase().indexOf('pixeldepth') !== -1) { currentDisplay.pixelDepth = parseInt(parts[1]); } // in BIT
181
191
  if (parts.length > 1 && parts[0].replace(/ +/g, '').toLowerCase().indexOf('framebufferdepth') !== -1) { currentDisplay.pixelDepth = parseInt(parts[1]); } // in BIT
package/lib/index.d.ts CHANGED
@@ -284,6 +284,7 @@ export namespace Systeminformation {
284
284
  model: string;
285
285
  manufacturer: string;
286
286
  serial: string;
287
+ additionalBatteries?: BatteryData[];
287
288
  }
288
289
 
289
290
  interface GraphicsData {
package/lib/memory.js CHANGED
@@ -510,7 +510,7 @@ function memLayout(callback) {
510
510
  bank: util.getValue(lines, 'abel', '='), // BankLabel
511
511
  type: memoryTypes[parseInt(util.getValue(lines, 'MemoryType', '='), 10)],
512
512
  ecc: dataWidth && totalWidth ? totalWidth > dataWidth : false,
513
- clockSpeed: parseInt(util.getValue(lines, 'ConfiguredClockSpeed', '='), 10) || 0,
513
+ clockSpeed: parseInt(util.getValue(lines, 'ConfiguredClockSpeed', '='), 10) || parseInt(util.getValue(lines, 'Speed', '='), 10) || 0,
514
514
  formFactor: FormFactors[parseInt(util.getValue(lines, 'FormFactor', '='), 10) || 0],
515
515
  manufacturer: util.getValue(lines, 'Manufacturer', '='),
516
516
  partNum: util.getValue(lines, 'PartNumber', '='),
package/lib/osinfo.js CHANGED
@@ -18,7 +18,7 @@ const fs = require('fs');
18
18
  const util = require('./util');
19
19
  const exec = require('child_process').exec;
20
20
  const execSync = require('child_process').execSync;
21
- const execPromise = util.promisify(require('child_process').exec);
21
+ // const execPromise = util.promisify(require('child_process').exec);
22
22
 
23
23
  let _platform = process.platform;
24
24
 
@@ -323,7 +323,8 @@ function osInfo(callback) {
323
323
  try {
324
324
  const workload = [];
325
325
  workload.push(util.wmic('os get /value'));
326
- workload.push(execPromise('systeminfo', util.execOptsWin));
326
+ // workload.push(execPromise('systeminfo', util.execOptsWin));
327
+ workload.push(util.powerShell('Get-ComputerInfo -property "HyperV*"'));
327
328
  workload.push(util.powerShell('Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SystemInformation]::TerminalServerSession'));
328
329
  util.promiseAll(
329
330
  workload
@@ -334,8 +335,10 @@ function osInfo(callback) {
334
335
  result.build = util.getValue(lines, 'BuildNumber', '=').trim();
335
336
  result.servicepack = util.getValue(lines, 'ServicePackMajorVersion', '=').trim() + '.' + util.getValue(lines, 'ServicePackMinorVersion', '=').trim();
336
337
  result.codepage = util.getCodepage();
337
- const systeminfo = data.results[1] ? data.results[1].toString() : '';
338
- result.hypervisor = (systeminfo.indexOf('hypervisor has been detected') !== -1) || (systeminfo.indexOf('Es wurde ein Hypervisor erkannt') !== -1) || (systeminfo.indexOf('Un hyperviseur a ') !== -1);
338
+ // const systeminfo = data.results[1] ? data.results[1].toString() : '';
339
+ // result.hypervisor = (systeminfo.indexOf('hypervisor has been detected') !== -1) || (systeminfo.indexOf('Es wurde ein Hypervisor erkannt') !== -1) || (systeminfo.indexOf('Un hyperviseur a ') !== -1);
340
+ const hyperv = data.results[1] ? data.results[1].toString().split('\r\n') : [];
341
+ result.hypervisor = (util.getValue(hyperv, 'HyperVisorPresent').toLowerCase() === 'true');
339
342
  const term = data.results[2] ? data.results[2].toString() : '';
340
343
  result.remoteSession = (term.toString().toLowerCase().indexOf('true') >= 0);
341
344
  isUefiWindows().then(uefi => {
@@ -384,7 +387,7 @@ function isUefiWindows() {
384
387
  exec('findstr /C:"Detected boot environment" "%windir%\\Panther\\setupact.log"', util.execOptsWin, function (error, stdout) {
385
388
  if (!error) {
386
389
  const line = stdout.toString().split('\n\r')[0];
387
- resolve(line.toLowerCase().indexOf('uefi') >= 0 || line.toLowerCase().indexOf(' efi') >= 0);
390
+ resolve(line.toLowerCase().indexOf('efi') >= 0);
388
391
  return;
389
392
  } else {
390
393
  exec('echo %firmware_type%', util.execOptsWin, function (error, stdout) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "systeminformation",
3
- "version": "5.7.3",
3
+ "version": "5.7.7",
4
4
  "description": "Simple system and OS information library",
5
5
  "license": "MIT",
6
6
  "author": "Sebastian Hildebrandt <hildebrandt@plus-innovations.com> (https://plus-innovations.com)",