systeminformation 5.12.15 → 5.13.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
@@ -112,6 +112,7 @@ si.cpu()
112
112
 
113
113
  (last 7 major and minor version releases)
114
114
 
115
+ - Version 5.13.0: `networkConnections()` added process name (mac OS)
115
116
  - Version 5.12.0: `cpu()` added performance and efficiency cores
116
117
  - Version 5.11.0: `networkInterfaces()` added default property and default parameter
117
118
  - Version 5.10.0: basic `android` support
@@ -595,7 +596,7 @@ Full function reference with examples can be found at [https://systeminformation
595
596
  | | [0].peerPort | X | X | X | X | | peer port |
596
597
  | | [0].state | X | X | X | X | | like ESTABLISHED, TIME_WAIT, ... |
597
598
  | | [0].pid | X | X | X | X | | process ID |
598
- | | [0].process | X | X | | | | process name |
599
+ | | [0].process | X | X | X | | | process name |
599
600
  | si.inetChecksite(url, cb) | {...} | X | X | X | X | X | response-time (ms) to fetch given URL |
600
601
  | | url | X | X | X | X | X | given url |
601
602
  | | ok | X | X | X | X | X | status code OK (2xx, 3xx) |
package/lib/cpu.js CHANGED
@@ -1088,7 +1088,7 @@ function cpuTemperature(callback) {
1088
1088
  }
1089
1089
  } else if (section === 'pch') {
1090
1090
  // chipset temp
1091
- if (firstPart.indexOf('TEMP') !== -1) {
1091
+ if (firstPart.indexOf('TEMP') !== -1 && !result.chipset) {
1092
1092
  result.chipset = parseFloat(temps);
1093
1093
  }
1094
1094
  }
package/lib/filesystem.js CHANGED
@@ -339,7 +339,7 @@ function parseBlk(lines) {
339
339
  'physical': (disk.type === 'disk' ? (disk.rota === '0' ? 'SSD' : 'HDD') : (disk.type === 'rom' ? 'CD/DVD' : '')),
340
340
  'uuid': disk.uuid,
341
341
  'label': disk.label,
342
- 'model': disk.model,
342
+ 'model': (disk.model || '').trim(),
343
343
  'serial': disk.serial,
344
344
  'removable': disk.rm === '1',
345
345
  'protocol': disk.tran,
package/lib/network.js CHANGED
@@ -1369,6 +1369,22 @@ exports.networkStats = networkStats;
1369
1369
  // --------------------------
1370
1370
  // NET - connections (sockets)
1371
1371
 
1372
+ function getProcessName(processes, pid) {
1373
+ let cmd = '';
1374
+ processes.forEach(line => {
1375
+ const parts = line.split(' ');
1376
+ const id = parseInt(parts[0], 10) || -1;
1377
+ if (id === pid) {
1378
+ parts.shift();
1379
+ cmd = parts.join(' ').split(':')[0];
1380
+ }
1381
+ });
1382
+ cmd = cmd.split(' -')[0];
1383
+ // return cmd;
1384
+ const cmdParts = cmd.split('/');
1385
+ return cmdParts[cmdParts.length - 1];
1386
+ }
1387
+
1372
1388
  function networkConnections(callback) {
1373
1389
 
1374
1390
  return new Promise((resolve) => {
@@ -1411,7 +1427,7 @@ function networkConnections(callback) {
1411
1427
  peerPort: peerport,
1412
1428
  state: connstate,
1413
1429
  pid: proc[0] && proc[0] !== '-' ? parseInt(proc[0], 10) : null,
1414
- process: proc[1] ? proc[1].split(' ')[0] : ''
1430
+ process: proc[1] ? proc[1].split(' ')[0].split(':')[0] : ''
1415
1431
  });
1416
1432
  }
1417
1433
  }
@@ -1453,7 +1469,7 @@ function networkConnections(callback) {
1453
1469
  if (line.length >= 7 && line[6].indexOf('users:') > -1) {
1454
1470
  let proc = line[6].replace('users:(("', '').replace(/"/g, '').split(',');
1455
1471
  if (proc.length > 2) {
1456
- process = proc[0].split(' ')[0];
1472
+ process = proc[0].split(' ')[0].split(':')[0];
1457
1473
  pid = parseInt(proc[1], 10);
1458
1474
  }
1459
1475
  }
@@ -1486,49 +1502,53 @@ function networkConnections(callback) {
1486
1502
  const states = 'ESTABLISHED|SYN_SENT|SYN_RECV|FIN_WAIT1|FIN_WAIT2|TIME_WAIT|CLOSE|CLOSE_WAIT|LAST_ACK|LISTEN|CLOSING|UNKNOWN';
1487
1503
  exec(cmd, { maxBuffer: 1024 * 20000 }, function (error, stdout) {
1488
1504
  if (!error) {
1505
+ exec('ps -axo pid,command', { maxBuffer: 1024 * 20000 }, function (err2, stdout2) {
1506
+ let processes = stdout2.toString().split('\n');
1507
+ processes = processes.map((line => { return line.trim().replace(/ +/g, ' '); }));
1508
+ let lines = stdout.toString().split('\n');
1489
1509
 
1490
- let lines = stdout.toString().split('\n');
1491
-
1492
- lines.forEach(function (line) {
1493
- line = line.replace(/ +/g, ' ').split(' ');
1494
- if (line.length >= 8) {
1495
- let localip = line[3];
1496
- let localport = '';
1497
- let localaddress = line[3].split('.');
1498
- if (localaddress.length > 1) {
1499
- localport = localaddress[localaddress.length - 1];
1500
- localaddress.pop();
1501
- localip = localaddress.join('.');
1502
- }
1503
- let peerip = line[4];
1504
- let peerport = '';
1505
- let peeraddress = line[4].split('.');
1506
- if (peeraddress.length > 1) {
1507
- peerport = peeraddress[peeraddress.length - 1];
1508
- peeraddress.pop();
1509
- peerip = peeraddress.join('.');
1510
- }
1511
- const hasState = states.indexOf(line[5]) >= 0;
1512
- let connstate = hasState ? line[5] : 'UNKNOWN';
1513
- let pid = parseInt(line[8 + (hasState ? 0 : -1)], 10);
1514
- if (connstate) {
1515
- result.push({
1516
- protocol: line[0],
1517
- localAddress: localip,
1518
- localPort: localport,
1519
- peerAddress: peerip,
1520
- peerPort: peerport,
1521
- state: connstate,
1522
- pid: pid,
1523
- process: ''
1524
- });
1510
+ lines.forEach(function (line) {
1511
+ line = line.replace(/ +/g, ' ').split(' ');
1512
+ if (line.length >= 8) {
1513
+ let localip = line[3];
1514
+ let localport = '';
1515
+ let localaddress = line[3].split('.');
1516
+ if (localaddress.length > 1) {
1517
+ localport = localaddress[localaddress.length - 1];
1518
+ localaddress.pop();
1519
+ localip = localaddress.join('.');
1520
+ }
1521
+ let peerip = line[4];
1522
+ let peerport = '';
1523
+ let peeraddress = line[4].split('.');
1524
+ if (peeraddress.length > 1) {
1525
+ peerport = peeraddress[peeraddress.length - 1];
1526
+ peeraddress.pop();
1527
+ peerip = peeraddress.join('.');
1528
+ }
1529
+ const hasState = states.indexOf(line[5]) >= 0;
1530
+ let connstate = hasState ? line[5] : 'UNKNOWN';
1531
+ let pid = parseInt(line[8 + (hasState ? 0 : -1)], 10);
1532
+ if (connstate) {
1533
+ result.push({
1534
+ protocol: line[0],
1535
+ localAddress: localip,
1536
+ localPort: localport,
1537
+ peerAddress: peerip,
1538
+ peerPort: peerport,
1539
+ state: connstate,
1540
+ pid: pid,
1541
+ process: getProcessName(processes, pid)
1542
+ });
1543
+ }
1525
1544
  }
1545
+ });
1546
+ if (callback) {
1547
+ callback(result);
1526
1548
  }
1549
+ resolve(result);
1527
1550
  });
1528
- if (callback) {
1529
- callback(result);
1530
- }
1531
- resolve(result);
1551
+
1532
1552
  }
1533
1553
  });
1534
1554
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "systeminformation",
3
- "version": "5.12.15",
3
+ "version": "5.13.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)",