systeminformation 5.14.3 → 5.15.0

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
@@ -466,6 +466,7 @@ Full function reference with examples can be found at [https://systeminformation
466
466
  | | [0].removable | X | | X | X | | serial |
467
467
  | | [0].protocol | X | | X | | | protocol (SATA, PCI-Express, ...) |
468
468
  | | [0].group | X | | | | | Raid group member (e.g. md1) |
469
+ | | [0].device | X | | X | X | | physical device mapped to (e.g. /dev/sda) |
469
470
  | si.disksIO(cb) | {...} | X | | X | | | current transfer stats |
470
471
  | | rIO | X | | X | | | read IOs on all mounted drives |
471
472
  | | wIO | X | | X | | | write IOs on all mounted drives |
package/lib/filesystem.js CHANGED
@@ -293,7 +293,9 @@ function parseDevices(lines) {
293
293
  model: '',
294
294
  serial: '',
295
295
  removable: false,
296
- protocol: ''
296
+ protocol: '',
297
+ group: '',
298
+ device: ''
297
299
  };
298
300
  }
299
301
  parts[0] = parts[0].trim().toUpperCase().replace(/ +/g, '');
@@ -367,7 +369,7 @@ function decodeMdabmData(lines) {
367
369
  };
368
370
  }
369
371
 
370
- function raidMatchLunix(data) {
372
+ function raidMatchLinux(data) {
371
373
  // for all block devices of type "raid%"
372
374
  let result = data;
373
375
  try {
@@ -391,6 +393,105 @@ function raidMatchLunix(data) {
391
393
  return result;
392
394
  }
393
395
 
396
+ function getDevicesLinux(data) {
397
+ const result = [];
398
+ data.forEach(element => {
399
+ if (element.type.startsWith('disk')) {
400
+ result.push(element.name);
401
+ }
402
+ });
403
+ return result;
404
+ }
405
+
406
+ function matchDevicesLinux(data) {
407
+ let result = data;
408
+ try {
409
+ const devices = getDevicesLinux(data);
410
+ result = result.map(blockdevice => {
411
+ if (blockdevice.type.startsWith('part') || blockdevice.type.startsWith('disk')) {
412
+ devices.forEach(element => {
413
+ if (blockdevice.name.startsWith(element)) {
414
+ blockdevice.device = '/dev/' + element;
415
+ }
416
+ });
417
+ }
418
+ return blockdevice;
419
+ });
420
+ } catch (e) {
421
+ util.noop();
422
+ }
423
+ return result;
424
+ }
425
+
426
+ function getDevicesMac(data) {
427
+ const result = [];
428
+ data.forEach(element => {
429
+ if (element.type.startsWith('disk')) {
430
+ result.push({ name: element.name, model: element.model, device: element.name });
431
+ }
432
+ if (element.type.startsWith('virtual')) {
433
+ let device = '';
434
+ result.forEach(e => {
435
+ if (e.model === element.model) {
436
+ device = e.device;
437
+ }
438
+ });
439
+ if (device) {
440
+ result.push({ name: element.name, model: element.model, device });
441
+ }
442
+ }
443
+ });
444
+ return result;
445
+ }
446
+
447
+ function matchDevicesMac(data) {
448
+ let result = data;
449
+ try {
450
+ const devices = getDevicesMac(data);
451
+ result = result.map(blockdevice => {
452
+ if (blockdevice.type.startsWith('part') || blockdevice.type.startsWith('disk') || blockdevice.type.startsWith('virtual')) {
453
+ devices.forEach(element => {
454
+ if (blockdevice.name.startsWith(element.name)) {
455
+ blockdevice.device = element.device;
456
+ }
457
+ });
458
+ }
459
+ return blockdevice;
460
+ });
461
+ } catch (e) {
462
+ util.noop();
463
+ }
464
+ return result;
465
+ }
466
+
467
+ function getDevicesWin(diskDrives) {
468
+ const result = [];
469
+ diskDrives.forEach(element => {
470
+ const lines = element.split('\r\n');
471
+ const device = util.getValue(lines, 'DeviceID', ':');
472
+ let partitions = element.split('@{DeviceID=');
473
+ if (partitions.length > 1) {
474
+ partitions = partitions.slice(1);
475
+ partitions.forEach(partition => {
476
+ result.push({ name: partition.split(';')[0].toUpperCase(), device });
477
+ });
478
+ }
479
+ });
480
+ return result;
481
+ }
482
+
483
+ function matchDevicesWin(data, diskDrives) {
484
+ const devices = getDevicesWin(diskDrives);
485
+ data.map(element => {
486
+ const filteresDevices = devices.filter((e) => { return e.name === element.name.toUpperCase(); });
487
+ if (filteresDevices.length > 0) {
488
+ element.device = filteresDevices[0].device;
489
+ }
490
+ return element;
491
+ });
492
+ return data;
493
+ }
494
+
394
495
  function blkStdoutToObject(stdout) {
395
496
  return stdout.toString()
396
497
  .replace(/NAME=/g, '{"name":')
@@ -423,7 +524,8 @@ function blockDevices(callback) {
423
524
  if (!error) {
424
525
  let lines = blkStdoutToObject(stdout).split('\n');
425
526
  data = parseBlk(lines);
426
- data = raidMatchLunix(data);
527
+ data = raidMatchLinux(data);
528
+ data = matchDevicesLinux(data);
427
529
  if (callback) {
428
530
  callback(data);
429
531
  }
@@ -433,7 +535,7 @@ function blockDevices(callback) {
433
535
  if (!error) {
434
536
  let lines = blkStdoutToObject(stdout).split('\n');
435
537
  data = parseBlk(lines);
436
- data = raidMatchLunix(data);
538
+ data = raidMatchLinux(data);
437
539
  }
438
540
  if (callback) {
439
541
  callback(data);
@@ -449,6 +551,7 @@ function blockDevices(callback) {
449
551
  let lines = stdout.toString().split('\n');
450
552
  // parse lines into temp array of devices
451
553
  data = parseDevices(lines);
554
+ data = matchDevicesMac(data);
452
555
  }
453
556
  if (callback) {
454
557
  callback(data);
@@ -465,31 +568,39 @@ function blockDevices(callback) {
465
568
  try {
466
569
  // util.wmic('logicaldisk get Caption,Description,DeviceID,DriveType,FileSystem,FreeSpace,Name,Size,VolumeName,VolumeSerialNumber /value').then((stdout, error) => {
467
570
  // util.powerShell('Get-CimInstance Win32_logicaldisk | select Caption,DriveType,Name,FileSystem,Size,VolumeSerialNumber,VolumeName | fl').then((stdout, error) => {
468
- util.powerShell('Get-CimInstance -ClassName Win32_LogicalDisk | select Caption,DriveType,Name,FileSystem,Size,VolumeSerialNumber,VolumeName | fl').then((stdout, error) => {
469
- if (!error) {
470
- let devices = stdout.toString().split(/\n\s*\n/);
471
- devices.forEach(function (device) {
472
- let lines = device.split('\r\n');
473
- let drivetype = util.getValue(lines, 'drivetype', ':');
474
- if (drivetype) {
475
- data.push({
476
- name: util.getValue(lines, 'name', ':'),
477
- identifier: util.getValue(lines, 'caption', ':'),
478
- type: 'disk',
479
- fsType: util.getValue(lines, 'filesystem', ':').toLowerCase(),
480
- mount: util.getValue(lines, 'caption', ':'),
481
- size: util.getValue(lines, 'size', ':'),
482
- physical: (drivetype >= 0 && drivetype <= 6) ? drivetypes[drivetype] : drivetypes[0],
483
- uuid: util.getValue(lines, 'volumeserialnumber', ':'),
484
- label: util.getValue(lines, 'volumename', ':'),
485
- model: '',
486
- serial: util.getValue(lines, 'volumeserialnumber', ':'),
487
- removable: drivetype === '2',
488
- protocol: ''
489
- });
490
- }
491
- });
492
- }
571
+ const workload = [];
572
+ workload.push(util.powerShell('Get-CimInstance -ClassName Win32_LogicalDisk | select Caption,DriveType,Name,FileSystem,Size,VolumeSerialNumber,VolumeName | fl'));
573
+ workload.push(util.powerShell('Get-WmiObject -Class Win32_diskdrive | Select-Object -Property PNPDeviceId,DeviceID, Model, Size, @{L=\'Partitions\'; E={$_.GetRelated(\'Win32_DiskPartition\').GetRelated(\'Win32_LogicalDisk\') | Select-Object -Property DeviceID, VolumeName, Size, FreeSpace}} | fl'));
574
+ util.promiseAll(
575
+ workload
576
+ ).then((res) => {
577
+ let logicalDisks = res.results[0].toString().split(/\n\s*\n/);
578
+ let diskDrives = res.results[1].toString().split(/\n\s*\n/);
579
+ logicalDisks.forEach(function (device) {
580
+ let lines = device.split('\r\n');
581
+ let drivetype = util.getValue(lines, 'drivetype', ':');
582
+ if (drivetype) {
583
+ data.push({
584
+ name: util.getValue(lines, 'name', ':'),
585
+ identifier: util.getValue(lines, 'caption', ':'),
586
+ type: 'disk',
587
+ fsType: util.getValue(lines, 'filesystem', ':').toLowerCase(),
588
+ mount: util.getValue(lines, 'caption', ':'),
589
+ size: util.getValue(lines, 'size', ':'),
590
+ physical: (drivetype >= 0 && drivetype <= 6) ? drivetypes[drivetype] : drivetypes[0],
591
+ uuid: util.getValue(lines, 'volumeserialnumber', ':'),
592
+ label: util.getValue(lines, 'volumename', ':'),
593
+ model: '',
594
+ serial: util.getValue(lines, 'volumeserialnumber', ':'),
595
+ removable: drivetype === '2',
596
+ protocol: '',
597
+ group: '',
598
+ device: ''
599
+ });
600
+ }
601
+ });
602
+ // match devices
603
+ data = matchDevicesWin(data, diskDrives);
493
604
  if (callback) {
494
605
  callback(data);
495
606
  }
@@ -1232,7 +1343,7 @@ function diskLayout(callback) {
1232
1343
  if (_windows) {
1233
1344
  try {
1234
1345
  const workload = [];
1235
- workload.push(util.powerShell('Get-CimInstance Win32_DiskDrive | select Caption,Size,Status,PNPDeviceId,BytesPerSector,TotalCylinders,TotalHeads,TotalSectors,TotalTracks,TracksPerCylinder,SectorsPerTrack,FirmwareRevision,SerialNumber,InterfaceType | fl'));
1346
+ workload.push(util.powerShell('Get-CimInstance Win32_DiskDrive | select Caption,Size,Status,PNPDeviceId,DeviceId,BytesPerSector,TotalCylinders,TotalHeads,TotalSectors,TotalTracks,TracksPerCylinder,SectorsPerTrack,FirmwareRevision,SerialNumber,InterfaceType | fl'));
1236
1347
  workload.push(util.powerShell('Get-PhysicalDisk | select BusType,MediaType,FriendlyName,Model,SerialNumber,Size | fl'));
1237
1348
  if (util.smartMonToolsInstalled()) {
1238
1349
  try {
@@ -1256,7 +1367,7 @@ function diskLayout(callback) {
1256
1367
  const status = util.getValue(lines, 'Status', ':').trim().toLowerCase();
1257
1368
  if (size) {
1258
1369
  result.push({
1259
- device: util.getValue(lines, 'PNPDeviceId', ':'),
1370
+ device: util.getValue(lines, 'DeviceId', ':'), // changed from PNPDeviceId to DeviceID (be be able to match devices)
1260
1371
  type: device.indexOf('SSD') > -1 ? 'SSD' : 'HD', // just a starting point ... better: MSFT_PhysicalDisk - Media Type ... see below
1261
1372
  name: util.getValue(lines, 'Caption', ':'),
1262
1373
  vendor: getVendorFromModel(util.getValue(lines, 'Caption', ':', true).trim()),
package/lib/index.d.ts CHANGED
@@ -370,7 +370,7 @@ export namespace Systeminformation {
370
370
  serial: string;
371
371
  build: string;
372
372
  servicepack: string;
373
- uefi: boolean;
373
+ uefi: boolean | null;
374
374
  hypervizor?: boolean;
375
375
  remoteSession?: boolean;
376
376
  hypervisor?: boolean;
@@ -457,6 +457,7 @@ export namespace Systeminformation {
457
457
  removable: boolean;
458
458
  protocol: string;
459
459
  group?: string;
460
+ device?: string;
460
461
  }
461
462
 
462
463
  interface FsStatsData {
@@ -915,6 +916,27 @@ export namespace Systeminformation {
915
916
  memLayout: MemLayoutData[];
916
917
  diskLayout: DiskLayoutData[];
917
918
  }
919
+
920
+ interface DynamicData {
921
+ time: TimeData;
922
+ node: string;
923
+ v8: string;
924
+ cpuCurrentSpeed: CpuCurrentSpeedData;
925
+ users: UserData[];
926
+ processes: ProcessesData;
927
+ currentLoad: CurrentLoadData;
928
+ cpuTemperature: CpuTemperatureData;
929
+ networkStats: NetworkStatsData;
930
+ networkConnections: NetworkConnectionsData;
931
+ mem: MemData;
932
+ battery: BatteryData;
933
+ services: ServicesData;
934
+ fsSize: FsSizeData;
935
+ fsStats: FsStatsData;
936
+ disksIO: DisksIoData;
937
+ wifiNetworks: WifiNetworkData;
938
+ inetLatency: number;
939
+ }
918
940
  }
919
941
 
920
942
  export function version(): string;
@@ -988,8 +1010,8 @@ export function audio(cb?: (data: Systeminformation.AudioData[]) => any): Promis
988
1010
  export function bluetoothDevices(cb?: (data: Systeminformation.BluetoothDeviceData[]) => any): Promise<Systeminformation.BluetoothDeviceData[]>;
989
1011
 
990
1012
  export function getStaticData(cb?: (data: Systeminformation.StaticData) => any): Promise<Systeminformation.StaticData>;
991
- export function getDynamicData(srv?: string, iface?: string, cb?: (data: any) => any): Promise<any>;
992
- export function getAllData(srv?: string, iface?: string, cb?: (data: any) => any): Promise<any>;
1013
+ export function getDynamicData(srv?: string, iface?: string, cb?: (data: any) => any): Promise<ysteminformation.DynamicData>;
1014
+ export function getAllData(srv?: string, iface?: string, cb?: (data: any) => any): Promise<Systeminformation.StaticData & Systeminformation.DynamicData>;
993
1015
  export function get(valuesObject: any, cb?: (data: any) => any): Promise<any>;
994
1016
  export function observe(valuesObject: any, interval: number, cb?: (data: any) => any): number;
995
1017
 
package/lib/internet.js CHANGED
@@ -46,7 +46,7 @@ function inetChecksite(url, callback) {
46
46
  let urlSanitized = '';
47
47
  const s = util.sanitizeShellString(url, true);
48
48
  for (let i = 0; i <= util.mathMin(s.length, 2000); i++) {
49
- if (!s[i] !== undefined) {
49
+ if (s[i] !== undefined) {
50
50
  s[i].__proto__.toLowerCase = util.stringToLower;
51
51
  const sl = s[i].toLowerCase();
52
52
  if (sl && sl[0] && !sl[1] && sl[0].length === 1) {
package/lib/osinfo.js CHANGED
@@ -262,20 +262,22 @@ function osInfo(callback) {
262
262
  }
263
263
  if (_freebsd || _openbsd || _netbsd) {
264
264
 
265
- exec('sysctl kern.ostype kern.osrelease kern.osrevision kern.hostuuid machdep.bootmethod', function (error, stdout) {
265
+ exec('sysctl kern.ostype kern.osrelease kern.osrevision kern.hostuuid machdep.bootmethod kern.geom.confxml', function (error, stdout) {
266
266
  let lines = stdout.toString().split('\n');
267
267
  const distro = util.getValue(lines, 'kern.ostype');
268
268
  const logofile = util.getValue(lines, 'kern.ostype');
269
269
  const release = util.getValue(lines, 'kern.osrelease').split('-')[0];
270
270
  const serial = util.getValue(lines, 'kern.uuid');
271
- const uefi = util.getValue(lines, 'machdep.bootmethod').toLowerCase().indexOf('uefi') >= 0;
271
+ const bootmethod = util.getValue(lines, 'machdep.bootmethod');
272
+ const uefiConf = stdout.toString().indexOf('<type>efi</type>') >= 0;
273
+ const uefi = bootmethod ? bootmethod.toLowerCase().indexOf('uefi') >= 0 : (uefiConf ? uefiConf : null);
272
274
  result.distro = distro || result.distro;
273
275
  result.logofile = logofile || result.logofile;
274
276
  result.release = release || result.release;
275
277
  result.serial = serial || result.serial;
276
278
  result.codename = '';
277
279
  result.codepage = util.getCodepage();
278
- result.uefi = uefi || result.uefi;
280
+ result.uefi = uefi || null;
279
281
  if (callback) {
280
282
  callback(result);
281
283
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "systeminformation",
3
- "version": "5.14.3",
3
+ "version": "5.15.0",
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)",