systeminformation
Advanced tools
Comparing version 3.7.1 to 3.8.0
@@ -19,2 +19,3 @@ # Changelog | ||
- `dockerContainerProcesses`: returns processes for a specific docker container (new in version 3.8) | ||
- `versions`: returns object of versions - kernel, ssl, node, npm, ...(new in version 3.6) | ||
@@ -91,2 +92,3 @@ - `graphics`: returns arrays of graphics controllers and displays (new in version 3.5) | ||
| -------------- | -------------- | -------- | | ||
| 3.8.0 | 2016-11-04 | added dockerContainerProcesses | | ||
| 3.7.1 | 2016-11-03 | code refactoring | | ||
@@ -93,0 +95,0 @@ | 3.7.0 | 2016-11-02 | extended docker stats, and no longer relying on curl | |
@@ -207,3 +207,3 @@ 'use strict'; | ||
// -------------------------- | ||
// container Stats (for one container) | ||
// container stats (for one container) | ||
@@ -290,2 +290,81 @@ function dockerContainerStats(containerID, callback) { | ||
// -------------------------- | ||
// container processes (for one container) | ||
function dockerContainerProcesses(containerID, callback) { | ||
containerID = containerID || ''; | ||
var result = []; | ||
return new Promise((resolve, reject) => { | ||
process.nextTick(() => { | ||
if (_windows) { | ||
let error = new Error(NOT_SUPPORTED); | ||
if (callback) { callback(NOT_SUPPORTED) } | ||
reject(error); | ||
} | ||
if (containerID) { | ||
if (!_docker_socket) { | ||
_docker_socket = new DockerSocket(); | ||
} | ||
_docker_socket.getProcesses(containerID, data => { | ||
/** | ||
* @namespace | ||
* @property {Array} Titles | ||
* @property {Array} Processes | ||
**/ | ||
try { | ||
if (data && data.Titles && data.Processes) { | ||
let titles = data.Titles.map(function(value) { | ||
return value.toUpperCase(); | ||
}); | ||
var pos_pid = titles.indexOf('PID'); | ||
var pos_ppid = titles.indexOf('PPID'); | ||
var pos_pgid = titles.indexOf('PGID'); | ||
var pos_vsz = titles.indexOf('VSZ'); | ||
var pos_time = titles.indexOf('TIME'); | ||
var pos_elapsed = titles.indexOf('ELAPSED'); | ||
var pos_ni = titles.indexOf('NI'); | ||
var pos_ruser = titles.indexOf('RUSER'); | ||
var pos_user = titles.indexOf('USER'); | ||
var pos_rgroup = titles.indexOf('RGROUP'); | ||
var pos_group = titles.indexOf('GROUP'); | ||
var pos_stat = titles.indexOf('STAT'); | ||
var pos_rss = titles.indexOf('RSS'); | ||
var pos_command = titles.indexOf('COMMAND'); | ||
data.Processes.forEach(process => { | ||
result.push({ | ||
pid_host: (pos_pid >= 0 ? process[pos_pid] : ''), | ||
ppid: (pos_ppid >= 0 ? process[pos_ppid] : ''), | ||
pgid: (pos_pgid >= 0 ? process[pos_pgid] : ''), | ||
user: (pos_user >= 0 ? process[pos_user] : ''), | ||
ruser: (pos_ruser >= 0 ? process[pos_ruser] : ''), | ||
group: (pos_group >= 0 ? process[pos_group] : ''), | ||
rgroup: (pos_rgroup >= 0 ? process[pos_rgroup] : ''), | ||
stat: (pos_stat >= 0 ? process[pos_stat] : ''), | ||
time: (pos_time >= 0 ? process[pos_time] : ''), | ||
elapsed: (pos_elapsed >= 0 ? process[pos_elapsed] : ''), | ||
nice: (pos_ni >= 0 ? process[pos_ni] : ''), | ||
rss: (pos_rss >= 0 ? process[pos_rss] : ''), | ||
vsz: (pos_vsz >= 0 ? process[pos_vsz] : ''), | ||
command: (pos_command >= 0 ? process[pos_command] : '') | ||
}) | ||
}) | ||
} | ||
} catch (err) { | ||
} | ||
if (callback) { callback(result) } | ||
resolve(result); | ||
}); | ||
} else { | ||
if (callback) { callback(result) } | ||
resolve(result); | ||
} | ||
}); | ||
}); | ||
} | ||
exports.dockerContainerProcesses = dockerContainerProcesses; | ||
function dockerAll(callback) { | ||
@@ -317,8 +396,12 @@ return new Promise((resolve, reject) => { | ||
dockerContainerProcesses(element.id).then(processes => { | ||
element.processes = processes; | ||
l -= 1; | ||
if (l == 0) { | ||
if (callback) { callback(result) } | ||
resolve(result); | ||
} | ||
}); | ||
// all done?? | ||
l -= 1; | ||
if (l == 0) { | ||
if (callback) { callback(result) } | ||
resolve(result); | ||
} | ||
}) | ||
@@ -325,0 +408,0 @@ }) |
@@ -84,2 +84,3 @@ 'use strict'; | ||
// version date comment | ||
// 3.8.0 2016-11-04 added dockerContainerProcesses | ||
// 3.7.1 2016-11-03 code refactoring | ||
@@ -418,2 +419,3 @@ // 3.7.0 2016-11-02 extended docker stats, and no longer relying on curl (version conflicts) | ||
exports.dockerContainerStats = docker.dockerContainerStats; | ||
exports.dockerContainerProcesses = docker.dockerContainerProcesses; | ||
exports.dockerAll = docker.dockerAll; | ||
@@ -420,0 +422,0 @@ |
{ | ||
"name": "systeminformation", | ||
"version": "3.7.1", | ||
"version": "3.8.0", | ||
"description": "Simple system and OS information library", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -45,2 +45,3 @@ # systeminformation | ||
- Version 3.8.0: added dockerContainerProcesses (docker process inside container). | ||
- Version 3.7.0: extended docker stats. | ||
@@ -264,3 +265,18 @@ - Version 3.6.0: added versions (kernel, ssl, node, npm, pm2, ...). | ||
| - networks | X | X | detailed network stats per interface | | ||
| si.dockerAll(cb) | X | X | list of all containers including their stats<br>in one single array | | ||
| si.dockerContainerProcesses(id, cb) | X | X | array of processes inside a container | | ||
| - [0].pid_host | X | X | process ID (host) | | ||
| - [0].ppid | X | X | parent process ID | | ||
| - [0].pgid | X | X | process group ID | | ||
| - [0].user | X | X | effective user name | | ||
| - [0].ruser | X | X | real user name | | ||
| - [0].group | X | X | effective group name | | ||
| - [0].rgroup | X | X | real group name | | ||
| - [0].stat | X | X | process state | | ||
| - [0].time | X | X | accumulated CPU time | | ||
| - [0].elapsed | X | X | elapsed running time | | ||
| - [0].nice | X | X | nice value | | ||
| - [0].rss | X | X | resident set size | | ||
| - [0].vsz | X | X | virtual size in Kbytes | | ||
| - [0].command | X | X | command and arguments | | ||
| si.dockerAll(cb) | X | X | list of all containers including their stats<br>and processes in one single array | | ||
| si.getStaticData(cb) | X | X | all static data at once | | ||
@@ -267,0 +283,0 @@ | si.getDynamicData(srv,iface,cb) | X | X | all dynamic data at once | |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
154834
3302
415
13