updated docs USB, improved test scripts

This commit is contained in:
Sebastian Hildebrandt 2021-01-12 17:22:32 +01:00
parent bcf9d46f67
commit 52a097d56a
6 changed files with 133 additions and 97 deletions

View File

@ -453,7 +453,24 @@ I also created a nice little command line tool called [mmon][mmon-github-url] (m
| | tx_sec | X | | X | | | total bytes reads + written / second |
| | ms | X | | X | | | interval length (for per second values) |
#### 10. File System
#### 10. USB
| Function | Result object | Linux | BSD | Mac | Win | Sun | Comments |
| --------------- | ------------- | ----- | ------- | --- | --- | --- | -------- |
| si.usb(cb) | [{...}] | X | X | X | X | | get detected USB devices |
| | [0].bus | X | | | | | USB bus |
| | [0].deviceId | X | | | | | bus device id |
| | [0].id | X | | X | X | | internal id |
| | [0].name | X | | X | X | | name |
| | [0].type | X | | X | X | | name |
| | [0].removable | | | X | | | is removable |
| | [0].vendor | X | | X | | | vendor |
| | [0].manufacturer | X | | X | X | | manifacturer |
| | [0].maxPower | X | | | | | max power |
| | [0].default | X | | X | X | | is default printer |
| | [0].serialNumber | | | X | | | serial number |
#### 11. Printer
| Function | Result object | Linux | BSD | Mac | Win | Sun | Comments |
| --------------- | ------------- | ----- | ------- | --- | --- | --- | -------- |
@ -461,14 +478,14 @@ I also created a nice little command line tool called [mmon][mmon-github-url] (m
| | [0].id | X | | X | X | | internal id |
| | [0].name | X | | X | X | | name |
| | [0].model | X | | X | X | | model |
| | [0].uri | X | | X | X | | printer URI |
| | [0].uuid | X | | X | X | | printer UUID |
| | [0].uri | X | | X | | | printer URI |
| | [0].uuid | X | | | | | printer UUID |
| | [0].status | X | | X | X | | printer status (e.g. idle) |
| | [0].local | X | | X | X | | is local printer |
| | [0].default | X | | X | X | | is default printer |
| | [0].default | | | X | X | | is default printer |
| | [0].shared | X | | X | X | | is shared printer |
#### 11. Network related functions
#### 12. Network related functions
| Function | Result object | Linux | BSD | Mac | Win | Sun | Comments |
| --------------- | ------------- | ----- | ------- | --- | --- | --- | -------- |
@ -522,7 +539,7 @@ I also created a nice little command line tool called [mmon][mmon-github-url] (m
| | ms | X | X | X | X | X | response time in ms |
| si.inetLatency(host, cb) | : number | X | X | X | X | X | response-time (ms) to external resource<br>host parameter is optional (default 8.8.8.8)|
#### 12. Wifi networks
#### 13. Wifi networks
| Function | Result object | Linux | BSD | Mac | Win | Sun | Comments |
| --------------- | ------------- | ----- | ------- | --- | --- | --- | -------- |
| si.wifiNetworks(cb) | [{...}] | X | | X | X | | array of available wifi networks |
@ -537,7 +554,7 @@ I also created a nice little command line tool called [mmon][mmon-github-url] (m
| | [0].wpaFlags | X | | X | X | | array of WPA flags |
| | [0].rsnFlags | X | | | | | array of RDN flags |
#### 13. Docker
#### 14. Docker
| Function | Result object | Linux | BSD | Mac | Win | Sun | Comments |
| --------------- | ------------- | ----- | ------- | --- | --- | --- | -------- |
@ -635,7 +652,7 @@ I also created a nice little command line tool called [mmon][mmon-github-url] (m
| | [0].command | X | X | X | X | X | command and arguments |
| si.dockerAll(cb) | {...} | X | X | X | X | X | list of all containers including their stats<br>and processes in one single array |
#### 14. Virtual Box
#### 15. Virtual Box
| Function | Result object | Linux | BSD | Mac | Win | Sun | Comments |
| --------------- | ------------- | ----- | ------- | --- | --- | --- | -------- |
@ -677,7 +694,7 @@ I also created a nice little command line tool called [mmon][mmon-github-url] (m
| | [0].timeOffset | X | X | X | X | X | time Offset |
| | [0].RTC | X | X | X | X | X | RTC |
#### 14. "Get All / Observe" - functions
#### 16. "Get All / Observe" - functions
| Function | Result object | Linux | BSD | Mac | Win | Sun | Comments |
| --------------- | ------------- | ----- | ------- | --- | --- | --- | -------- |

View File

@ -112,7 +112,7 @@
<td>X</td>
<td></td>
<td>X</td>
<td>X</td>
<td></td>
<td></td>
<td>printer URI</td>
</tr>
@ -121,8 +121,8 @@
<td>[0].uuid</td>
<td>X</td>
<td></td>
<td>X</td>
<td>X</td>
<td></td>
<td></td>
<td></td>
<td>printer UUID</td>
</tr>
@ -149,7 +149,7 @@
<tr>
<td></td>
<td>[0].default</td>
<td>X</td>
<td></td>
<td></td>
<td>X</td>
<td>X</td>

View File

@ -81,8 +81,8 @@
<td>[0].bus</td>
<td>X</td>
<td></td>
<td>X</td>
<td>X</td>
<td></td>
<td></td>
<td></td>
<td>USB bus</td>
</tr>
@ -91,8 +91,8 @@
<td>[0].deviceId</td>
<td>X</td>
<td></td>
<td>X</td>
<td>X</td>
<td></td>
<td></td>
<td></td>
<td>Bus device ID</td>
</tr>
@ -129,10 +129,10 @@
<tr>
<td></td>
<td>[0].removable</td>
<td>X</td>
<td></td>
<td></td>
<td>X</td>
<td>X</td>
<td></td>
<td></td>
<td>is removable</td>
</tr>
@ -142,7 +142,7 @@
<td>X</td>
<td></td>
<td>X</td>
<td>X</td>
<td></td>
<td></td>
<td>vendor e.g. Realtek</td>
</tr>
@ -161,18 +161,18 @@
<td>[0].maxPower</td>
<td>X</td>
<td></td>
<td>X</td>
<td>X</td>
<td></td>
<td></td>
<td></td>
<td>max power e.g. 100mA</td>
</tr>
<tr>
<td></td>
<td>[0].serialNumber</td>
<td>X</td>
<td></td>
<td></td>
<td>X</td>
<td>X</td>
<td></td>
<td></td>
<td>serial number if available</td>
</tr>

View File

@ -271,3 +271,4 @@ function usb(callback) {
}
exports.usb = usb;

View File

@ -4,54 +4,54 @@ function test(f) {
return new Promise((resolve) => {
process.nextTick(() => {
// console.log(f);
if (f === 'a') { si.audio().then(data => resolve({ data, title: 'Audio' }) )}
else if (f === 'b') { si.bios().then(data => resolve({ data, title: 'BIOS' })) }
else if (f === 'B') { si.baseboard().then(data => resolve({ data, title: 'Baseboard' })) }
else if (f === 'C') { si.chassis().then(data => resolve({ data, title: 'Chassis' })) }
else if (f === 'c') { si.cpu().then(data => resolve({ data, title: 'CPU' })) }
else if (f === 'd') { si.diskLayout().then(data => resolve({ data, title: 'Disk Layout' })) }
else if (f === 'D') { si.disksIO().then(data => resolve({ data, title: 'Disks IO' })) }
else if (f === 'e') { si.blockDevices().then(data => resolve({ data, title: 'Block Devices' })) }
else if (f === 'E') { si.fsOpenFiles().then(data => resolve({ data, title: 'Open Files' })) }
else if (f === 'f') { si.fsSize().then(data => resolve({ data, title: 'File System' })) }
else if (f === 'F') { si.fsStats().then(data => resolve({ data, title: 'FS Stats' })) }
else if (f === 'g') { si.graphics().then(data => resolve({ data, title: 'Graphics' })) }
else if (f === 'h') { si.bluetooth().then(data => resolve({ data, title: 'Bluetooth' })) }
else if (f === 'i') { si.inetLatency().then(data => resolve({ data, title: 'Internet Latency' })) }
else if (f === 'I') { si.inetChecksite('www.plus-innovations.com').then(data => resolve({ data, title: 'Internet Check Site' })) }
else if (f === 'l') { si.cpuCurrentspeed().then(data => resolve({ data, title: 'CPU Current Speed' })) }
else if (f === 'L') { si.fullLoad().then(data => resolve({ data, title: 'CPU Full Load' })) }
else if (f === 'm') { si.mem().then(data => resolve({ data, title: 'Memory' })) }
else if (f === 'M') { si.memLayout().then(data => resolve({ data, title: 'Memory Layout' })) }
else if (f === 'o') { si.osInfo().then(data => resolve({ data, title: 'OS Info' })) }
else if (f === 'p') { si.processes().then(data => resolve({ data, title: 'Processes' })) }
else if (f === 'P') { si.processLoad('postgres').then(data => resolve({ data, title: 'Process Load' })) }
else if (f === 'r') { si.printer().then(data => resolve({ data, title: 'Printer' })) }
else if (f === 's') { si.services('apache2, postgres').then(data => resolve({ data, title: 'Services' })) }
else if (f === 'S') { si.shell().then(data => resolve({ data, title: 'Shell' })) }
if (f === 'a') { si.audio().then(data => { if (data !== null) { resolve({ data, title: 'Audio' }); } else { resolve('not_supported') } }) }
else if (f === 'b') { si.bios().then(data => { if (data !== null) { resolve({ data, title: 'BIOS' }); } else { resolve('not_supported') } }) }
else if (f === 'B') { si.baseboard().then(data => { if (data !== null) { resolve({ data, title: 'Baseboard' }); } else { resolve('not_supported') } }) }
else if (f === 'C') { si.chassis().then(data => { if (data !== null) { resolve({ data, title: 'Chassis' }); } else { resolve('not_supported') } }) }
else if (f === 'c') { si.cpu().then(data => { if (data !== null) { resolve({ data, title: 'CPU' }); } else { resolve('not_supported') } }) }
else if (f === 'd') { si.diskLayout().then(data => { if (data !== null) { resolve({ data, title: 'Disk Layout' }); } else { resolve('not_supported') } }) }
else if (f === 'D') { si.disksIO().then(data => { if (data !== null) { resolve({ data, title: 'Disks IO' }); } else { resolve('not_supported') } }) }
else if (f === 'e') { si.blockDevices().then(data => { if (data !== null) { resolve({ data, title: 'Block Devices' }); } else { resolve('not_supported') } }) }
else if (f === 'E') { si.fsOpenFiles().then(data => { if (data !== null) { resolve({ data, title: 'Open Files' }); } else { resolve('not_supported') } }) }
else if (f === 'f') { si.fsSize().then(data => { if (data !== null) { resolve({ data, title: 'File System' }); } else { resolve('not_supported') } }) }
else if (f === 'F') { si.fsStats().then(data => { if (data !== null) { resolve({ data, title: 'FS Stats' }); } else { resolve('not_supported') } }) }
else if (f === 'g') { si.graphics().then(data => { if (data !== null) { resolve({ data, title: 'Graphics' }); } else { resolve('not_supported') } }) }
else if (f === 'h') { si.bluetooth().then(data => { if (data !== null) { resolve({ data, title: 'Bluetooth' }); } else { resolve('not_supported') } }) }
else if (f === 'i') { si.inetLatency().then(data => { if (data !== null) { resolve({ data, title: 'Internet Latency' }); } else { resolve('not_supported') } }) }
else if (f === 'I') { si.inetChecksite('www.plus-innovations.com').then(data => { if (data !== null) { resolve({ data, title: 'Internet Check Site' }); } else { resolve('not_supported') } }) }
else if (f === 'l') { si.cpuCurrentspeed().then(data => { if (data !== null) { resolve({ data, title: 'CPU Current Speed' }); } else { resolve('not_supported') } }) }
else if (f === 'L') { si.fullLoad().then(data => { if (data !== null) { resolve({ data, title: 'CPU Full Load' }); } else { resolve('not_supported') } }) }
else if (f === 'm') { si.mem().then(data => { if (data !== null) { resolve({ data, title: 'Memory' }); } else { resolve('not_supported') } }) }
else if (f === 'M') { si.memLayout().then(data => { if (data !== null) { resolve({ data, title: 'Memory Layout' }); } else { resolve('not_supported') } }) }
else if (f === 'o') { si.osInfo().then(data => { if (data !== null) { resolve({ data, title: 'OS Info' }); } else { resolve('not_supported') } }) }
else if (f === 'p') { si.processes().then(data => { if (data !== null) { resolve({ data, title: 'Processes' }); } else { resolve('not_supported') } }) }
else if (f === 'P') { si.processLoad('postgres').then(data => { if (data !== null) { resolve({ data, title: 'Process Load' }); } else { resolve('not_supported') } }) }
else if (f === 'r') { si.printer().then(data => { if (data !== null) { resolve({ data, title: 'Printer' }); } else { resolve('not_supported') } }) }
else if (f === 's') { si.services('apache2, postgres').then(data => { if (data !== null) { resolve({ data, title: 'Services' }); } else { resolve('not_supported') } }) }
else if (f === 'S') { si.shell().then(data => { if (data !== null) { resolve({ data, title: 'Shell' }); } else { resolve('not_supported') } }) }
else if (f === 't') { resolve({ data: si.time(), title: 'Time' }) }
else if (f === 'T') { si.cpuTemperature().then(data => resolve({ data, title: 'CPU Temperature' })) }
else if (f === 'u') { si.usb().then(data => resolve({ data, title: 'USB' })) }
else if (f === 'U') { si.uuid().then(data => resolve({ data, title: 'UUID' })) }
else if (f === 'v') { si.versions().then(data => resolve({ data, title: 'Versions' })) }
else if (f === 'V') { si.vboxInfo().then(data => resolve({ data, title: 'Virtual Box' })) }
else if (f === 'w') { si.wifiNetworks().then(data => resolve({ data, title: 'WIFI Networks' })) }
else if (f === 'y') { si.battery().then(data => resolve({ data, title: 'Battery' })) }
else if (f === 'z') { si.users().then(data => resolve({ data, title: 'Users' })) }
else if (f === '1') { si.networkInterfaceDefault().then(data => resolve({ data, title: 'NET Iface Default' })) }
else if (f === '2') { si.networkGatewayDefault().then(data => resolve({ data, title: 'NET Gateway Default' })) }
else if (f === '3') { si.networkInterfaces().then(data => resolve({ data, title: 'NET Interfaces' })) }
else if (f === '4') { si.networkStats().then(data => resolve({ data, title: 'NET Stats' })) }
else if (f === '5') { si.networkConnections().then(data => resolve({ data, title: 'NET Connections' })) }
else if (f === '6') { si.dockerInfo().then(data => resolve({ data, title: 'Docker Info' })) }
else if (f === '7') { si.dockerContainers(true).then(data => resolve({ data, title: 'Docker Containers' })) }
else if (f === '8') { si.dockerContainerStats('1').then(data => resolve({ data, title: 'Docker Cont Stats' })) }
else if (f === '9') { si.dockerContainerProcesses('1').then(data => resolve({ data, title: 'Docker Cont Processes' })) }
else if (f === '0') { si.dockerAll().then(data => resolve({ data, title: 'Docker All' })) }
else if (f === '+') { si.getStaticData().then(data => resolve({ data, title: 'All Static Data' })) }
else if (f === '-') { si.getDynamicData('apache2, postgres').then(data => resolve({ data, title: 'All Dynamic Data' })) }
else if (f === '#') { si.getAllData('apache2, postgres').then(data => resolve({ data, title: 'All Data' })) }
else if (f === ',') {
else if (f === 'T') { si.cpuTemperature().then(data => { if (data !== null) { resolve({ data, title: 'CPU Temperature' }); } else { resolve('not_supported') } }) }
else if (f === 'u') { si.usb().then(data => { if (data !== null) { resolve({ data, title: 'USB' }); } else { resolve('not_supported') } }) }
else if (f === 'U') { si.uuid().then(data => { if (data !== null) { resolve({ data, title: 'UUID' }); } else { resolve('not_supported') } }) }
else if (f === 'v') { si.versions().then(data => { if (data !== null) { resolve({ data, title: 'Versions' }); } else { resolve('not_supported') } }) }
else if (f === 'V') { si.vboxInfo().then(data => { if (data !== null) { resolve({ data, title: 'Virtual Box' }); } else { resolve('not_supported') } }) }
else if (f === 'w') { si.wifiNetworks().then(data => { if (data !== null) { resolve({ data, title: 'WIFI Networks' }); } else { resolve('not_supported') } }) }
else if (f === 'y') { si.battery().then(data => { if (data !== null) { resolve({ data, title: 'Battery' }); } else { resolve('not_supported') } }) }
else if (f === 'z') { si.users().then(data => { if (data !== null) { resolve({ data, title: 'Users' }); } else { resolve('not_supported') } }) }
else if (f === '1') { si.networkInterfaceDefault().then(data => { if (data !== null) { resolve({ data, title: 'NET Iface Default' }); } else { resolve('not_supported') } }) }
else if (f === '2') { si.networkGatewayDefault().then(data => { if (data !== null) { resolve({ data, title: 'NET Gateway Default' }); } else { resolve('not_supported') } }) }
else if (f === '3') { si.networkInterfaces().then(data => { if (data !== null) { resolve({ data, title: 'NET Interfaces' }); } else { resolve('not_supported') } }) }
else if (f === '4') { si.networkStats().then(data => { if (data !== null) { resolve({ data, title: 'NET Stats' }); } else { resolve('not_supported') } }) }
else if (f === '5') { si.networkConnections().then(data => { if (data !== null) { resolve({ data, title: 'NET Connections' }); } else { resolve('not_supported') } }) }
else if (f === '6') { si.dockerInfo().then(data => { if (data !== null) { resolve({ data, title: 'Docker Info' }); } else { resolve('not_supported') } }) }
else if (f === '7') { si.dockerContainers(true).then(data => { if (data !== null) { resolve({ data, title: 'Docker Containers' }); } else { resolve('not_supported') } }) }
else if (f === '8') { si.dockerContainerStats('1').then(data => { if (data !== null) { resolve({ data, title: 'Docker Cont Stats' }); } else { resolve('not_supported') } }) }
else if (f === '9') { si.dockerContainerProcesses('1').then(data => { if (data !== null) { resolve({ data, title: 'Docker Cont Processes' }); } else { resolve('not_supported') } }) }
else if (f === '0') { si.dockerAll().then(data => { if (data !== null) { resolve({ data, title: 'Docker All' }); } else { resolve('not_supported') } }) }
else if (f === '+') { si.getStaticData().then(data => { if (data !== null) { resolve({ data, title: 'All Static Data' }); } else { resolve('not_supported') } }) }
else if (f === '-') { si.getDynamicData('apache2, postgres').then(data => { if (data !== null) { resolve({ data, title: 'All Dynamic Data' }); } else { resolve('not_supported') } }) }
else if (f === '#') { si.getAllData('apache2, postgres').then(data => { if (data !== null) { resolve({ data, title: 'All Data' }); } else { resolve('not_supported') } }) }
else if (f === '.') {
const valueObject = {
cpu: '*',
osInfo: 'platform, release',

View File

@ -1,25 +1,32 @@
const readline = require('readline');
const util = require('util');
const { exec } = require('child_process');
const { exec } = require('child_process');
const lib_version = require('../package.json').version;
let waiting = false;
let timer;
function printHeader() {
console.log('');
console.log('SYSTEMINFORMATION - Test Scripts - Version: ' + lib_version);
console.log('═════════════════════════════════════════════════════');
}
function printMenu() {
console.log('');
console.log('-----------------------------------------------------------------------------------------------------------------------------------');
console.log('a ... Audio g ... Graphics p ... Processes w ... WIFI networks 1 ... NET Iface Default');
console.log('b ... BIOS h ... Bluetooth P ... Process Load y ... Battery 2 ... NET Gateway Default');
console.log('B ... Baseboard i ... INET Latency r ... Printer z ... Users 3 ... NET Interfaces');
console.log('C ... Chassis I ... INET Check Site s ... Services 4 ... NET Stats');
console.log('c ... CPU l ... CPU Load S ... Shell 5 ... NET Connections');
console.log('d ... DiskLayout L ... Full Load t ... time 6 ... Docker Info');
console.log('D ... DiskIO n ... T ... CPU Temperature + ... All Static 7 ... Docker Container');
console.log('e ... Block Devices m ... Memory u ... USB - ... All Dynamic 8 ... Docker Cont Stats');
console.log('E ... Open Files M ... MEM Layout U ... UUID # ... All 9 ... Docker Cont Proc');
console.log('f ... FS Size o ... OS Info v ... Versions , ... Get Object 0 ... Docker All');
console.log('F ... FS Stats O ... V ... VirtualBox . ... Observe q >>> Quit');
console.log('-----------------------------------------------------------------------------------------------------------------------------------');
console.log('');
console.log('┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐');
console.log('a ... Audio g ... Graphics p ... Processes w ... WIFI networks 1 ... NET Iface Default');
console.log('b ... BIOS h ... Bluetooth P ... Process Load y ... Battery 2 ... NET Gateway Default');
console.log('B ... Baseboard i ... INET Latency r ... Printer z ... Users 3 ... NET Interfaces');
console.log('C ... Chassis I ... INET Check Site s ... Services 4 ... NET Stats');
console.log('c ... CPU l ... CPU Load S ... Shell 5 ... NET Connections');
console.log('d ... DiskLayout L ... Full Load t ... time 6 ... Docker Info');
console.log('D ... DiskIO n ... T ... CPU Temperature 7 ... Docker Container │');
console.log('e ... Block Devices m ... Memory u ... USB + ... All Static 8 ... Docker Cont Stats │');
console.log('E ... Open Files M ... MEM Layout U ... UUID - ... All Dynamic 9 ... Docker Cont Proc │');
console.log('f ... FS Size o ... OS Info v ... Versions # ... All 0 ... Docker All │');
console.log('F ... FS Stats O ... V ... VirtualBox . ... Get Object q >>> Quit │');
console.log('└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘');
}
function EnableUserInput() {
@ -27,15 +34,16 @@ function EnableUserInput() {
process.stdin.setRawMode(true);
}
// function DisableUserInput() {
// process.stdin.removeAllListeners()
// }
function noop() { }
function dot() {
process.stdout.write('.');
}
function clearline() {
readline.cursorTo(process.stdout, 0);
process.stdout.write(' ');
}
function startDots() {
dot();
timer = setInterval(() => {
@ -48,10 +56,11 @@ function stopDots() {
}
function printTitle(title) {
title = '||' + (' ' + title + ' ').substr(0, 36) + '||'
console.log('========================================');
// https://en.wikipedia.org/wiki/Box_Drawing_(Unicode_block)
title = '┃' + (' ' + title + ' ').substr(0, 38) + '┃'
console.log('┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓');
console.log(title);
console.log('========================================');
console.log('┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛');
}
@ -68,18 +77,23 @@ process.stdin.on('keypress', (key, data) => {
exec(`node si.js '${key}'`, {timeout: 30000}, (error, stdout) => {
waiting = false;
stopDots();
clearline();
if (error && error.signal) {
console.log();
console.log('Key: ' + key);
console.log('TIMEOUT!');
} else {
try {
if (stdout.toString().startsWith('"no_key')) {
console.log()
console.log('menu item not found - select valid menu item')
console.log('Menu item not found. Please select valid menu item ... Press q to quit')
} else if (stdout.toString().startsWith('"not_supported')) {
console.log()
console.log('Key: ' + key);
console.log('Not supported');
} else if (stdout.toString()) {
data = JSON.parse(stdout.toString());
console.log();
console.log();
printTitle(data.title);
console.log(util.inspect(data.data, { colors: true, depth: 4 }));
printMenu();
@ -87,12 +101,16 @@ process.stdin.on('keypress', (key, data) => {
} catch (e) {
console.log();
console.log('Key: ' + key);
console.log('ERROR - UNSUPPORTET');
console.log('ERROR');
console.log('----------------------------------------------------------------------------------------------------');
console.log(stdout.toString());
console.log();
}
}
})
}
});
printHeader();
printMenu();
EnableUserInput();