systeminformation 5.13.5 → 5.14.1

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/README.md CHANGED
@@ -112,6 +112,7 @@ si.cpu()
112
112
 
113
113
  (last 7 major and minor version releases)
114
114
 
115
+ - Version 5.14.0: `blockDevices()` added raid group member (linux)
115
116
  - Version 5.13.0: `networkConnections()` added process name (mac OS)
116
117
  - Version 5.12.0: `cpu()` added performance and efficiency cores
117
118
  - Version 5.11.0: `networkInterfaces()` added default property and default parameter
@@ -464,6 +465,7 @@ Full function reference with examples can be found at [https://systeminformation
464
465
  | | [0].serial | X | | | X | | serial |
465
466
  | | [0].removable | X | | X | X | | serial |
466
467
  | | [0].protocol | X | | X | | | protocol (SATA, PCI-Express, ...) |
468
+ | | [0].group | X | | | | | Raid group member (e.g. md1) |
467
469
  | si.disksIO(cb) | {...} | X | | X | | | current transfer stats |
468
470
  | | rIO | X | | X | | | read IOs on all mounted drives |
469
471
  | | wIO | X | | X | | | write IOs on all mounted drives |
package/lib/filesystem.js CHANGED
@@ -88,7 +88,6 @@ function fsSize(callback) {
88
88
  const use = parseFloat((100.0 * (used / (used + available))).toFixed(2));
89
89
  line.splice(0, (_linux || _freebsd || _openbsd || _netbsd) ? 6 : 5);
90
90
  const mount = line.join(' ');
91
- // const mount = line[line.length - 1];
92
91
  if (!data.find(el => (el.fs === fs && el.type === fsType))) {
93
92
  data.push({
94
93
  fs,
@@ -121,7 +120,7 @@ function fsSize(callback) {
121
120
  macOsDisks = [];
122
121
  }
123
122
  }
124
- if (_linux) { cmd = 'df -lkPTx squashfs'; } // cmd = 'df -lkPTx squashfs | grep -E "^/|^.\\:"';
123
+ if (_linux) { cmd = 'df -lkPTx squashfs'; }
125
124
  if (_freebsd || _openbsd || _netbsd) { cmd = 'df -lkPT'; }
126
125
  exec(cmd, { maxBuffer: 1024 * 1024 }, function (error, stdout) {
127
126
  let lines = filterLines(stdout);
@@ -343,7 +342,7 @@ function parseBlk(lines) {
343
342
  'serial': disk.serial,
344
343
  'removable': disk.rm === '1',
345
344
  'protocol': disk.tran,
346
- 'group': disk.group,
345
+ 'group': disk.group || '',
347
346
  });
348
347
  } catch (e) {
349
348
  util.noop();
@@ -354,6 +353,44 @@ function parseBlk(lines) {
354
353
  return data;
355
354
  }
356
355
 
356
+ function decodeMdabmData(lines) {
357
+ const raid = util.getValue(lines, 'md_level', '=');
358
+ const members = [];
359
+ lines.forEach(line => {
360
+ if (line.toLowerCase().startsWith('md_device_ev') && line.toLowerCase().indexOf('/dev/') > 0) {
361
+ members.push(line.split('/dev/')[1]);
362
+ }
363
+ });
364
+ return {
365
+ raid,
366
+ members
367
+ };
368
+ }
369
+
370
+ function raidMatchLunix(data) {
371
+ // for all block devices of type "raid%"
372
+ let result = data;
373
+ try {
374
+ data.forEach(element => {
375
+ if (element.type.startsWith('raid')) {
376
+ const lines = execSync(`mdadm --export --detail /dev/${element.name}`).toString().split('\n');
377
+ const mdData = decodeMdabmData(lines);
378
+ if (mdData.members && mdData.members.length && mdData.raid === element.type) {
379
+ result = result.map(blockdevice => {
380
+ if (blockdevice.fsType === 'linux_raid_member' && mdData.members.indexOf(blockdevice.name) >= 0) {
381
+ blockdevice.group = element.name;
382
+ }
383
+ return blockdevice;
384
+ });
385
+ }
386
+ }
387
+ });
388
+ } catch (e) {
389
+ util.noop();
390
+ }
391
+ return result;
392
+ }
393
+
357
394
  function blkStdoutToObject(stdout) {
358
395
  return stdout.toString()
359
396
  .replace(/NAME=/g, '{"name":')
@@ -386,6 +423,7 @@ function blockDevices(callback) {
386
423
  if (!error) {
387
424
  let lines = blkStdoutToObject(stdout).split('\n');
388
425
  data = parseBlk(lines);
426
+ data = raidMatchLunix(data);
389
427
  if (callback) {
390
428
  callback(data);
391
429
  }
@@ -395,6 +433,7 @@ function blockDevices(callback) {
395
433
  if (!error) {
396
434
  let lines = blkStdoutToObject(stdout).split('\n');
397
435
  data = parseBlk(lines);
436
+ data = raidMatchLunix(data);
398
437
  }
399
438
  if (callback) {
400
439
  callback(data);
package/lib/index.d.ts CHANGED
@@ -456,6 +456,7 @@ export namespace Systeminformation {
456
456
  serial: string;
457
457
  removable: boolean;
458
458
  protocol: string;
459
+ group?: string;
459
460
  }
460
461
 
461
462
  interface FsStatsData {
package/lib/memory.js CHANGED
@@ -323,12 +323,16 @@ function memLayout(callback) {
323
323
  let lines = device.split('\n');
324
324
  const sizeString = util.getValue(lines, 'Size');
325
325
  const size = sizeString.indexOf('GB') >= 0 ? parseInt(sizeString, 10) * 1024 * 1024 * 1024 : parseInt(sizeString, 10) * 1024 * 1024;
326
+ let bank = util.getValue(lines, 'Bank Locator');
327
+ if (bank.toLowerCase().indexOf('bad') >= 0) {
328
+ bank = '';
329
+ }
326
330
  if (parseInt(util.getValue(lines, 'Size'), 10) > 0) {
327
331
  const totalWidth = util.toInt(util.getValue(lines, 'Total Width'));
328
332
  const dataWidth = util.toInt(util.getValue(lines, 'Data Width'));
329
333
  result.push({
330
334
  size,
331
- bank: util.getValue(lines, 'Bank Locator'),
335
+ bank,
332
336
  type: util.getValue(lines, 'Type:'),
333
337
  ecc: dataWidth && totalWidth ? totalWidth > dataWidth : false,
334
338
  clockSpeed: (util.getValue(lines, 'Configured Clock Speed:') ? parseInt(util.getValue(lines, 'Configured Clock Speed:'), 10) : (util.getValue(lines, 'Speed:') ? parseInt(util.getValue(lines, 'Speed:'), 10) : null)),
@@ -343,7 +347,7 @@ function memLayout(callback) {
343
347
  } else {
344
348
  result.push({
345
349
  size: 0,
346
- bank: util.getValue(lines, 'Bank Locator'),
350
+ bank,
347
351
  type: 'Empty',
348
352
  ecc: null,
349
353
  clockSpeed: 0,
package/lib/users.js CHANGED
@@ -209,7 +209,6 @@ function users(callback) {
209
209
  try {
210
210
  let cmd = 'Get-CimInstance Win32_LogonSession | select LogonId,@{n="StartTime";e={$_.StartTime.ToString("yyyy-MM-dd HH:mm:ss")}} | fl' + '; echo \'#-#-#-#\';';
211
211
  cmd += 'Get-CimInstance Win32_LoggedOnUser | select antecedent,dependent | fl ' + '; echo \'#-#-#-#\';';
212
- // cmd += `Get-CimInstance Win32_Process -Filter 'name="explorer.exe"' | Select @{Name="sessionid";Expression={$_.SessionId}}, @{Name="domain";Expression={$_.GetOwner().Domain}}, @{Name="username";Expression={$_.GetOwner().User}} | fl` + '; echo \'#-#-#-#\';';
213
212
  cmd += '$process = (Get-CimInstance Win32_Process -Filter "name = \'explorer.exe\'"); Invoke-CimMethod -InputObject $process -MethodName GetOwner | select user, domain | fl; get-process -name explorer | select-object sessionid | fl; echo \'#-#-#-#\';';
214
213
  cmd += 'query user';
215
214
  util.powerShell(cmd).then((data) => {
@@ -257,17 +256,6 @@ function users(callback) {
257
256
  });
258
257
  }
259
258
 
260
- // function parseWinAccounts(accountParts) {
261
- // const accounts = [];
262
- // accountParts.forEach(account => {
263
- // const lines = account.split('\r\n');
264
- // const name = util.getValue(lines, 'name', ':', true);
265
- // const domain = util.getValue(lines, 'domain', ':', true);
266
- // accounts.push(`${domain}\${name}`);
267
- // });
268
- // return accounts;
269
- // }
270
-
271
259
  function parseWinSessions(sessionParts) {
272
260
  const sessions = {};
273
261
  sessionParts.forEach(session => {
@@ -325,7 +313,7 @@ function parseWinLoggedOn(loggedonParts) {
325
313
  const antecendent = util.getValue(lines, 'antecedent', ':', true);
326
314
  let parts = antecendent.split('=');
327
315
  const name = parts.length > 2 ? parts[1].split(',')[0].replace(/"/g, '').trim() : '';
328
- const domain = parts.length > 2 ? parts[2].replace(/"/g, '').trim() : '';
316
+ const domain = parts.length > 2 ? parts[2].replace(/"/g, '').replace(/\)/g, '').trim() : '';
329
317
  const dependent = util.getValue(lines, 'dependent', ':', true);
330
318
  parts = dependent.split('=');
331
319
  const id = parts.length > 1 ? parts[1].replace(/"/g, '').replace(/\)/g, '').trim() : '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "systeminformation",
3
- "version": "5.13.5",
3
+ "version": "5.14.1",
4
4
  "description": "Advanced, lightweight system and OS information library",
5
5
  "license": "MIT",
6
6
  "author": "Sebastian Hildebrandt <hildebrandt@plus-innovations.com> (https://plus-innovations.com)",