added versions (kernel, ssl, node, npm, pm2, ...)
This commit is contained in:
parent
e1827fd78b
commit
d338e90e83
@ -42,6 +42,7 @@ si.cpu()
|
||||
|
||||
### Latest Activity
|
||||
|
||||
- Version 3.6.0: added versions (kernel, ssl, node, npm, pm2, ...).
|
||||
- Version 3.5.0: added graphics info (controller and display).
|
||||
- Version 3.4.0: rewritten currentLoad and CPU load for processes (linux). This is now much more accurate.
|
||||
- Version 3.3.0: added process list. Get full process list including details like cpu and mem usage, status, command, ...
|
||||
@ -69,6 +70,7 @@ Here all changes more detailed:
|
||||
|
||||
New Functions
|
||||
|
||||
- `versions`: returns object of versions - kernel, ssl, node, npm, ...(new in version 3.6)
|
||||
- `graphics`: returns arrays of graphics controllers and displays (new in version 3.5)
|
||||
- `networkInterfaceDefault`: returns default network interface (new in version 3.4)
|
||||
- `processes`: now returns also a process list with all process details (new in version 3.3)
|
||||
@ -188,6 +190,7 @@ This library is splitted in several sections:
|
||||
| - arch | X | X | same as os.arch() |
|
||||
| - hostname | X | X | same as os.hostname() |
|
||||
| - logofile | X | X | e.g. 'apple', 'debian', 'fedora', ... |
|
||||
| si.versions(cb) | X | X | Version information (kernel, ssl, node, ...) |
|
||||
| si.cpu(cb) | X | X | CPU information|
|
||||
| - manufacturer | X | X | e.g. 'Intel(R)' |
|
||||
| - brand | X | X | e.g. 'Core(TM)2 Duo' |
|
||||
@ -394,6 +397,7 @@ I am happy to discuss any comments and suggestions. Please feel free to contact
|
||||
|
||||
| Version | Date | Comment |
|
||||
| -------------- | -------------- | -------- |
|
||||
| 3.6.0 | 2016-09-14 | added versions (kernel, ssl, node, npm, pm2, ...) |
|
||||
| 3.5.1 | 2016-09-14 | bugfix graphics info |
|
||||
| 3.5.0 | 2016-09-14 | added graphics info (controller, display) |
|
||||
| 3.4.4 | 2016-09-02 | tiny fixes system.model, getDefaultNetworkInterface |
|
||||
|
||||
50
lib/index.js
50
lib/index.js
@ -81,6 +81,7 @@
|
||||
// --------------------------------
|
||||
//
|
||||
// version date comment
|
||||
// 3.6.0 2016-09-16 added versions (kernel, ssl, node, npm, pm2, ...)
|
||||
// 3.5.1 2016-09-14 bugfix graphics info
|
||||
// 3.5.0 2016-09-14 added graphics info (controller, display)
|
||||
// 3.4.4 2016-09-02 tiny fixes system.model, getDefaultNetworkInterface
|
||||
@ -435,6 +436,45 @@ function osInfo(callback) {
|
||||
|
||||
exports.osInfo = osInfo;
|
||||
|
||||
function versions(callback) {
|
||||
return new Promise((resolve, reject) => {
|
||||
process.nextTick(() => {
|
||||
if (_windows) {
|
||||
let error = new Error(NOT_SUPPORTED);
|
||||
if (callback) { callback(NOT_SUPPORTED) }
|
||||
reject(error);
|
||||
}
|
||||
|
||||
let result = {
|
||||
kernel: os.release(),
|
||||
node: process.versions.node,
|
||||
v8: process.versions.v8,
|
||||
npm: '',
|
||||
pm2: '',
|
||||
openssl: process.versions.openssl
|
||||
};
|
||||
let lines = [];
|
||||
exec("npm -v", function (error, stdout) {
|
||||
if (!error) {
|
||||
result.npm = stdout.toString().split('\n')[0];
|
||||
}
|
||||
exec("pm2 -v", function (error, stdout) {
|
||||
if (!error) {
|
||||
lines = stdout.toString().split('\n');
|
||||
if (lines.length >= 2) {
|
||||
result.pm2 = lines[lines.length-2];
|
||||
}
|
||||
}
|
||||
if (callback) { callback(result) }
|
||||
resolve(result);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
exports.versions = versions;
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// 4. CPU
|
||||
// ----------------------------------------------------------------------------------
|
||||
@ -816,7 +856,6 @@ function mem(callback) {
|
||||
|
||||
exports.mem = mem;
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// 6. Battery
|
||||
// ----------------------------------------------------------------------------------
|
||||
@ -1013,8 +1052,7 @@ function graphics(callback) {
|
||||
is_vga = true;
|
||||
let endpos = lines[i].search(/\[[0-9a-f]{4}:[0-9a-f]{4}]|$/);
|
||||
let parts = lines[i].substr(vgapos, endpos - vgapos).split(':');
|
||||
if (parts.length > 1)
|
||||
{
|
||||
if (parts.length > 1) {
|
||||
parts[1] = parts[1].trim();
|
||||
if (parts[1].toLowerCase().indexOf('corporation')) {
|
||||
currentController.vendor = parts[1].substr(0, parts[1].toLowerCase().indexOf('corporation') + 11).trim();
|
||||
@ -2164,6 +2202,7 @@ function processes(callback) {
|
||||
let guest_nice = (parts.length >= 11 ? parseInt(parts[10]) : 0);
|
||||
return user + nice + system + idle + iowait + irq + softirq + steal + guest + guest_nice;
|
||||
}
|
||||
|
||||
function parseProcPidStat(line, all) {
|
||||
let parts = line.replace(/ +/g, " ").split(' ');
|
||||
if (parts.length >= 17) {
|
||||
@ -2525,7 +2564,6 @@ function users(callback) {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -2640,6 +2678,7 @@ function dockerContainers(all, callback) {
|
||||
});
|
||||
return (filtered.length > 0);
|
||||
}
|
||||
|
||||
// fallback - if only callback is given
|
||||
if (isFunction(all) && !callback) {
|
||||
callback = all;
|
||||
@ -2932,6 +2971,8 @@ function getStaticData(callback) {
|
||||
data.system = res;
|
||||
osInfo().then(res => {
|
||||
data.os = res;
|
||||
versions().then(res => {
|
||||
data.versions = res;
|
||||
cpu().then(res => {
|
||||
data.cpu = res;
|
||||
graphics().then(res => {
|
||||
@ -2945,6 +2986,7 @@ function getStaticData(callback) {
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user