diff --git a/CHANGELOG.md b/CHANGELOG.md index 0522d16..4d55682 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,6 +56,7 @@ We had to make **several interface changes** to keep systeminformation as consis - `graphics()`: extended properties (mac OS) - `graphics()`: extended nvidia-smi parsing - `networkInterfaces()`: type detection improved (win - wireless) +- `networkConnections()`: added process name (mac OS) - `memLayout()`: extended manufacturer list (decoding) - `memLayout()`: added ECC flag - `osInfo()`: better fqdn (win) @@ -80,6 +81,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page. | Version | Date | Comment | | ------- | ---------- | --------------------------------------------------------------------------------------------------- | +| 5.13.0 | 2022-11-17 | `networkConnections()` addedd process name (mac OS) | | 5.12.15 | 2022-11-16 | `networkConnections()` adapted parsing to reflect also UDP (mac OS) | | 5.12.14 | 2022-11-11 | restored `powershell` compatibility for version 7.3 (windows) | | 5.12.13 | 2022-11-06 | updated docs | diff --git a/README.md b/README.md index e6fb5cc..e82017b 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,7 @@ si.cpu() (last 7 major and minor version releases) +- Version 5.13.0: `networkConnections()` added process name (mac OS) - Version 5.12.0: `cpu()` added performance and efficiency cores - Version 5.11.0: `networkInterfaces()` added default property and default parameter - Version 5.10.0: basic `android` support @@ -595,7 +596,7 @@ Full function reference with examples can be found at [https://systeminformation | | [0].peerPort | X | X | X | X | | peer port | | | [0].state | X | X | X | X | | like ESTABLISHED, TIME_WAIT, ... | | | [0].pid | X | X | X | X | | process ID | -| | [0].process | X | X | | | | process name | +| | [0].process | X | X | X | | | process name | | si.inetChecksite(url, cb) | {...} | X | X | X | X | X | response-time (ms) to fetch given URL | | | url | X | X | X | X | X | given url | | | ok | X | X | X | X | X | status code OK (2xx, 3xx) | diff --git a/docs/history.html b/docs/history.html index 243ea19..3099768 100644 --- a/docs/history.html +++ b/docs/history.html @@ -57,6 +57,11 @@ + + 5.13.0 + 2022-11-17 + networkConnections() added process name (mac OS) + 5.12.15 2022-11-16 diff --git a/docs/index.html b/docs/index.html index 73a30fc..1ec3300 100644 --- a/docs/index.html +++ b/docs/index.html @@ -170,7 +170,7 @@
systeminformation
 
-
New Version: 5.12.15
+
New Version: 5.13.0
diff --git a/docs/network.html b/docs/network.html index d221d21..258a921 100644 --- a/docs/network.html +++ b/docs/network.html @@ -643,7 +643,7 @@ setInterval(function() { [0].process X X - + X process name diff --git a/lib/cpu.js b/lib/cpu.js index 9326b82..83dba28 100644 --- a/lib/cpu.js +++ b/lib/cpu.js @@ -1088,7 +1088,7 @@ function cpuTemperature(callback) { } } else if (section === 'pch') { // chipset temp - if (firstPart.indexOf('TEMP') !== -1) { + if (firstPart.indexOf('TEMP') !== -1 && !result.chipset) { result.chipset = parseFloat(temps); } } diff --git a/lib/filesystem.js b/lib/filesystem.js index 173c3f0..04dccaa 100644 --- a/lib/filesystem.js +++ b/lib/filesystem.js @@ -339,7 +339,7 @@ function parseBlk(lines) { 'physical': (disk.type === 'disk' ? (disk.rota === '0' ? 'SSD' : 'HDD') : (disk.type === 'rom' ? 'CD/DVD' : '')), 'uuid': disk.uuid, 'label': disk.label, - 'model': disk.model, + 'model': (disk.model || '').trim(), 'serial': disk.serial, 'removable': disk.rm === '1', 'protocol': disk.tran, diff --git a/lib/network.js b/lib/network.js index e682998..e0d2d2c 100644 --- a/lib/network.js +++ b/lib/network.js @@ -1369,6 +1369,22 @@ exports.networkStats = networkStats; // -------------------------- // NET - connections (sockets) +function getProcessName(processes, pid) { + let cmd = ''; + processes.forEach(line => { + const parts = line.split(' '); + const id = parseInt(parts[0], 10) || -1; + if (id === pid) { + parts.shift(); + cmd = parts.join(' ').split(':')[0]; + } + }); + cmd = cmd.split(' -')[0]; + // return cmd; + const cmdParts = cmd.split('/'); + return cmdParts[cmdParts.length - 1]; +} + function networkConnections(callback) { return new Promise((resolve) => { @@ -1411,7 +1427,7 @@ function networkConnections(callback) { peerPort: peerport, state: connstate, pid: proc[0] && proc[0] !== '-' ? parseInt(proc[0], 10) : null, - process: proc[1] ? proc[1].split(' ')[0] : '' + process: proc[1] ? proc[1].split(' ')[0].split(':')[0] : '' }); } } @@ -1453,7 +1469,7 @@ function networkConnections(callback) { if (line.length >= 7 && line[6].indexOf('users:') > -1) { let proc = line[6].replace('users:(("', '').replace(/"/g, '').split(','); if (proc.length > 2) { - process = proc[0].split(' ')[0]; + process = proc[0].split(' ')[0].split(':')[0]; pid = parseInt(proc[1], 10); } } @@ -1486,49 +1502,53 @@ function networkConnections(callback) { const states = 'ESTABLISHED|SYN_SENT|SYN_RECV|FIN_WAIT1|FIN_WAIT2|TIME_WAIT|CLOSE|CLOSE_WAIT|LAST_ACK|LISTEN|CLOSING|UNKNOWN'; exec(cmd, { maxBuffer: 1024 * 20000 }, function (error, stdout) { if (!error) { + exec('ps -axo pid,command', { maxBuffer: 1024 * 20000 }, function (err2, stdout2) { + let processes = stdout2.toString().split('\n'); + processes = processes.map((line => { return line.trim().replace(/ +/g, ' '); })); + let lines = stdout.toString().split('\n'); - let lines = stdout.toString().split('\n'); - - lines.forEach(function (line) { - line = line.replace(/ +/g, ' ').split(' '); - if (line.length >= 8) { - let localip = line[3]; - let localport = ''; - let localaddress = line[3].split('.'); - if (localaddress.length > 1) { - localport = localaddress[localaddress.length - 1]; - localaddress.pop(); - localip = localaddress.join('.'); - } - let peerip = line[4]; - let peerport = ''; - let peeraddress = line[4].split('.'); - if (peeraddress.length > 1) { - peerport = peeraddress[peeraddress.length - 1]; - peeraddress.pop(); - peerip = peeraddress.join('.'); - } - const hasState = states.indexOf(line[5]) >= 0; - let connstate = hasState ? line[5] : 'UNKNOWN'; - let pid = parseInt(line[8 + (hasState ? 0 : -1)], 10); - if (connstate) { - result.push({ - protocol: line[0], - localAddress: localip, - localPort: localport, - peerAddress: peerip, - peerPort: peerport, - state: connstate, - pid: pid, - process: '' - }); + lines.forEach(function (line) { + line = line.replace(/ +/g, ' ').split(' '); + if (line.length >= 8) { + let localip = line[3]; + let localport = ''; + let localaddress = line[3].split('.'); + if (localaddress.length > 1) { + localport = localaddress[localaddress.length - 1]; + localaddress.pop(); + localip = localaddress.join('.'); + } + let peerip = line[4]; + let peerport = ''; + let peeraddress = line[4].split('.'); + if (peeraddress.length > 1) { + peerport = peeraddress[peeraddress.length - 1]; + peeraddress.pop(); + peerip = peeraddress.join('.'); + } + const hasState = states.indexOf(line[5]) >= 0; + let connstate = hasState ? line[5] : 'UNKNOWN'; + let pid = parseInt(line[8 + (hasState ? 0 : -1)], 10); + if (connstate) { + result.push({ + protocol: line[0], + localAddress: localip, + localPort: localport, + peerAddress: peerip, + peerPort: peerport, + state: connstate, + pid: pid, + process: getProcessName(processes, pid) + }); + } } + }); + if (callback) { + callback(result); } + resolve(result); }); - if (callback) { - callback(result); - } - resolve(result); + } }); }