systeminformation 5.14.4 → 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 +1 -0
- package/lib/filesystem.js +142 -31
- package/lib/index.d.ts +24 -2
- package/package.json +1 -1
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
|
|
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 =
|
|
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 =
|
|
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
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
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, '
|
|
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
|
@@ -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<
|
|
992
|
-
export function getAllData(srv?: string, iface?: string, cb?: (data: any) => any): Promise<
|
|
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "systeminformation",
|
|
3
|
-
"version": "5.
|
|
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)",
|