diff --git a/CHANGELOG.md b/CHANGELOG.md index 20799d7..14e8aa7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page. | Version | Date | Comment | | -------------- | -------------- | -------- | +| 4.8.0 | 2019-05-31 | added `vboxInfo()` detailed virtual box info | | 4.7.3 | 2019-05-30 | updated typescript typings | | 4.7.2 | 2019-05-30 | `versions()` added virtualbox, java popup fix macos | | 4.7.1 | 2019-05-29 | `memLayout()` fix macos mojave | diff --git a/README.md b/README.md index 78008f1..302366c 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,7 @@ si.cpu() (last 7 major and minor version releases) +- Version 4.8.0: added `vboxInfo()` detailed virtual box info - Version 4.7.0: partial NetBSD support - Version 4.6.0: added `dockerInfo()` - Version 4.5.0: `fsOpenFiles()` added open file descriptor count @@ -546,7 +547,46 @@ I also created a nice little command line tool called [mmon][mmon-github-url] ( | | [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
and processes in one single array | -#### 12. "Get All at once" - functions +#### 12. Virtual Box + +| Function | Result object | Linux | BSD | Mac | Win | Sun | Comments | +| --------------- | ------------- | ----- | ------- | --- | --- | --- | -------- | +| si.vboxInfo(cb) | {...} | X | X | X | X | X | returns general virtual box info | +| | id | X | X | X | X | X | virtual box ID | +| | name | X | X | X | X | X | name | +| | running | X | X | X | X | X | vbox is running | +| | runningSince | X | X | X | X | X | running since (secs) | +| | guestOS | X | X | X | X | X | Guest OK | +| | hardwareUUID | X | X | X | X | X | Hardware UUID | +| | memory | X | X | X | X | X | Memory in MB | +| | vram | X | X | X | X | X | VRAM in MB | +| | cpus | X | X | X | X | X | CPUs | +| | cpuExepCap | X | X | X | X | X | CPU exec cap | +| | cpuProfile | X | X | X | X | X | CPU profile | +| | chipset | X | X | X | X | X | chipset | +| | firmware | X | X | X | X | X | firmware | +| | pageFusion | X | X | X | X | X | page fusion | +| | configFile | X | X | X | X | X | config file | +| | snapshotFolder | X | X | X | X | X | snapshot folder | +| | logFolder | X | X | X | X | X | log folder path | +| | HPET | X | X | X | X | X | HPET | +| | PAE | X | X | X | X | X | PAE | +| | longMode | X | X | X | X | X | long mode | +| | tripleFaultReset | X | X | X | X | X | triple fault reset | +| | APIC | X | X | X | X | X | APIC | +| | X2APIC | X | X | X | X | X | X2APIC | +| | ACPI | X | X | X | X | X | ACPI | +| | IOAPIC | X | X | X | X | X | IOAPIC | +| | biosAPICmode | X | X | X | X | X | BIOS APIC mode | +| | bootMenuMode | X | X | X | X | X | boot menu Mode | +| | bootDevice1 | X | X | X | X | X | bootDevice1 | +| | bootDevice2 | X | X | X | X | X | bootDevice2 | +| | bootDevice3 | X | X | X | X | X | bootDevice3 | +| | bootDevice4 | X | X | X | X | X | bootDevice4 | +| | timeOffset | X | X | X | X | X | time Offset | +| | RTC | X | X | X | X | X | RTC | + +#### 13. "Get All at once" - functions | Function | Result object | Linux | BSD | Mac | Win | Sun | Comments | | --------------- | ------------- | ----- | ------- | --- | --- | --- | -------- | diff --git a/docs/history.html b/docs/history.html index 6b0b2a0..a8550ff 100644 --- a/docs/history.html +++ b/docs/history.html @@ -80,6 +80,11 @@ + + 4.8.0 + 2019-05-31 + vboxInfo() added virtualbox detailed VM info + 4.7.3 2019-05-30 diff --git a/docs/index.html b/docs/index.html index 64754a6..c719f66 100644 --- a/docs/index.html +++ b/docs/index.html @@ -19,7 +19,7 @@ - 🖥 systeminformation + systeminformation + + + + + + + + + + + + systeminformation + + + + + + +
+
+ +
+
+
+
Virtual Box
+
+

In this section you will learn how to get information about virtual box VMs:

+

For function reference and examples we assume, that we imported systeminformation as follows:

+
const si = require('systeminformation');
+

VMs

+

All functions in this section return a promise or can be called with a callback function (parameter cb in the function reference)

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FunctionResult objectLinuxBSDMacWinSunComments
si.vboxInfo(cb)[{...}]XXXXXreturns array of detailed info about all VMs
[0].idXXXXXvirtual box ID
[0].nameXXXXXname
[0].runningXXXXXvbox is running
[0].runningSinceXXXXXrunning since (secs)
[0].guestOSXXXXXGuest OK
[0].hardwareUUIDXXXXXHardware UUID
[0].memoryXXXXXMemory in MB
[0].vramXXXXXVRAM in MB
[0].cpusXXXXXCPUs
[0].cpuExepCapXXXXXCPU exec cap
[0].cpuProfileXXXXXCPU profile
[0].chipsetXXXXXchipset
[0].firmwareXXXXXfirmware
[0].pageFusionXXXXXpage fusion
[0].configFileXXXXXconfig file
[0].snapshotFolderXXXXXsnapshot folder
[0].logFolderXXXXXlog folder path
[0].HPETXXXXXHPET
[0].PAEXXXXXPAE
[0].longModeXXXXXlong mode
[0].tripleFaultResetXXXXXtriple fault reset
[0].APICXXXXXAPIC
[0].X2APICXXXXXX2APIC
[0].ACPIXXXXXACPI
[0].IOAPICXXXXXIOAPIC
[0].biosAPICmodeXXXXXBIOS APIC mode
[0].bootMenuModeXXXXXboot menu Mode
[0].bootDevice1XXXXXbootDevice1
[0].bootDevice2XXXXXbootDevice2
[0].bootDevice3XXXXXbootDevice3
[0].bootDevice4XXXXXbootDevice4
[0].timeOffsetXXXXXtime Offset
[0].RTCXXXXXRTC
+
+
+
+
+
+ +
+ + + + + + diff --git a/lib/index.js b/lib/index.js index 8006546..10c2810 100644 --- a/lib/index.js +++ b/lib/index.js @@ -35,6 +35,7 @@ const processes = require('./processes'); const users = require('./users'); const internet = require('./internet'); const docker = require('./docker'); +const vbox = require('./virtualbox'); let _platform = process.platform; const _windows = (_platform === 'win32'); @@ -364,6 +365,8 @@ exports.dockerContainerStats = docker.dockerContainerStats; exports.dockerContainerProcesses = docker.dockerContainerProcesses; exports.dockerAll = docker.dockerAll; +exports.vboxInfo = vbox.vboxInfo; + exports.getStaticData = getStaticData; exports.getDynamicData = getDynamicData; exports.getAllData = getAllData; diff --git a/lib/osinfo.js b/lib/osinfo.js index e461f4b..b602e9f 100644 --- a/lib/osinfo.js +++ b/lib/osinfo.js @@ -602,7 +602,7 @@ function versions(callback) { } else { functionProcessed(); } - }) + }); } else { exec('java -version 2>&1', function (error, stdout) { if (!error) { @@ -632,8 +632,7 @@ function versions(callback) { }); } }); - const vboxmanagePath = _windows ? process.env.VBOX_INSTALL_PATH || process.env.VBOX_MSI_INSTALL_PATH + '\\VBoxManage.exe' + '" ' : 'vboxmanage'; - exec(vboxmanagePath + ' -v 2>&1', function (error, stdout) { + exec(util.getVboxmanage() + ' -v 2>&1', function (error, stdout) { if (!error) { const vbox = stdout.toString().split('\n')[0] || ''; const parts = vbox.split('r'); diff --git a/lib/util.js b/lib/util.js index 3c9a86f..dd79432 100644 --- a/lib/util.js +++ b/lib/util.js @@ -254,6 +254,10 @@ function wmic(command, options) { }); } +function getVboxmanage() { + return _windows ? process.env.VBOX_INSTALL_PATH || process.env.VBOX_MSI_INSTALL_PATH + '\\VBoxManage.exe' + '" ' : 'vboxmanage'; +} + function powerShell(cmd) { let result = ''; @@ -407,6 +411,7 @@ exports.parseHead = parseHead; exports.findObjectByKey = findObjectByKey; exports.getWmic = getWmic; exports.wmic = wmic; +exports.getVboxmanage = getVboxmanage; exports.powerShell = powerShell; exports.nanoSeconds = nanoSeconds; exports.countUniqueLines = countUniqueLines; diff --git a/lib/virtualbox.js b/lib/virtualbox.js new file mode 100644 index 0000000..740f1f3 --- /dev/null +++ b/lib/virtualbox.js @@ -0,0 +1,102 @@ +'use strict'; +// @ts-check +// ================================================================================== +// virtualbox.js +// ---------------------------------------------------------------------------------- +// Description: System Information - library +// for Node.js +// Copyright: (c) 2014 - 2019 +// Author: Sebastian Hildebrandt +// ---------------------------------------------------------------------------------- +// License: MIT +// ================================================================================== +// 14. Docker +// ---------------------------------------------------------------------------------- + +const os = require('os'); +const exec = require('child_process').exec; +const util = require('./util'); + +function vboxInfo(all, callback) { + + // fallback - if only callback is given + if (util.isFunction(all) && !callback) { + callback = all; + all = false; + } + + all = all || false; + let result = []; + return new Promise((resolve) => { + process.nextTick(() => { + try { + exec(util.getVboxmanage() + ' list vms --long', function (error, stdout) { + let parts = stdout.toString().split('Name:'); + parts.shift(); + parts.forEach(part => { + const lines = part.split(os.EOL); + if (lines && lines[0]) { + lines[0] = 'Name:' + lines[0]; + } + const state = util.getValue(lines, 'State'); + const running = state.startsWith('running'); + const runningSinceString = running ? state.replace('running (since ', '').replace(')', '').trim() : ''; + let runningSince = 0; + try { + if (running) { + const sinceDateObj = new Date(runningSinceString); + const offset = sinceDateObj.getTimezoneOffset(); + runningSince = Math.round((Date.now() - Date.parse(sinceDateObj)) / 1000) + offset * 60; + } + } catch (e) { + util.noop(); + } + result.push({ + id: util.getValue(lines, 'UUID'), + name: util.getValue(lines, 'Name'), + running, + runningSince, + guestOS: util.getValue(lines, 'Guest OS'), + hardwareUUID: util.getValue(lines, 'Hardware UUID'), + memory: parseInt(util.getValue(lines, 'Memory size', ' '), 10), + vram: parseInt(util.getValue(lines, 'VRAM size'), 10), + cpus: parseInt(util.getValue(lines, 'Number of CPUs'), 10), + cpuExepCap: util.getValue(lines, 'CPU exec cap'), + cpuProfile: util.getValue(lines, 'CPUProfile'), + chipset: util.getValue(lines, 'Chipset'), + firmware: util.getValue(lines, 'Firmware'), + pageFusion: util.getValue(lines, 'Page Fusion') === 'enabled', + configFile: util.getValue(lines, 'Config file'), + snapshotFolder: util.getValue(lines, 'Snapshot folder'), + logFolder: util.getValue(lines, 'Log folder'), + HPET: util.getValue(lines, 'HPET') === 'enabled', + PAE: util.getValue(lines, 'PAE') === 'enabled', + longMode: util.getValue(lines, 'Long Mode') === 'enabled', + tripleFaultReset: util.getValue(lines, 'Triple Fault Reset') === 'enabled', + APIC: util.getValue(lines, 'APIC') === 'enabled', + X2APIC: util.getValue(lines, 'X2APIC') === 'enabled', + ACPI: util.getValue(lines, 'ACPI') === 'enabled', + IOAPIC: util.getValue(lines, 'IOAPIC') === 'enabled', + biosAPICmode: util.getValue(lines, 'BIOS APIC mode'), + bootMenuMode: util.getValue(lines, 'Boot menu mode'), + bootDevice1: util.getValue(lines, 'Boot Device 1'), + bootDevice2: util.getValue(lines, 'Boot Device 2'), + bootDevice3: util.getValue(lines, 'Boot Device 3'), + bootDevice4: util.getValue(lines, 'Boot Device 4'), + timeOffset: util.getValue(lines, 'Time offset'), + RTC: util.getValue(lines, 'RTC'), + }); + }); + + if (callback) { callback(result); } + resolve(result); + }); + } catch (e) { + if (callback) { callback(result); } + resolve(result); + } + }); + }); +} + +exports.vboxInfo = vboxInfo;