processes() added process params and path
This commit is contained in:
parent
cdcc4bc3fd
commit
9067e342a9
@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page.
|
||||
|
||||
| Version | Date | Comment |
|
||||
| -------------- | -------------- | -------- |
|
||||
| 4.14.0 | 2019-07-03 | `processes()` added process path and params |
|
||||
| 4.13.2 | 2019-07-02 | `versions()` fix getting all versions |
|
||||
| 4.13.1 | 2019-07-01 | `versions()` gcc fix macos |
|
||||
| 4.13.0 | 2019-07-01 | `networkConnections()` added PID and process |
|
||||
|
||||
@ -84,13 +84,13 @@ si.cpu()
|
||||
|
||||
(last 7 major and minor version releases)
|
||||
|
||||
- Version 4.14.0: `processes()` added process path and params
|
||||
- Version 4.13.0: `networkConnections()` added PID, process
|
||||
- Version 4.12.0: `networkInterfaces()` added property virtual
|
||||
- Version 4.11.0: `wifiNetworks()` added available wifi networks
|
||||
- Version 4.10.0: `graphics()` added windows multiple display support, added display size, connection, ...
|
||||
- Version 4.9.0: `graphics()` added vendor, refresh rate, current resolution
|
||||
- Version 4.8.0: added `vboxInfo()` detailed virtual box info
|
||||
- Version 4.7.0: partial NetBSD support
|
||||
- ...
|
||||
|
||||
You can find all changes here: [detailed changelog][changelog-url]
|
||||
@ -333,7 +333,8 @@ I also created a nice little command line tool called [mmon][mmon-github-url] (
|
||||
| | ...[0].tty | X | X | X | | X | tty from which process was started |
|
||||
| | ...[0].user | X | X | X | | X | user who started process |
|
||||
| | ...[0].command | X | X | X | X | X | process starting command |
|
||||
| si.processLoad('apache2',cb) | {...} | X | X | X | X | | detailed information about given process |
|
||||
| | ...[0].params | X | X | X | | X | process params |
|
||||
| | ...[0].path | X | X | X | X | X | process path |
|
||||
| | proc | X | X | X | X | | process name |
|
||||
| | pid | X | X | X | X | | PID |
|
||||
| | pids | X | X | X | X | | additional pids |
|
||||
|
||||
@ -83,6 +83,11 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row">4.14.0</th>
|
||||
<td>2019-07-03</td>
|
||||
<td><span class="code">processes()</span> added process params and path</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">4.13.2</th>
|
||||
<td>2019-07-02</td>
|
||||
|
||||
@ -168,7 +168,7 @@
|
||||
<img class="logo" src="assets/logo.png">
|
||||
<div class="title">systeminformation</div>
|
||||
<div class="subtitle"><span id="typed"></span></div>
|
||||
<div class="version">Current Version: <span id="version">4.13.2</span></div>
|
||||
<div class="version">Current Version: <span id="version">4.14.0</span></div>
|
||||
<button class="btn btn-light" onclick="location.href='https://github.com/sebhildebrandt/systeminformation'">View on Github <i class=" fab fa-github"></i></button>
|
||||
</div>
|
||||
<div class="down">
|
||||
@ -191,7 +191,7 @@
|
||||
</div>
|
||||
<div class="row number-section">
|
||||
<div class="col-xl-4 col-lg-4 col-md-4 col-12">
|
||||
<div class="numbers">9,183</div>
|
||||
<div class="numbers">9,213</div>
|
||||
<div class="title">Lines of code</div>
|
||||
</div>
|
||||
<div class="col-xl-4 col-lg-4 col-md-4 col-12">
|
||||
|
||||
@ -405,6 +405,26 @@
|
||||
<td>X</td>
|
||||
<td>process starting command</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>...[0].params</td>
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
<td></td>
|
||||
<td>X</td>
|
||||
<td>process params</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>...[0].path</td>
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
<td>process path</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>si.processLoad('apache2',cb)</td>
|
||||
<td>{...}</td>
|
||||
|
||||
2
lib/index.d.ts
vendored
2
lib/index.d.ts
vendored
@ -420,6 +420,8 @@ export namespace Systeminformation {
|
||||
tty: string;
|
||||
user: string;
|
||||
command: string;
|
||||
params: string;
|
||||
path: string;
|
||||
}
|
||||
|
||||
interface ProcessesProcessLoadData {
|
||||
|
||||
@ -439,23 +439,23 @@ function processes(callback) {
|
||||
}
|
||||
|
||||
checkColumn(0);
|
||||
let pid = parseInt(line.substring(parsedhead[0].from + offset, parsedhead[0].to + offset2));
|
||||
const pid = parseInt(line.substring(parsedhead[0].from + offset, parsedhead[0].to + offset2));
|
||||
checkColumn(1);
|
||||
let ppid = parseInt(line.substring(parsedhead[1].from + offset, parsedhead[1].to + offset2));
|
||||
const ppid = parseInt(line.substring(parsedhead[1].from + offset, parsedhead[1].to + offset2));
|
||||
checkColumn(2);
|
||||
let pcpu = parseFloat(line.substring(parsedhead[2].from + offset, parsedhead[2].to + offset2).replace(/,/g, '.'));
|
||||
const pcpu = parseFloat(line.substring(parsedhead[2].from + offset, parsedhead[2].to + offset2).replace(/,/g, '.'));
|
||||
checkColumn(3);
|
||||
let pmem = parseFloat(line.substring(parsedhead[3].from + offset, parsedhead[3].to + offset2).replace(/,/g, '.'));
|
||||
const pmem = parseFloat(line.substring(parsedhead[3].from + offset, parsedhead[3].to + offset2).replace(/,/g, '.'));
|
||||
checkColumn(4);
|
||||
let priority = parseInt(line.substring(parsedhead[4].from + offset, parsedhead[4].to + offset2));
|
||||
const priority = parseInt(line.substring(parsedhead[4].from + offset, parsedhead[4].to + offset2));
|
||||
checkColumn(5);
|
||||
let vsz = parseInt(line.substring(parsedhead[5].from + offset, parsedhead[5].to + offset2));
|
||||
const vsz = parseInt(line.substring(parsedhead[5].from + offset, parsedhead[5].to + offset2));
|
||||
checkColumn(6);
|
||||
let rss = parseInt(line.substring(parsedhead[6].from + offset, parsedhead[6].to + offset2));
|
||||
const rss = parseInt(line.substring(parsedhead[6].from + offset, parsedhead[6].to + offset2));
|
||||
checkColumn(7);
|
||||
let nice = parseInt(line.substring(parsedhead[7].from + offset, parsedhead[7].to + offset2)) || 0;
|
||||
const nice = parseInt(line.substring(parsedhead[7].from + offset, parsedhead[7].to + offset2)) || 0;
|
||||
checkColumn(8);
|
||||
let started = parseTimeUnix(line.substring(parsedhead[8].from + offset, parsedhead[8].to + offset2).trim());
|
||||
const started = parseTimeUnix(line.substring(parsedhead[8].from + offset, parsedhead[8].to + offset2).trim());
|
||||
checkColumn(9);
|
||||
let state = line.substring(parsedhead[9].from + offset, parsedhead[9].to + offset2).trim();
|
||||
state = (state[0] === 'R' ? 'running' : (state[0] === 'S' ? 'sleeping' : (state[0] === 'T' ? 'stopped' : (state[0] === 'W' ? 'paging' : (state[0] === 'X' ? 'dead' : (state[0] === 'Z' ? 'zombie' : ((state[0] === 'D' || state[0] === 'U') ? 'blocked' : 'unknown')))))));
|
||||
@ -463,9 +463,34 @@ function processes(callback) {
|
||||
let tty = line.substring(parsedhead[10].from + offset, parsedhead[10].to + offset2).trim();
|
||||
if (tty === '?' || tty === '??') tty = '';
|
||||
checkColumn(11);
|
||||
let user = line.substring(parsedhead[11].from + offset, parsedhead[11].to + offset2).trim();
|
||||
const user = line.substring(parsedhead[11].from + offset, parsedhead[11].to + offset2).trim();
|
||||
checkColumn(12);
|
||||
let command = line.substring(parsedhead[12].from + offset, parsedhead[12].to + offset2).trim().replace(/\[/g, '').replace(/]/g, '');
|
||||
const fullcommand = line.substring(parsedhead[12].from + offset, parsedhead[12].to + offset2).trim().replace(/\[/g, '').replace(/]/g, '');
|
||||
let path = '';
|
||||
let command = '';
|
||||
let params = '';
|
||||
// try to figure out where parameter starts
|
||||
let firstParamPos = fullcommand.indexOf(' -')
|
||||
let firstParamPathPos = fullcommand.indexOf(' /')
|
||||
firstParamPos = (firstParamPos >= 0 ? firstParamPos : 10000);
|
||||
firstParamPathPos = (firstParamPathPos >= 0 ? firstParamPathPos : 10000);
|
||||
const firstPos = Math.min(firstParamPos, firstParamPathPos);
|
||||
let tmpCommand = fullcommand.substr(0, firstPos);
|
||||
const tmpParams = fullcommand.substr(firstPos);
|
||||
const lastSlashPos = tmpCommand.lastIndexOf('/');
|
||||
if (lastSlashPos >= 0) {
|
||||
path = tmpCommand.substr(0, lastSlashPos);
|
||||
tmpCommand = tmpCommand.substr(lastSlashPos + 1);
|
||||
}
|
||||
|
||||
if (firstPos === 10000) {
|
||||
const parts = tmpCommand.split(' ');
|
||||
command = parts.shift();
|
||||
params = (parts.join(' ') + ' ' + tmpParams).trim();
|
||||
} else {
|
||||
command = tmpCommand.trim();
|
||||
params = tmpParams.trim();
|
||||
}
|
||||
|
||||
return ({
|
||||
pid: pid,
|
||||
@ -483,7 +508,9 @@ function processes(callback) {
|
||||
state: state,
|
||||
tty: tty,
|
||||
user: user,
|
||||
command: command
|
||||
command: command,
|
||||
params: params,
|
||||
path: path
|
||||
});
|
||||
}
|
||||
|
||||
@ -564,7 +591,7 @@ function processes(callback) {
|
||||
if (_linux || _freebsd || _openbsd || _netbsd || _darwin || _sunos) {
|
||||
if (_linux) cmd = 'export LC_ALL=C; ps -axo pid:11,ppid:11,pcpu:6,pmem:6,pri:5,vsz:11,rss:11,ni:5,lstart:30,state:5,tty:15,user:20,command; unset LC_ALL';
|
||||
if (_freebsd || _openbsd || _netbsd) cmd = 'export LC_ALL=C; ps -axo pid,ppid,pcpu,pmem,pri,vsz,rss,ni,lstart,state,tty,user,command; unset LC_ALL';
|
||||
if (_darwin) cmd = 'export LC_ALL=C; ps -acxo pid,ppid,pcpu,pmem,pri,vsz,rss,nice,lstart,state,tty,user,command -r; unset LC_ALL';
|
||||
if (_darwin) cmd = 'export LC_ALL=C; ps -axo pid,ppid,pcpu,pmem,pri,vsz,rss,nice,lstart,state,tty,user,command -r; unset LC_ALL';
|
||||
if (_sunos) cmd = 'ps -Ao pid,ppid,pcpu,pmem,pri,vsz,rss,nice,stime,s,tty,user,comm';
|
||||
exec(cmd, { maxBuffer: 1024 * 20000 }, function (error, stdout) {
|
||||
if (!error) {
|
||||
@ -681,6 +708,7 @@ function processes(callback) {
|
||||
let statusValue = util.getValue(lines, 'ExecutionState', '=');
|
||||
let name = util.getValue(lines, 'Caption', '=', true);
|
||||
let commandLine = util.getValue(lines, 'CommandLine', '=', true);
|
||||
let commandPath = util.getValue(lines, 'ExecutablePath', '=', true);
|
||||
let utime = parseInt(util.getValue(lines, 'UserModeTime', '=', true), 10);
|
||||
let stime = parseInt(util.getValue(lines, 'KernelModeTime', '=', true), 10);
|
||||
let mem = parseInt(util.getValue(lines, 'WorkingSetSize', '=', true), 10);
|
||||
@ -715,7 +743,9 @@ function processes(callback) {
|
||||
state: (!statusValue ? _winStatusValues[0] : _winStatusValues[statusValue]),
|
||||
tty: '',
|
||||
user: '',
|
||||
command: commandLine || name
|
||||
command: commandLine || name,
|
||||
path: commandPath,
|
||||
params: ''
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user