pascalCase modifications, docs update, tests improvement
This commit is contained in:
+51
-51
@@ -32,17 +32,17 @@ module.exports = function (callback) {
|
||||
return new Promise((resolve) => {
|
||||
process.nextTick(() => {
|
||||
let result = {
|
||||
hasbattery: false,
|
||||
cyclecount: 0,
|
||||
ischarging: false,
|
||||
designedcapacity: 0,
|
||||
maxcapacity: 0,
|
||||
currentcapacity: 0,
|
||||
hasBattery: false,
|
||||
cycleCount: 0,
|
||||
isCharging: false,
|
||||
designedCapacity: 0,
|
||||
maxCapacity: 0,
|
||||
currentCapacity: 0,
|
||||
voltage: 0,
|
||||
capacityUnit: '',
|
||||
percent: 0,
|
||||
timeremaining: null,
|
||||
acconnected: true,
|
||||
timeRemaining: null,
|
||||
acConnected: true,
|
||||
type: '',
|
||||
model: '',
|
||||
manufacturer: '',
|
||||
@@ -61,18 +61,18 @@ module.exports = function (callback) {
|
||||
if (!error) {
|
||||
let lines = stdout.toString().split('\n');
|
||||
|
||||
result.ischarging = (util.getValue(lines, 'POWER_SUPPLY_STATUS', '=').toLowerCase() === 'charging');
|
||||
result.acconnected = result.ischarging;
|
||||
result.isCharging = (util.getValue(lines, 'POWER_SUPPLY_STATUS', '=').toLowerCase() === 'charging');
|
||||
result.acConnected = result.isCharging;
|
||||
result.voltage = parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_VOLTAGE_NOW', '='), 10) / 1000000.0;
|
||||
result.capacityUnit = result.voltage ? 'mWh' : 'mAh';
|
||||
result.cyclecount = parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_CYCLE_COUNT', '='), 10);
|
||||
result.maxcapacity = Math.round(parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_CHARGE_FULL', '='), 10) / 1000.0 / (result.voltage || 1));
|
||||
result.designedcapacity = Math.round(parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_CHARGE_FULL_DESIGN', '='), 10) / 1000.0 / (result.voltage || 1)) | result.maxcapacity;
|
||||
result.currentcapacity = Math.round(parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_CHARGE_NOW', '='), 10) / 1000.0 / (result.voltage || 1));
|
||||
if (!result.maxcapacity) {
|
||||
result.maxcapacity = parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_ENERGY_FULL', '='), 10) / 1000.0;
|
||||
result.designcapacity = parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_ENERGY_FULL_DESIGN', '='), 10) / 1000.0 | result.maxcapacity;
|
||||
result.currentcapacity = parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_ENERGY_NOW', '='), 10) / 1000.0;
|
||||
result.cycleCount = parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_CYCLE_COUNT', '='), 10);
|
||||
result.maxCapacity = Math.round(parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_CHARGE_FULL', '='), 10) / 1000.0 / (result.voltage || 1));
|
||||
result.designedCapacity = Math.round(parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_CHARGE_FULL_DESIGN', '='), 10) / 1000.0 / (result.voltage || 1)) | result.maxcapacity;
|
||||
result.currentCapacity = Math.round(parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_CHARGE_NOW', '='), 10) / 1000.0 / (result.voltage || 1));
|
||||
if (!result.maxCapacity) {
|
||||
result.maxCapacity = parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_ENERGY_FULL', '='), 10) / 1000.0;
|
||||
result.designCapacity = parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_ENERGY_FULL_DESIGN', '='), 10) / 1000.0 | result.maxCapacity;
|
||||
result.currentCapacity = parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_ENERGY_NOW', '='), 10) / 1000.0;
|
||||
}
|
||||
const percent = util.getValue(lines, 'POWER_SUPPLY_CAPACITY', '=');
|
||||
const energy = parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_ENERGY_NOW', '='), 10);
|
||||
@@ -80,19 +80,19 @@ module.exports = function (callback) {
|
||||
const current = parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_CURRENT_NOW', '='), 10);
|
||||
|
||||
result.percent = parseInt('0' + percent, 10);
|
||||
if (result.maxcapacity && result.currentcapacity) {
|
||||
result.hasbattery = true;
|
||||
if (result.maxCapacity && result.currentCapacity) {
|
||||
result.hasBattery = true;
|
||||
if (!percent) {
|
||||
result.percent = 100.0 * result.currentcapacity / result.maxcapacity;
|
||||
result.percent = 100.0 * result.currentCapacity / result.maxCapacity;
|
||||
}
|
||||
}
|
||||
if (result.ischarging) {
|
||||
result.hasbattery = true;
|
||||
if (result.isCharging) {
|
||||
result.hasBattery = true;
|
||||
}
|
||||
if (energy && power) {
|
||||
result.timeremaining = Math.floor(energy / power * 60);
|
||||
} else if (current && result.currentcapacity) {
|
||||
result.timeremaining = Math.floor(result.currentcapacity / current * 60);
|
||||
result.timeRemaining = Math.floor(energy / power * 60);
|
||||
} else if (current && result.currentCapacity) {
|
||||
result.timeRemaining = Math.floor(result.currentCapacity / current * 60);
|
||||
}
|
||||
result.type = util.getValue(lines, 'POWER_SUPPLY_TECHNOLOGY', '=');
|
||||
result.model = util.getValue(lines, 'POWER_SUPPLY_MODEL_NAME', '=');
|
||||
@@ -115,12 +115,12 @@ module.exports = function (callback) {
|
||||
let lines = stdout.toString().split('\n');
|
||||
const batteries = parseInt('0' + util.getValue(lines, 'hw.acpi.battery.units'), 10);
|
||||
const percent = parseInt('0' + util.getValue(lines, 'hw.acpi.battery.life'), 10);
|
||||
result.hasbattery = (batteries > 0);
|
||||
result.cyclecount = null;
|
||||
result.ischarging = util.getValue(lines, 'hw.acpi.acline') !== '1';
|
||||
result.acconnected = result.ischarging;
|
||||
result.maxcapacity = null;
|
||||
result.currentcapacity = null;
|
||||
result.hasBattery = (batteries > 0);
|
||||
result.cycleCount = null;
|
||||
result.isCharging = util.getValue(lines, 'hw.acpi.acline') !== '1';
|
||||
result.acConnected = result.isCharging;
|
||||
result.maxCapacity = null;
|
||||
result.currentCapacity = null;
|
||||
result.capacityUnit = 'unknown';
|
||||
result.percent = batteries ? percent : null;
|
||||
if (callback) { callback(result); }
|
||||
@@ -132,12 +132,12 @@ module.exports = function (callback) {
|
||||
exec('ioreg -n AppleSmartBattery -r | egrep "CycleCount|IsCharging|DesignCapacity|MaxCapacity|CurrentCapacity|BatterySerialNumber|TimeRemaining|Voltage"; pmset -g batt | grep %', function (error, stdout) {
|
||||
if (stdout) {
|
||||
let lines = stdout.toString().replace(/ +/g, '').replace(/"+/g, '').replace(/-/g, '').split('\n');
|
||||
result.cyclecount = parseInt('0' + util.getValue(lines, 'cyclecount', '='), 10);
|
||||
result.cycleCount = parseInt('0' + util.getValue(lines, 'cyclecount', '='), 10);
|
||||
result.voltage = parseInt('0' + util.getValue(lines, 'voltage', '='), 10) / 1000.0;
|
||||
result.capacityUnit = result.voltage ? 'mWh' : 'mAh';
|
||||
result.maxcapacity = Math.round(parseInt('0' + util.getValue(lines, 'maxcapacity', '='), 10) * (result.voltage || 1));
|
||||
result.currentcapacity = Math.round(parseInt('0' + util.getValue(lines, 'currentcapacity', '='), 10) * (result.voltage || 1));
|
||||
result.designedcapacity = Math.round(parseInt('0' + util.getValue(lines, 'DesignCapacity', '='), 10) * (result.voltage || 1));
|
||||
result.maxCapacity = Math.round(parseInt('0' + util.getValue(lines, 'maxcapacity', '='), 10) * (result.voltage || 1));
|
||||
result.currentCapacity = Math.round(parseInt('0' + util.getValue(lines, 'currentcapacity', '='), 10) * (result.voltage || 1));
|
||||
result.designedCapacity = Math.round(parseInt('0' + util.getValue(lines, 'DesignCapacity', '='), 10) * (result.voltage || 1));
|
||||
result.manufacturer = 'Apple';
|
||||
result.serial = util.getValue(lines, 'BatterySerialNumber', '=');
|
||||
let percent = null;
|
||||
@@ -150,18 +150,18 @@ module.exports = function (callback) {
|
||||
}
|
||||
}
|
||||
if (parts && parts[1]) {
|
||||
result.ischarging = (parts[1].trim() === 'charging');
|
||||
result.acconnected = (parts[1].trim() !== 'discharging');
|
||||
result.isCharging = (parts[1].trim() === 'charging');
|
||||
result.acConnected = (parts[1].trim() !== 'discharging');
|
||||
} else {
|
||||
result.ischarging = util.getValue(lines, 'ischarging', '=').toLowerCase() === 'yes';
|
||||
result.acconnected = result.ischarging;
|
||||
result.isCharging = util.getValue(lines, 'ischarging', '=').toLowerCase() === 'yes';
|
||||
result.acConnected = result.isCharging;
|
||||
}
|
||||
if (result.maxcapacity && result.currentcapacity) {
|
||||
result.hasbattery = true;
|
||||
if (result.maxCapacity && result.currentCapacity) {
|
||||
result.hasBattery = true;
|
||||
result.type = 'Li-ion';
|
||||
result.percent = percent !== null ? percent : Math.round(100.0 * result.currentcapacity / result.maxcapacity);
|
||||
if (!result.ischarging) {
|
||||
result.timeremaining = parseInt('0' + util.getValue(lines, 'TimeRemaining', '='), 10);
|
||||
result.percent = percent !== null ? percent : Math.round(100.0 * result.currentCapacity / result.maxCapacity);
|
||||
if (!result.isCharging) {
|
||||
result.timeRemaining = parseInt('0' + util.getValue(lines, 'TimeRemaining', '='), 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -192,15 +192,15 @@ module.exports = function (callback) {
|
||||
// 11 = "Partially Charged"
|
||||
if (status && status != '10') {
|
||||
const statusValue = parseInt(status);
|
||||
result.hasbattery = true;
|
||||
result.maxcapacity = parseInt(util.getValue(lines, 'DesignCapacity', '=') || 0);
|
||||
result.designcapacity = parseInt(util.getValue(lines, 'DesignCapacity', '=') || 0);
|
||||
result.hasBattery = true;
|
||||
result.maxCapacity = parseInt(util.getValue(lines, 'DesignCapacity', '=') || 0);
|
||||
result.designCapacity = parseInt(util.getValue(lines, 'DesignCapacity', '=') || 0);
|
||||
result.voltage = parseInt(util.getValue(lines, 'DesignVoltage', '=') || 0) / 1000.0;
|
||||
result.capacityUnit = 'mWh';
|
||||
result.percent = parseInt(util.getValue(lines, 'EstimatedChargeRemaining', '=') || 0);
|
||||
result.currentcapacity = parseInt(result.maxcapacity * result.percent / 100);
|
||||
result.ischarging = (statusValue >= 6 && statusValue <= 9) || statusValue === 11 || (!(statusValue === 3) && !(statusValue === 1) && result.percent < 100);
|
||||
result.acconnected = result.ischarging || statusValue === 2;
|
||||
result.currentCapacity = parseInt(result.maxcapacity * result.percent / 100);
|
||||
result.isCharging = (statusValue >= 6 && statusValue <= 9) || statusValue === 11 || (!(statusValue === 3) && !(statusValue === 1) && result.percent < 100);
|
||||
result.acConnected = result.ischarging || statusValue === 2;
|
||||
}
|
||||
}
|
||||
if (callback) { callback(result); }
|
||||
|
||||
+88
-88
@@ -39,18 +39,18 @@ let _current_cpu = {
|
||||
load: 0,
|
||||
tick: 0,
|
||||
ms: 0,
|
||||
currentload: 0,
|
||||
currentload_user: 0,
|
||||
currentload_system: 0,
|
||||
currentload_nice: 0,
|
||||
currentload_idle: 0,
|
||||
currentload_irq: 0,
|
||||
raw_currentload: 0,
|
||||
raw_currentload_user: 0,
|
||||
raw_currentload_system: 0,
|
||||
raw_currentload_nice: 0,
|
||||
raw_currentload_idle: 0,
|
||||
raw_currentload_irq: 0
|
||||
currentLoad: 0,
|
||||
currentLoadUser: 0,
|
||||
currentLoadSystem: 0,
|
||||
currentLoadNice: 0,
|
||||
currentLoadIdle: 0,
|
||||
currentLoadIrq: 0,
|
||||
rawCurrentLoad: 0,
|
||||
rawCurrentLoadUser: 0,
|
||||
rawCurrentLoadSystem: 0,
|
||||
rawCurrentLoadNice: 0,
|
||||
rawCurrentLoadIdle: 0,
|
||||
rawCurrentLoadIrq: 0
|
||||
};
|
||||
let _cpus = [];
|
||||
let _corecount = 0;
|
||||
@@ -889,7 +889,7 @@ function getCpuCurrentSpeedSync() {
|
||||
}
|
||||
}
|
||||
|
||||
function cpuCurrentspeed(callback) {
|
||||
function cpuCurrentSpeed(callback) {
|
||||
|
||||
return new Promise((resolve) => {
|
||||
process.nextTick(() => {
|
||||
@@ -909,7 +909,7 @@ function cpuCurrentspeed(callback) {
|
||||
});
|
||||
}
|
||||
|
||||
exports.cpuCurrentspeed = cpuCurrentspeed;
|
||||
exports.cpuCurrentSpeed = cpuCurrentSpeed;
|
||||
|
||||
// --------------------------
|
||||
// CPU - temperature
|
||||
@@ -1357,7 +1357,7 @@ function getLoad() {
|
||||
return new Promise((resolve) => {
|
||||
process.nextTick(() => {
|
||||
let loads = os.loadavg().map(function (x) { return x / util.cores(); });
|
||||
let avgload = parseFloat((Math.max.apply(Math, loads)).toFixed(2));
|
||||
let avgLoad = parseFloat((Math.max.apply(Math, loads)).toFixed(2));
|
||||
let result = {};
|
||||
|
||||
let now = Date.now() - _current_cpu.ms;
|
||||
@@ -1379,54 +1379,54 @@ function getLoad() {
|
||||
totalNice += cpu.nice;
|
||||
totalIdle += cpu.idle;
|
||||
totalIrq += cpu.irq;
|
||||
let tmp_tick = (_cpus && _cpus[i] && _cpus[i].totalTick ? _cpus[i].totalTick : 0);
|
||||
let tmp_load = (_cpus && _cpus[i] && _cpus[i].totalLoad ? _cpus[i].totalLoad : 0);
|
||||
let tmp_user = (_cpus && _cpus[i] && _cpus[i].user ? _cpus[i].user : 0);
|
||||
let tmp_system = (_cpus && _cpus[i] && _cpus[i].sys ? _cpus[i].sys : 0);
|
||||
let tmp_nice = (_cpus && _cpus[i] && _cpus[i].nice ? _cpus[i].nice : 0);
|
||||
let tmp_idle = (_cpus && _cpus[i] && _cpus[i].idle ? _cpus[i].idle : 0);
|
||||
let tmp_irq = (_cpus && _cpus[i] && _cpus[i].irq ? _cpus[i].irq : 0);
|
||||
let tmpTick = (_cpus && _cpus[i] && _cpus[i].totalTick ? _cpus[i].totalTick : 0);
|
||||
let tmpLoad = (_cpus && _cpus[i] && _cpus[i].totalLoad ? _cpus[i].totalLoad : 0);
|
||||
let tmpUser = (_cpus && _cpus[i] && _cpus[i].user ? _cpus[i].user : 0);
|
||||
let tmpSystem = (_cpus && _cpus[i] && _cpus[i].sys ? _cpus[i].sys : 0);
|
||||
let tmpNice = (_cpus && _cpus[i] && _cpus[i].nice ? _cpus[i].nice : 0);
|
||||
let tmpIdle = (_cpus && _cpus[i] && _cpus[i].idle ? _cpus[i].idle : 0);
|
||||
let tmpIrq = (_cpus && _cpus[i] && _cpus[i].irq ? _cpus[i].irq : 0);
|
||||
_cpus[i] = cpu;
|
||||
_cpus[i].totalTick = _cpus[i].user + _cpus[i].sys + _cpus[i].nice + _cpus[i].irq + _cpus[i].idle;
|
||||
_cpus[i].totalLoad = _cpus[i].user + _cpus[i].sys + _cpus[i].nice + _cpus[i].irq;
|
||||
_cpus[i].currentTick = _cpus[i].totalTick - tmp_tick;
|
||||
_cpus[i].load = (_cpus[i].totalLoad - tmp_load);
|
||||
_cpus[i].load_user = (_cpus[i].user - tmp_user);
|
||||
_cpus[i].load_system = (_cpus[i].sys - tmp_system);
|
||||
_cpus[i].load_nice = (_cpus[i].nice - tmp_nice);
|
||||
_cpus[i].load_idle = (_cpus[i].idle - tmp_idle);
|
||||
_cpus[i].load_irq = (_cpus[i].irq - tmp_irq);
|
||||
_cpus[i].currentTick = _cpus[i].totalTick - tmpTick;
|
||||
_cpus[i].load = (_cpus[i].totalLoad - tmpLoad);
|
||||
_cpus[i].loadUser = (_cpus[i].user - tmpUser);
|
||||
_cpus[i].loadSystem = (_cpus[i].sys - tmpSystem);
|
||||
_cpus[i].loadNice = (_cpus[i].nice - tmpNice);
|
||||
_cpus[i].loadIdle = (_cpus[i].idle - tmpIdle);
|
||||
_cpus[i].loadIrq = (_cpus[i].irq - tmpIrq);
|
||||
cores[i] = {};
|
||||
cores[i].load = _cpus[i].load / _cpus[i].currentTick * 100;
|
||||
cores[i].load_user = _cpus[i].load_user / _cpus[i].currentTick * 100;
|
||||
cores[i].load_system = _cpus[i].load_system / _cpus[i].currentTick * 100;
|
||||
cores[i].load_nice = _cpus[i].load_nice / _cpus[i].currentTick * 100;
|
||||
cores[i].load_idle = _cpus[i].load_idle / _cpus[i].currentTick * 100;
|
||||
cores[i].load_irq = _cpus[i].load_irq / _cpus[i].currentTick * 100;
|
||||
cores[i].raw_load = _cpus[i].load;
|
||||
cores[i].raw_load_user = _cpus[i].load_user;
|
||||
cores[i].raw_load_system = _cpus[i].load_system;
|
||||
cores[i].raw_load_nice = _cpus[i].load_nice;
|
||||
cores[i].raw_load_idle = _cpus[i].load_idle;
|
||||
cores[i].raw_load_irq = _cpus[i].load_irq;
|
||||
cores[i].loadUser = _cpus[i].load_user / _cpus[i].currentTick * 100;
|
||||
cores[i].loadSystem = _cpus[i].load_system / _cpus[i].currentTick * 100;
|
||||
cores[i].loadNice = _cpus[i].load_nice / _cpus[i].currentTick * 100;
|
||||
cores[i].loadIdle = _cpus[i].load_idle / _cpus[i].currentTick * 100;
|
||||
cores[i].loadIrq = _cpus[i].load_irq / _cpus[i].currentTick * 100;
|
||||
cores[i].rawLoad = _cpus[i].load;
|
||||
cores[i].rawLoadUser = _cpus[i].loadUser;
|
||||
cores[i].rawLoadSystem = _cpus[i].loadSystem;
|
||||
cores[i].rawLoadNice = _cpus[i].loadNice;
|
||||
cores[i].rawLoadIdle = _cpus[i].loadIdle;
|
||||
cores[i].rawLoadIrq = _cpus[i].loadIrq;
|
||||
}
|
||||
let totalTick = totalUser + totalSystem + totalNice + totalIrq + totalIdle;
|
||||
let totalLoad = totalUser + totalSystem + totalNice + totalIrq;
|
||||
let currentTick = totalTick - _current_cpu.tick;
|
||||
result = {
|
||||
avgload: avgload,
|
||||
currentload: (totalLoad - _current_cpu.load) / currentTick * 100,
|
||||
currentload_user: (totalUser - _current_cpu.user) / currentTick * 100,
|
||||
currentload_system: (totalSystem - _current_cpu.system) / currentTick * 100,
|
||||
currentload_nice: (totalNice - _current_cpu.nice) / currentTick * 100,
|
||||
currentload_idle: (totalIdle - _current_cpu.idle) / currentTick * 100,
|
||||
currentload_irq: (totalIrq - _current_cpu.irq) / currentTick * 100,
|
||||
raw_currentload: (totalLoad - _current_cpu.load),
|
||||
raw_currentload_user: (totalUser - _current_cpu.user),
|
||||
raw_currentload_system: (totalSystem - _current_cpu.system),
|
||||
raw_currentload_nice: (totalNice - _current_cpu.nice),
|
||||
raw_currentload_idle: (totalIdle - _current_cpu.idle),
|
||||
raw_currentload_irq: (totalIrq - _current_cpu.irq),
|
||||
avgLoad: avgLoad,
|
||||
currentLoad: (totalLoad - _current_cpu.load) / currentTick * 100,
|
||||
currentLoadUser: (totalUser - _current_cpu.user) / currentTick * 100,
|
||||
currentLoadSystem: (totalSystem - _current_cpu.system) / currentTick * 100,
|
||||
currentLoadNice: (totalNice - _current_cpu.nice) / currentTick * 100,
|
||||
currentLoadIdle: (totalIdle - _current_cpu.idle) / currentTick * 100,
|
||||
currentLoadIrq: (totalIrq - _current_cpu.irq) / currentTick * 100,
|
||||
rawCurrentLoad: (totalLoad - _current_cpu.load),
|
||||
rawCurrentLoadUser: (totalUser - _current_cpu.user),
|
||||
rawCurrentLoadSystem: (totalSystem - _current_cpu.system),
|
||||
rawCurrentLoadNice: (totalNice - _current_cpu.nice),
|
||||
rawCurrentLoadIdle: (totalIdle - _current_cpu.idle),
|
||||
rawCurrentLoadIrq: (totalIrq - _current_cpu.irq),
|
||||
cpus: cores
|
||||
};
|
||||
_current_cpu = {
|
||||
@@ -1438,50 +1438,50 @@ function getLoad() {
|
||||
tick: totalTick,
|
||||
load: totalLoad,
|
||||
ms: _current_cpu.ms,
|
||||
currentload: result.currentload,
|
||||
currentload_user: result.currentload_user,
|
||||
currentload_system: result.currentload_system,
|
||||
currentload_nice: result.currentload_nice,
|
||||
currentload_idle: result.currentload_idle,
|
||||
currentload_irq: result.currentload_irq,
|
||||
raw_currentload: result.raw_currentload,
|
||||
raw_currentload_user: result.raw_currentload_user,
|
||||
raw_currentload_system: result.raw_currentload_system,
|
||||
raw_currentload_nice: result.raw_currentload_nice,
|
||||
raw_currentload_idle: result.raw_currentload_idle,
|
||||
raw_currentload_irq: result.raw_currentload_irq,
|
||||
currentLoad: result.currentLoad,
|
||||
currentLoadUser: result.currentLoadUser,
|
||||
currentLoadSystem: result.currentLoadSystem,
|
||||
currentLoadNice: result.currentLoadNice,
|
||||
currentLoadIdle: result.currentLoadIdle,
|
||||
currentLoadIrq: result.currentLoadIrq,
|
||||
rawCurrentLoad: result.rawCurrentLoad,
|
||||
rawCurrentLoadUser: result.rawCurrentLoadUser,
|
||||
rawCurrentLoadSystem: result.rawCurrentLoadSystem,
|
||||
rawCurrentLoadNice: result.rawCurrentLoadNice,
|
||||
rawCurrentLoadIdle: result.rawCurrentLoadIdle,
|
||||
rawCurrentLoadIrq: result.rawCurrentLoadIrq,
|
||||
};
|
||||
} else {
|
||||
let cores = [];
|
||||
for (let i = 0; i < _corecount; i++) {
|
||||
cores[i] = {};
|
||||
cores[i].load = _cpus[i].load / _cpus[i].currentTick * 100;
|
||||
cores[i].load_user = _cpus[i].load_user / _cpus[i].currentTick * 100;
|
||||
cores[i].load_system = _cpus[i].load_system / _cpus[i].currentTick * 100;
|
||||
cores[i].load_nice = _cpus[i].load_nice / _cpus[i].currentTick * 100;
|
||||
cores[i].load_idle = _cpus[i].load_idle / _cpus[i].currentTick * 100;
|
||||
cores[i].load_irq = _cpus[i].load_irq / _cpus[i].currentTick * 100;
|
||||
cores[i].raw_load = _cpus[i].load;
|
||||
cores[i].raw_load_user = _cpus[i].load_user;
|
||||
cores[i].raw_load_system = _cpus[i].load_system;
|
||||
cores[i].raw_load_nice = _cpus[i].load_nice;
|
||||
cores[i].raw_load_idle = _cpus[i].load_idle;
|
||||
cores[i].raw_load_irq = _cpus[i].load_irq;
|
||||
cores[i].loadUser = _cpus[i].loadUser / _cpus[i].currentTick * 100;
|
||||
cores[i].loadSystem = _cpus[i].loadSystem / _cpus[i].currentTick * 100;
|
||||
cores[i].loadNice = _cpus[i].loadNice / _cpus[i].currentTick * 100;
|
||||
cores[i].loadIdle = _cpus[i].loadIdle / _cpus[i].currentTick * 100;
|
||||
cores[i].loadIrq = _cpus[i].loadIrq / _cpus[i].currentTick * 100;
|
||||
cores[i].rawLoad = _cpus[i].load;
|
||||
cores[i].rawLoadUser = _cpus[i].loadUser;
|
||||
cores[i].rawLoadSystem = _cpus[i].loadSystem;
|
||||
cores[i].rawLoadNice = _cpus[i].loadNice;
|
||||
cores[i].rawLoadIdle = _cpus[i].loadIdle;
|
||||
cores[i].rawLoadIrq = _cpus[i].loadIrq;
|
||||
}
|
||||
result = {
|
||||
avgload: avgload,
|
||||
avgLoad: avgLoad,
|
||||
currentload: _current_cpu.currentload,
|
||||
currentload_user: _current_cpu.currentload_user,
|
||||
currentload_system: _current_cpu.currentload_system,
|
||||
currentload_nice: _current_cpu.currentload_nice,
|
||||
currentload_idle: _current_cpu.currentload_idle,
|
||||
currentload_irq: _current_cpu.currentload_irq,
|
||||
raw_currentload: _current_cpu.raw_currentload,
|
||||
raw_currentload_user: _current_cpu.raw_currentload_user,
|
||||
raw_currentload_system: _current_cpu.raw_currentload_system,
|
||||
raw_currentload_nice: _current_cpu.raw_currentload_nice,
|
||||
raw_currentload_idle: _current_cpu.raw_currentload_idle,
|
||||
raw_currentload_irq: _current_cpu.raw_currentload_irq,
|
||||
currentloadUser: _current_cpu.currentloadUser,
|
||||
currentloadSystem: _current_cpu.currentloadSystem,
|
||||
currentloadNice: _current_cpu.currentloadNice,
|
||||
currentloadIdle: _current_cpu.currentloadIdle,
|
||||
currentloadIrq: _current_cpu.currentloadIrq,
|
||||
rawCurrentload: _current_cpu.rawCurrentload,
|
||||
rawCurrentloadUser: _current_cpu.rawCurrentloadUser,
|
||||
rawCurrentloadSystem: _current_cpu.rawCurrentloadSystem,
|
||||
rawCurrentloadNice: _current_cpu.rawCurrentloadNice,
|
||||
rawCurrentloadIdle: _current_cpu.rawCurrentloadIdle,
|
||||
rawCurrentloadIrq: _current_cpu.rawCurrentloadIrq,
|
||||
cpus: cores
|
||||
};
|
||||
}
|
||||
|
||||
+19
-30
@@ -379,10 +379,10 @@ function dockerContainerStatsSingle(containerID) {
|
||||
containerID = containerID || '';
|
||||
let result = {
|
||||
id: containerID,
|
||||
mem_usage: 0,
|
||||
mem_limit: 0,
|
||||
mem_percent: 0,
|
||||
cpu_percent: 0,
|
||||
memUsage: 0,
|
||||
memLimit: 0,
|
||||
memPercent: 0,
|
||||
cpuPercent: 0,
|
||||
pids: 0,
|
||||
netIO: {
|
||||
rx: 0,
|
||||
@@ -406,30 +406,19 @@ function dockerContainerStatsSingle(containerID) {
|
||||
_docker_socket.getStats(containerID, data => {
|
||||
try {
|
||||
let stats = data;
|
||||
/**
|
||||
* @namespace
|
||||
* @property {Object} memory_stats
|
||||
* @property {number} memory_stats.usage
|
||||
* @property {number} memory_stats.limit
|
||||
* @property {Object} cpu_stats
|
||||
* @property {Object} pids_stats
|
||||
* @property {number} pids_stats.current
|
||||
* @property {Object} networks
|
||||
* @property {Object} blkio_stats
|
||||
*/
|
||||
|
||||
if (!stats.message) {
|
||||
result.mem_usage = (stats.memory_stats && stats.memory_stats.usage ? stats.memory_stats.usage : 0);
|
||||
result.mem_limit = (stats.memory_stats && stats.memory_stats.limit ? stats.memory_stats.limit : 0);
|
||||
result.mem_percent = (stats.memory_stats && stats.memory_stats.usage && stats.memory_stats.limit ? stats.memory_stats.usage / stats.memory_stats.limit * 100.0 : 0);
|
||||
result.cpu_percent = (stats.cpu_stats && stats.precpu_stats ? docker_calcCPUPercent(stats.cpu_stats, stats.precpu_stats) : 0);
|
||||
result.memUsage = (stats.memory_stats && stats.memory_stats.usage ? stats.memory_stats.usage : 0);
|
||||
result.memLimit = (stats.memory_stats && stats.memory_stats.limit ? stats.memory_stats.limit : 0);
|
||||
result.memPercent = (stats.memory_stats && stats.memory_stats.usage && stats.memory_stats.limit ? stats.memory_stats.usage / stats.memory_stats.limit * 100.0 : 0);
|
||||
result.cpuPercent = (stats.cpu_stats && stats.precpu_stats ? docker_calcCPUPercent(stats.cpu_stats, stats.precpu_stats) : 0);
|
||||
result.pids = (stats.pids_stats && stats.pids_stats.current ? stats.pids_stats.current : 0);
|
||||
result.restartCount = (dataInspect.RestartCount ? dataInspect.RestartCount : 0);
|
||||
if (stats.networks) result.netIO = docker_calcNetworkIO(stats.networks);
|
||||
if (stats.blkio_stats) result.blockIO = docker_calcBlockIO(stats.blkio_stats);
|
||||
result.cpu_stats = (stats.cpu_stats ? stats.cpu_stats : {});
|
||||
result.precpu_stats = (stats.precpu_stats ? stats.precpu_stats : {});
|
||||
result.memory_stats = (stats.memory_stats ? stats.memory_stats : {});
|
||||
result.cpuStats = (stats.cpu_stats ? stats.cpu_stats : {});
|
||||
result.precpuStats = (stats.precpu_stats ? stats.precpu_stats : {});
|
||||
result.memoryStats = (stats.memory_stats ? stats.memory_stats : {});
|
||||
result.networks = (stats.networks ? stats.networks : {});
|
||||
}
|
||||
} catch (err) {
|
||||
@@ -493,7 +482,7 @@ function dockerContainerProcesses(containerID, callback) {
|
||||
|
||||
data.Processes.forEach(process => {
|
||||
result.push({
|
||||
pid_host: (pos_pid >= 0 ? process[pos_pid] : ''),
|
||||
pidHost: (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] : ''),
|
||||
@@ -535,16 +524,16 @@ function dockerAll(callback) {
|
||||
result.forEach(function (element) {
|
||||
dockerContainerStats(element.id).then(res => {
|
||||
// include stats in array
|
||||
element.mem_usage = res[0].mem_usage;
|
||||
element.mem_limit = res[0].mem_limit;
|
||||
element.mem_percent = res[0].mem_percent;
|
||||
element.cpu_percent = res[0].cpu_percent;
|
||||
element.memUsage = res[0].memUsage;
|
||||
element.memLimit = res[0].memLimit;
|
||||
element.memPercent = res[0].memPercent;
|
||||
element.cpuPercent = res[0].cpuPercent;
|
||||
element.pids = res[0].pids;
|
||||
element.netIO = res[0].netIO;
|
||||
element.blockIO = res[0].blockIO;
|
||||
element.cpu_stats = res[0].cpu_stats;
|
||||
element.precpu_stats = res[0].precpu_stats;
|
||||
element.memory_stats = res[0].memory_stats;
|
||||
element.cpuStats = res[0].cpuStats;
|
||||
element.precpuStats = res[0].precpuStats;
|
||||
element.memoryStats = res[0].memoryStats;
|
||||
element.networks = res[0].networks;
|
||||
|
||||
dockerContainerProcesses(element.id).then(processes => {
|
||||
|
||||
+10
-10
@@ -54,16 +54,16 @@ function fsSize(callback) {
|
||||
line = line.replace(/ +/g, ' ').split(' ');
|
||||
if (line && ((line[0].startsWith('/')) || (line[6] && line[6] === '/') || (line[0].indexOf('/') > 0))) {
|
||||
const fs = line[0];
|
||||
const fstype = ((_linux || _freebsd || _openbsd || _netbsd) ? line[1] : getmacOsFsType(line[0]));
|
||||
const fsType = ((_linux || _freebsd || _openbsd || _netbsd) ? line[1] : getmacOsFsType(line[0]));
|
||||
const size = parseInt(((_linux || _freebsd || _openbsd || _netbsd) ? line[2] : line[1])) * 1024;
|
||||
const used = parseInt(((_linux || _freebsd || _openbsd || _netbsd) ? line[3] : line[2])) * 1024;
|
||||
const available = parseInt(((_linux || _freebsd || _openbsd || _netbsd) ? line[4] : line[3])) * 1024;
|
||||
const use = parseFloat((100.0 * (used / (used + available))).toFixed(2));
|
||||
const mount = line[line.length - 1];
|
||||
if (!data.find(el => (el.fs === fs && el.type === fstype))) {
|
||||
if (!data.find(el => (el.fs === fs && el.type === fsType))) {
|
||||
data.push({
|
||||
fs,
|
||||
type: fstype,
|
||||
type: fsType,
|
||||
size,
|
||||
used,
|
||||
available,
|
||||
@@ -233,7 +233,7 @@ function parseDevices(lines) {
|
||||
name: '',
|
||||
identifier: '',
|
||||
type: 'disk',
|
||||
fstype: '',
|
||||
fsType: '',
|
||||
mount: '',
|
||||
size: 0,
|
||||
physical: 'HDD',
|
||||
@@ -253,7 +253,7 @@ function parseDevices(lines) {
|
||||
}
|
||||
if ('PROTOCOL' === parts[0]) devices[i].protocol = parts[1];
|
||||
if ('DISKSIZE' === parts[0]) devices[i].size = parseBytes(parts[1]);
|
||||
if ('FILESYSTEMPERSONALITY' === parts[0]) devices[i].fstype = parts[1];
|
||||
if ('FILESYSTEMPERSONALITY' === parts[0]) devices[i].fsType = parts[1];
|
||||
if ('MOUNTPOINT' === parts[0]) devices[i].mount = parts[1];
|
||||
if ('VOLUMEUUID' === parts[0]) devices[i].uuid = parts[1];
|
||||
if ('READ-ONLYMEDIA' === parts[0] && parts[1] === 'Yes') devices[i].physical = 'CD/DVD';
|
||||
@@ -280,7 +280,7 @@ function parseBlk(lines) {
|
||||
data.push({
|
||||
'name': disk.name,
|
||||
'type': disk.type,
|
||||
'fstype': disk.fstype,
|
||||
'fsType': disk.fsType,
|
||||
'mount': disk.mountpoint,
|
||||
'size': parseInt(disk.size),
|
||||
'physical': (disk.type === 'disk' ? (disk.rota === '0' ? 'SSD' : 'HDD') : (disk.type === 'rom' ? 'CD/DVD' : '')),
|
||||
@@ -304,7 +304,7 @@ function parseBlk(lines) {
|
||||
function blkStdoutToObject(stdout) {
|
||||
return stdout.toString()
|
||||
.replace(/NAME=/g, '{"name":')
|
||||
.replace(/FSTYPE=/g, ',"fstype":')
|
||||
.replace(/FSTYPE=/g, ',"fsType":')
|
||||
.replace(/TYPE=/g, ',"type":')
|
||||
.replace(/SIZE=/g, ',"size":')
|
||||
.replace(/MOUNTPOINT=/g, ',"mountpoint":')
|
||||
@@ -382,7 +382,7 @@ function blockDevices(callback) {
|
||||
name: util.getValue(lines, 'name', '='),
|
||||
identifier: util.getValue(lines, 'caption', '='),
|
||||
type: 'disk',
|
||||
fstype: util.getValue(lines, 'filesystem', '=').toLowerCase(),
|
||||
fsType: util.getValue(lines, 'filesystem', '=').toLowerCase(),
|
||||
mount: util.getValue(lines, 'caption', '='),
|
||||
size: util.getValue(lines, 'size', '='),
|
||||
physical: (drivetype >= 0 && drivetype <= 6) ? drivetypes[drivetype] : drivetypes[0],
|
||||
@@ -770,14 +770,14 @@ function diskLayout(callback) {
|
||||
try {
|
||||
const outJSON = JSON.parse(out);
|
||||
if (outJSON && {}.hasOwnProperty.call(outJSON, 'blockdevices')) {
|
||||
devices = outJSON.blockdevices.filter(item => { return (item.group === 'disk' || item.type === 'disk') && item.size > 0 && (item.model !== null || (item.mountpoint === null && item.label === null && item.fstype === null && item.parttype === null)); });
|
||||
devices = outJSON.blockdevices.filter(item => { return (item.group === 'disk' || item.type === 'disk') && item.size > 0 && (item.model !== null || (item.mountpoint === null && item.label === null && item.fsType === null && item.parttype === null)); });
|
||||
}
|
||||
} catch (e) {
|
||||
// fallback to older version of lsblk
|
||||
const out2 = execSync('export LC_ALL=C; lsblk -bPo NAME,TYPE,SIZE,FSTYPE,MOUNTPOINT,UUID,ROTA,RO,RM,LABEL,MODEL,OWNER,GROUP 2>/dev/null; unset LC_ALL').toString();
|
||||
let lines = blkStdoutToObject(out2).split('\n');
|
||||
const data = parseBlk(lines);
|
||||
devices = data.filter(item => { return (item.group === 'disk' || item.type === 'disk') && item.size > 0 && ((item.model !== null && item.model !== '') || (item.mountpoint === '' && item.label === '' && item.fstype === '')); });
|
||||
devices = data.filter(item => { return (item.group === 'disk' || item.type === 'disk') && item.size > 0 && ((item.model !== null && item.model !== '') || (item.mountpoint === '' && item.label === '' && item.fsType === '')); });
|
||||
}
|
||||
devices.forEach((device) => {
|
||||
let mediumType = '';
|
||||
|
||||
+86
-86
@@ -30,10 +30,10 @@ const _openbsd = (_platform === 'openbsd');
|
||||
const _netbsd = (_platform === 'netbsd');
|
||||
const _sunos = (_platform === 'sunos');
|
||||
|
||||
let _resolutionx = 0;
|
||||
let _resolutiony = 0;
|
||||
let _pixeldepth = 0;
|
||||
let _refreshrate = 0;
|
||||
let _resolutionX = 0;
|
||||
let _resolutionY = 0;
|
||||
let _pixelDepth = 0;
|
||||
let _refreshRate = 0;
|
||||
|
||||
const videoTypes = {
|
||||
'-2': 'UNINITIALIZED',
|
||||
@@ -78,11 +78,11 @@ function graphics(callback) {
|
||||
main: false,
|
||||
builtin: false,
|
||||
connection: '',
|
||||
sizex: null,
|
||||
sizey: null,
|
||||
pixeldepth: null,
|
||||
resolutionx: null,
|
||||
resolutiony: null,
|
||||
sizeX: null,
|
||||
sizeY: null,
|
||||
pixelDepth: null,
|
||||
resolutionX: null,
|
||||
resolutionY: null,
|
||||
currentResX: null,
|
||||
currentResY: null,
|
||||
positionX: 0,
|
||||
@@ -116,11 +116,11 @@ function graphics(callback) {
|
||||
main: false,
|
||||
builtin: false,
|
||||
connection: '',
|
||||
sizex: null,
|
||||
sizey: null,
|
||||
pixeldepth: null,
|
||||
resolutionx: null,
|
||||
resolutiony: null,
|
||||
sizeX: null,
|
||||
sizeY: null,
|
||||
pixelDepth: null,
|
||||
resolutionX: null,
|
||||
resolutionY: null,
|
||||
currentResX: null,
|
||||
currentResY: null,
|
||||
positionX: 0,
|
||||
@@ -162,23 +162,23 @@ function graphics(callback) {
|
||||
currentDisplay.main = false;
|
||||
currentDisplay.builtin = false;
|
||||
currentDisplay.connection = '';
|
||||
currentDisplay.sizex = null;
|
||||
currentDisplay.sizey = null;
|
||||
currentDisplay.sizeX = null;
|
||||
currentDisplay.sizeY = null;
|
||||
currentDisplay.positionX = 0;
|
||||
currentDisplay.positionY = 0;
|
||||
currentDisplay.pixeldepth = null;
|
||||
currentDisplay.pixelDepth = null;
|
||||
}
|
||||
}
|
||||
if (4 === level) { // display controller details level
|
||||
if (parts.length > 1 && parts[0].replace(/ +/g, '').toLowerCase().indexOf('resolution') !== -1) {
|
||||
let resolution = parts[1].split('x');
|
||||
currentDisplay.resolutionx = (resolution.length > 1 ? parseInt(resolution[0]) : 0);
|
||||
currentDisplay.resolutiony = (resolution.length > 1 ? parseInt(resolution[1]) : 0);
|
||||
currentDisplay.currentResX = currentDisplay.resolutionx;
|
||||
currentDisplay.currentResY = currentDisplay.resolutiony;
|
||||
currentDisplay.resolutionX = (resolution.length > 1 ? parseInt(resolution[0]) : 0);
|
||||
currentDisplay.resolutionY = (resolution.length > 1 ? parseInt(resolution[1]) : 0);
|
||||
currentDisplay.currentResX = currentDisplay.resolutionX;
|
||||
currentDisplay.currentResY = currentDisplay.resolutionY;
|
||||
}
|
||||
if (parts.length > 1 && parts[0].replace(/ +/g, '').toLowerCase().indexOf('pixeldepth') !== -1) currentDisplay.pixeldepth = parseInt(parts[1]); // in BIT
|
||||
if (parts.length > 1 && parts[0].replace(/ +/g, '').toLowerCase().indexOf('framebufferdepth') !== -1) currentDisplay.pixeldepth = parseInt(parts[1]); // in BIT
|
||||
if (parts.length > 1 && parts[0].replace(/ +/g, '').toLowerCase().indexOf('pixeldepth') !== -1) currentDisplay.pixelDepth = parseInt(parts[1]); // in BIT
|
||||
if (parts.length > 1 && parts[0].replace(/ +/g, '').toLowerCase().indexOf('framebufferdepth') !== -1) currentDisplay.pixelDepth = parseInt(parts[1]); // in BIT
|
||||
if (parts.length > 1 && parts[0].replace(/ +/g, '').toLowerCase().indexOf('maindisplay') !== -1 && parts[1].replace(/ +/g, '').toLowerCase() === 'yes') currentDisplay.main = true;
|
||||
if (parts.length > 1 && parts[0].replace(/ +/g, '').toLowerCase().indexOf('built-in') !== -1 && parts[1].replace(/ +/g, '').toLowerCase() === 'yes') {
|
||||
currentDisplay.vendor = 'Apple';
|
||||
@@ -505,11 +505,11 @@ function graphics(callback) {
|
||||
main: false,
|
||||
builtin: false,
|
||||
connection: '',
|
||||
sizex: null,
|
||||
sizey: null,
|
||||
pixeldepth: null,
|
||||
resolutionx: null,
|
||||
resolutiony: null,
|
||||
sizeX: null,
|
||||
sizeY: null,
|
||||
pixelDepth: null,
|
||||
resolutionX: null,
|
||||
resolutionY: null,
|
||||
currentResX: null,
|
||||
currentResY: null,
|
||||
positionX: 0,
|
||||
@@ -530,10 +530,10 @@ function graphics(callback) {
|
||||
if (edid.substr(start, 6) === '000000') {
|
||||
start += 36;
|
||||
}
|
||||
result.resolutionx = parseInt('0x0' + edid.substr(start + 8, 1) + edid.substr(start + 4, 2));
|
||||
result.resolutiony = parseInt('0x0' + edid.substr(start + 14, 1) + edid.substr(start + 10, 2));
|
||||
result.sizex = parseInt('0x0' + edid.substr(start + 28, 1) + edid.substr(start + 24, 2));
|
||||
result.sizey = parseInt('0x0' + edid.substr(start + 29, 1) + edid.substr(start + 26, 2));
|
||||
result.resolutionX = parseInt('0x0' + edid.substr(start + 8, 1) + edid.substr(start + 4, 2));
|
||||
result.resolutionX = parseInt('0x0' + edid.substr(start + 14, 1) + edid.substr(start + 10, 2));
|
||||
result.sizeX = parseInt('0x0' + edid.substr(start + 28, 1) + edid.substr(start + 24, 2));
|
||||
result.sizeY = parseInt('0x0' + edid.substr(start + 29, 1) + edid.substr(start + 26, 2));
|
||||
// monitor name
|
||||
start = edid.indexOf('000000fc00'); // find first "Monitor Description Data"
|
||||
if (start >= 0) {
|
||||
@@ -565,11 +565,11 @@ function graphics(callback) {
|
||||
main: false,
|
||||
builtin: false,
|
||||
connection: '',
|
||||
sizex: null,
|
||||
sizey: null,
|
||||
pixeldepth: null,
|
||||
resolutionx: null,
|
||||
resolutiony: null,
|
||||
sizeX: null,
|
||||
sizeY: null,
|
||||
pixelDepth: null,
|
||||
resolutionX: null,
|
||||
resolutionY: null,
|
||||
currentResX: null,
|
||||
currentResY: null,
|
||||
positionX: 0,
|
||||
@@ -583,7 +583,7 @@ function graphics(callback) {
|
||||
for (let i = 1; i < lines.length; i++) { // start with second line
|
||||
if ('' !== lines[i].trim()) {
|
||||
if (' ' !== lines[i][0] && '\t' !== lines[i][0] && lines[i].toLowerCase().indexOf(' connected ') !== -1) { // first line of new entry
|
||||
if (currentDisplay.model || currentDisplay.main || currentDisplay.builtin || currentDisplay.connection || currentDisplay.sizex !== -1 || currentDisplay.pixeldepth !== -1 || currentDisplay.resolutionx !== -1) { // push last display to array
|
||||
if (currentDisplay.model || currentDisplay.main || currentDisplay.builtin || currentDisplay.connection || currentDisplay.sizeX !== null || currentDisplay.pixelDepth !== null || currentDisplay.resolutionX !== null) { // push last display to array
|
||||
displays.push(currentDisplay);
|
||||
currentDisplay = {
|
||||
vendor: '',
|
||||
@@ -591,11 +591,11 @@ function graphics(callback) {
|
||||
main: false,
|
||||
builtin: false,
|
||||
connection: '',
|
||||
sizex: null,
|
||||
sizey: null,
|
||||
pixeldepth: null,
|
||||
resolutionx: null,
|
||||
resolutiony: null,
|
||||
sizeX: null,
|
||||
sizeY: null,
|
||||
pixelDepth: null,
|
||||
resolutionX: null,
|
||||
resolutionY: null,
|
||||
currentResX: null,
|
||||
currentResY: null,
|
||||
positionX: 0,
|
||||
@@ -618,11 +618,11 @@ function graphics(callback) {
|
||||
let edid_decoded = parseLinesLinuxEdid(edid_raw);
|
||||
currentDisplay.vendor = edid_decoded.vendor;
|
||||
currentDisplay.model = edid_decoded.model;
|
||||
currentDisplay.resolutionx = edid_decoded.resolutionx;
|
||||
currentDisplay.resolutiony = edid_decoded.resolutiony;
|
||||
currentDisplay.sizex = edid_decoded.sizex;
|
||||
currentDisplay.sizey = edid_decoded.sizey;
|
||||
currentDisplay.pixeldepth = depth;
|
||||
currentDisplay.resolutionX = edid_decoded.resolutionX;
|
||||
currentDisplay.resolutionY = edid_decoded.resolutionY;
|
||||
currentDisplay.sizeX = edid_decoded.sizeX;
|
||||
currentDisplay.sizeY = edid_decoded.sizeY;
|
||||
currentDisplay.pixelDepth = depth;
|
||||
is_edid = false;
|
||||
}
|
||||
}
|
||||
@@ -650,7 +650,7 @@ function graphics(callback) {
|
||||
}
|
||||
|
||||
// pushen displays
|
||||
if (currentDisplay.model || currentDisplay.main || currentDisplay.builtin || currentDisplay.connection || currentDisplay.sizex !== -1 || currentDisplay.pixeldepth !== -1 || currentDisplay.resolutionx !== -1) { // still information there
|
||||
if (currentDisplay.model || currentDisplay.main || currentDisplay.builtin || currentDisplay.connection || currentDisplay.sizeX !== null || currentDisplay.pixelDepth !== null || currentDisplay.resolutionX !== null) { // still information there
|
||||
displays.push(currentDisplay);
|
||||
}
|
||||
return displays;
|
||||
@@ -691,11 +691,11 @@ function graphics(callback) {
|
||||
main: true,
|
||||
builtin: false,
|
||||
connection: 'HDMI',
|
||||
sizex: null,
|
||||
sizey: null,
|
||||
pixeldepth: null,
|
||||
resolutionx: parseInt(parts[0], 10),
|
||||
resolutiony: parseInt(parts[1], 10),
|
||||
sizeX: null,
|
||||
sizeY: null,
|
||||
pixelDepth: null,
|
||||
resolutionX: parseInt(parts[0], 10),
|
||||
resolutionY: parseInt(parts[1], 10),
|
||||
currentResX: null,
|
||||
currentResY: null,
|
||||
positionX: 0,
|
||||
@@ -847,23 +847,23 @@ function graphics(callback) {
|
||||
result.displays = parseLinesWindowsDisplaysPowershell(ssections, msections, dsections, tsections, isections);
|
||||
|
||||
if (result.displays.length === 1) {
|
||||
if (_resolutionx) {
|
||||
result.displays[0].resolutionx = _resolutionx;
|
||||
if (_resolutionX) {
|
||||
result.displays[0].resolutionX = _resolutionX;
|
||||
if (!result.displays[0].currentResX) {
|
||||
result.displays[0].currentResX = _resolutionx;
|
||||
result.displays[0].currentResX = _resolutionX;
|
||||
}
|
||||
}
|
||||
if (_resolutiony) {
|
||||
result.displays[0].resolutiony = _resolutiony;
|
||||
if (_resolutionY) {
|
||||
result.displays[0].resolutionY = _resolutionY;
|
||||
if (result.displays[0].currentResY === 0) {
|
||||
result.displays[0].currentResY = _resolutiony;
|
||||
result.displays[0].currentResY = _resolutionY;
|
||||
}
|
||||
}
|
||||
if (_pixeldepth) {
|
||||
result.displays[0].pixeldepth = _pixeldepth;
|
||||
if (_pixelDepth) {
|
||||
result.displays[0].pixelDepth = _pixelDepth;
|
||||
}
|
||||
if (_refreshrate && !result.displays[0].refreshrate) {
|
||||
result.displays[0].currentRefreshRate = _refreshrate;
|
||||
if (_refreshRate && !result.displays[0].refreshRate) {
|
||||
result.displays[0].currentRefreshRate = _refreshRate;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -909,10 +909,10 @@ function graphics(callback) {
|
||||
vramDynamic: (util.getValue(lines, 'VideoMemoryType', '=') === '2'),
|
||||
subDeviceId
|
||||
});
|
||||
_resolutionx = util.toInt(util.getValue(lines, 'CurrentHorizontalResolution', '=')) || _resolutionx;
|
||||
_resolutiony = util.toInt(util.getValue(lines, 'CurrentVerticalResolution', '=')) || _resolutiony;
|
||||
_refreshrate = util.toInt(util.getValue(lines, 'CurrentRefreshRate', '=')) || _refreshrate;
|
||||
_pixeldepth = util.toInt(util.getValue(lines, 'CurrentBitsPerPixel', '=')) || _pixeldepth;
|
||||
_resolutionX = util.toInt(util.getValue(lines, 'CurrentHorizontalResolution', '=')) || _resolutionX;
|
||||
_resolutionY = util.toInt(util.getValue(lines, 'CurrentVerticalResolution', '=')) || _resolutionY;
|
||||
_refreshRate = util.toInt(util.getValue(lines, 'CurrentRefreshRate', '=')) || _refreshRate;
|
||||
_pixelDepth = util.toInt(util.getValue(lines, 'CurrentBitsPerPixel', '=')) || _pixelDepth;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -924,15 +924,15 @@ function graphics(callback) {
|
||||
let vendor = '';
|
||||
let model = '';
|
||||
let deviceID = '';
|
||||
let resolutionx = 0;
|
||||
let resolutiony = 0;
|
||||
let resolutionX = 0;
|
||||
let resolutionY = 0;
|
||||
if (dsections && dsections.length) {
|
||||
let linesDisplay = dsections[0].split(os.EOL);
|
||||
vendor = util.getValue(linesDisplay, 'MonitorManufacturer', '=');
|
||||
model = util.getValue(linesDisplay, 'Name', '=');
|
||||
deviceID = util.getValue(linesDisplay, 'PNPDeviceID', '=').replace(/&/g, '&').toLowerCase();
|
||||
resolutionx = util.toInt(util.getValue(linesDisplay, 'ScreenWidth', '='));
|
||||
resolutiony = util.toInt(util.getValue(linesDisplay, 'ScreenHeight', '='));
|
||||
resolutionX = util.toInt(util.getValue(linesDisplay, 'ScreenWidth', '='));
|
||||
resolutionY = util.toInt(util.getValue(linesDisplay, 'ScreenHeight', '='));
|
||||
}
|
||||
for (let i = 0; i < ssections.length; i++) {
|
||||
if (ssections[i].trim() !== '') {
|
||||
@@ -950,8 +950,8 @@ function graphics(callback) {
|
||||
const bitsPerPixel = util.getValue(linesScreen, 'BitsPerPixel');
|
||||
const bounds = util.getValue(linesScreen, 'Bounds').replace('{', '').replace('}', '').split(',');
|
||||
const primary = util.getValue(linesScreen, 'Primary');
|
||||
const sizex = util.getValue(linesMonitor, 'MaxHorizontalImageSize');
|
||||
const sizey = util.getValue(linesMonitor, 'MaxVerticalImageSize');
|
||||
const sizeX = util.getValue(linesMonitor, 'MaxHorizontalImageSize');
|
||||
const sizeY = util.getValue(linesMonitor, 'MaxVerticalImageSize');
|
||||
const instanceName = util.getValue(linesMonitor, 'InstanceName').toLowerCase();
|
||||
const videoOutputTechnology = util.getValue(linesConnection, 'VideoOutputTechnology');
|
||||
const deviceName = util.getValue(linesScreen, 'DeviceName');
|
||||
@@ -970,11 +970,11 @@ function graphics(callback) {
|
||||
main: primary.toLowerCase() === 'true',
|
||||
builtin: videoOutputTechnology === '2147483648',
|
||||
connection: videoOutputTechnology && videoTypes[videoOutputTechnology] ? videoTypes[videoOutputTechnology] : '',
|
||||
resolutionx: util.toInt(util.getValue(bounds, 'Width', '=')),
|
||||
resolutiony: util.toInt(util.getValue(bounds, 'Height', '=')),
|
||||
sizex: sizex ? parseInt(sizex, 10) : null,
|
||||
sizey: sizey ? parseInt(sizey, 10) : null,
|
||||
pixeldepth: bitsPerPixel,
|
||||
resolutionX: util.toInt(util.getValue(bounds, 'Width', '=')),
|
||||
resolutionY: util.toInt(util.getValue(bounds, 'Height', '=')),
|
||||
sizeX: sizeX ? parseInt(sizeX, 10) : null,
|
||||
sizeY: sizeY ? parseInt(sizeY, 10) : null,
|
||||
pixelDepth: bitsPerPixel,
|
||||
currentResX: util.toInt(util.getValue(bounds, 'Width', '=')),
|
||||
currentResY: util.toInt(util.getValue(bounds, 'Height', '=')),
|
||||
positionX: util.toInt(util.getValue(bounds, 'X', '=')),
|
||||
@@ -987,13 +987,13 @@ function graphics(callback) {
|
||||
vendor,
|
||||
model,
|
||||
main: true,
|
||||
resolutionx,
|
||||
resolutiony,
|
||||
sizex: null,
|
||||
sizey: null,
|
||||
pixeldepth: null,
|
||||
currentResX: resolutionx,
|
||||
currentResY: resolutiony,
|
||||
sizeX: null,
|
||||
sizeY: null,
|
||||
resolutionX,
|
||||
resolutionY,
|
||||
pixelDepth: null,
|
||||
currentResX: resolutionX,
|
||||
currentResY: resolutionY,
|
||||
positionX: 0,
|
||||
positionY: 0
|
||||
});
|
||||
|
||||
Vendored
+59
-59
@@ -228,17 +228,17 @@ export namespace Systeminformation {
|
||||
}
|
||||
|
||||
interface BatteryData {
|
||||
hasbattery: boolean;
|
||||
cyclecount: number;
|
||||
ischarging: boolean;
|
||||
hasBattery: boolean;
|
||||
cycleCount: number;
|
||||
isCharging: boolean;
|
||||
voltage: number;
|
||||
designedcapacity: number;
|
||||
maxcapacity: number;
|
||||
currentcapacity: number;
|
||||
designedCapacity: number;
|
||||
maxCapacity: number;
|
||||
currentCapacity: number;
|
||||
capacityUnit: string;
|
||||
percent: number;
|
||||
timeremaining: number,
|
||||
acconnected: boolean;
|
||||
timeRemaining: number,
|
||||
acConnected: boolean;
|
||||
type: string;
|
||||
model: string;
|
||||
manufacturer: string;
|
||||
@@ -282,11 +282,11 @@ export namespace Systeminformation {
|
||||
main: boolean;
|
||||
builtin: boolean;
|
||||
connection: string;
|
||||
sizex: number;
|
||||
sizey: number;
|
||||
pixeldepth: number;
|
||||
resolutionx: number;
|
||||
resolutiony: number;
|
||||
sizeX: number;
|
||||
sizeY: number;
|
||||
pixelDepth: number;
|
||||
resolutionX: number;
|
||||
resolutionY: number;
|
||||
currentResX: number;
|
||||
currentResY: number;
|
||||
positionX: number;
|
||||
@@ -381,7 +381,7 @@ export namespace Systeminformation {
|
||||
name: string;
|
||||
identifier: string;
|
||||
type: string;
|
||||
fstype: string;
|
||||
fsType: string;
|
||||
mount: string;
|
||||
size: number;
|
||||
physical: string;
|
||||
@@ -453,10 +453,10 @@ export namespace Systeminformation {
|
||||
|
||||
interface NetworkConnectionsData {
|
||||
protocol: string;
|
||||
localaddress: string;
|
||||
localport: string;
|
||||
peeraddress: string;
|
||||
peerport: string;
|
||||
localAddress: string;
|
||||
localPort: string;
|
||||
peerAddress: string;
|
||||
peerPort: string;
|
||||
state: string;
|
||||
pid: number;
|
||||
process: string;
|
||||
@@ -485,35 +485,35 @@ export namespace Systeminformation {
|
||||
// 7. Current Load, Processes & Services
|
||||
|
||||
interface CurrentLoadData {
|
||||
avgload: number;
|
||||
currentload: number;
|
||||
currentload_user: number;
|
||||
currentload_system: number;
|
||||
currentload_nice: number;
|
||||
currentload_idle: number;
|
||||
currentload_irq: number;
|
||||
raw_currentload: number;
|
||||
raw_currentload_user: number;
|
||||
raw_currentload_system: number;
|
||||
raw_currentload_nice: number;
|
||||
raw_currentload_idle: number;
|
||||
raw_currentload_irq: number;
|
||||
avgLoad: number;
|
||||
currentLoad: number;
|
||||
currentLoadUser: number;
|
||||
currentLoadSystem: number;
|
||||
currentLoadNice: number;
|
||||
currentLoadIdle: number;
|
||||
currentLoadIrq: number;
|
||||
rawCurrentLoad: number;
|
||||
rawCurrentLoadUser: number;
|
||||
rawCurrentLoadSystem: number;
|
||||
rawCurrentLoadNice: number;
|
||||
rawCurrentLoadIdle: number;
|
||||
rawCurrentLoadIrq: number;
|
||||
cpus: CurrentLoadCpuData[];
|
||||
}
|
||||
|
||||
interface CurrentLoadCpuData {
|
||||
load: number;
|
||||
load_user: number;
|
||||
load_system: number;
|
||||
load_nice: number;
|
||||
load_idle: number;
|
||||
load_irq: number;
|
||||
raw_load: number;
|
||||
raw_load_user: number;
|
||||
raw_load_system: number;
|
||||
raw_load_nice: number;
|
||||
raw_load_idle: number;
|
||||
raw_load_irq: number;
|
||||
loadUser: number;
|
||||
loadSystem: number;
|
||||
loadNice: number;
|
||||
loadIdle: number;
|
||||
loadIrq: number;
|
||||
rawLoad: number;
|
||||
rawLoadUser: number;
|
||||
rawLoadSystem: number;
|
||||
rawLoadNice: number;
|
||||
rawLoadIdle: number;
|
||||
rawLoadIrq: number;
|
||||
}
|
||||
|
||||
interface ProcessesData {
|
||||
@@ -534,8 +534,8 @@ export namespace Systeminformation {
|
||||
pcpus: number;
|
||||
pmem: number;
|
||||
priority: number;
|
||||
mem_vsz: number;
|
||||
mem_rss: number;
|
||||
memVsz: number;
|
||||
memRss: number;
|
||||
nice: number;
|
||||
started: string,
|
||||
state: string;
|
||||
@@ -645,10 +645,10 @@ export namespace Systeminformation {
|
||||
|
||||
interface DockerContainerStatsData {
|
||||
id: string;
|
||||
mem_usage: number;
|
||||
mem_limit: number;
|
||||
mem_percent: number;
|
||||
cpu_percent: number;
|
||||
memUsage: number;
|
||||
memLimit: number;
|
||||
memPercent: number;
|
||||
cpuPercent: number;
|
||||
netIO: {
|
||||
rx: number;
|
||||
wx: number;
|
||||
@@ -658,9 +658,9 @@ export namespace Systeminformation {
|
||||
w: number;
|
||||
};
|
||||
restartCount: number;
|
||||
cpu_stats: any;
|
||||
precpu_stats: any;
|
||||
memory_stats: any,
|
||||
cpuStats: any;
|
||||
precpuStats: any;
|
||||
memoryStats: any,
|
||||
networks: any;
|
||||
}
|
||||
|
||||
@@ -687,22 +687,22 @@ export namespace Systeminformation {
|
||||
configFile: string;
|
||||
snapshotFolder: string;
|
||||
logFolder: string;
|
||||
HPET: boolean;
|
||||
PAE: boolean;
|
||||
hpet: boolean;
|
||||
pae: boolean;
|
||||
longMode: boolean;
|
||||
tripleFaultReset: boolean;
|
||||
APIC: boolean;
|
||||
X2APIC: boolean;
|
||||
ACPI: boolean;
|
||||
IOAPIC: boolean;
|
||||
biosAPICmode: string;
|
||||
apic: boolean;
|
||||
x2Apic: boolean;
|
||||
acpi: boolean;
|
||||
ioApic: boolean;
|
||||
biosApicMode: string;
|
||||
bootMenuMode: string;
|
||||
bootDevice1: string;
|
||||
bootDevice2: string;
|
||||
bootDevice3: string;
|
||||
bootDevice4: string;
|
||||
timeOffset: string;
|
||||
RTC: string;
|
||||
rtc: string;
|
||||
}
|
||||
|
||||
interface PrinterData {
|
||||
|
||||
+3
-3
@@ -181,8 +181,8 @@ function getDynamicData(srv, iface, callback) {
|
||||
data.node = process.versions.node;
|
||||
data.v8 = process.versions.v8;
|
||||
|
||||
cpu.cpuCurrentspeed().then(res => {
|
||||
data.cpuCurrentspeed = res;
|
||||
cpu.cpuCurrentSpeed().then(res => {
|
||||
data.cpuCurrentSpeed = res;
|
||||
functionProcessed();
|
||||
});
|
||||
|
||||
@@ -445,7 +445,7 @@ exports.uuid = osInfo.uuid;
|
||||
exports.cpu = cpu.cpu;
|
||||
exports.cpuFlags = cpu.cpuFlags;
|
||||
exports.cpuCache = cpu.cpuCache;
|
||||
exports.cpuCurrentspeed = cpu.cpuCurrentspeed;
|
||||
exports.cpuCurrentSpeed = cpu.cpuCurrentSpeed;
|
||||
exports.cpuTemperature = cpu.cpuTemperature;
|
||||
exports.currentLoad = cpu.currentLoad;
|
||||
exports.fullLoad = cpu.fullLoad;
|
||||
|
||||
+6
-6
@@ -564,8 +564,8 @@ function processes(callback) {
|
||||
pcpus: 0,
|
||||
pmem: pmem,
|
||||
priority: priority,
|
||||
mem_vsz: vsz,
|
||||
mem_rss: rss,
|
||||
memVsz: vsz,
|
||||
memRss: rss,
|
||||
nice: nice,
|
||||
started: started,
|
||||
state: state,
|
||||
@@ -623,8 +623,8 @@ function processes(callback) {
|
||||
pcpus: 0,
|
||||
pmem: pmem,
|
||||
priority: 0,
|
||||
mem_vsz: parseInt(parts[2]),
|
||||
mem_rss: parseInt(parts[3]),
|
||||
memVsz: parseInt(parts[2]),
|
||||
memRss: parseInt(parts[3]),
|
||||
nice: parseInt(parts[4]),
|
||||
started: started,
|
||||
state: (parts[6] === 'R' ? 'running' : (parts[6] === 'S' ? 'sleeping' : (parts[6] === 'T' ? 'stopped' : (parts[6] === 'W' ? 'paging' : (parts[6] === 'X' ? 'dead' : (parts[6] === 'Z' ? 'zombie' : ((parts[6] === 'D' || parts[6] === 'U') ? 'blocked' : 'unknown'))))))),
|
||||
@@ -800,8 +800,8 @@ function processes(callback) {
|
||||
pcpus: 0,
|
||||
pmem: mem / os.totalmem() * 100,
|
||||
priority: parseInt(util.getValue(lines, 'Priority', '=', true), 10),
|
||||
mem_vsz: parseInt(util.getValue(lines, 'PageFileUsage', '=', true), 10),
|
||||
mem_rss: Math.floor(parseInt(util.getValue(lines, 'WorkingSetSize', '=', true), 10) / 1024),
|
||||
memVsz: parseInt(util.getValue(lines, 'PageFileUsage', '=', true), 10),
|
||||
memRss: Math.floor(parseInt(util.getValue(lines, 'WorkingSetSize', '=', true), 10) / 1024),
|
||||
nice: 0,
|
||||
started: parseTimeWin(util.getValue(lines, 'CreationDate', '=', true)),
|
||||
state: (!statusValue ? _winStatusValues[0] : _winStatusValues[statusValue]),
|
||||
|
||||
+8
-8
@@ -74,22 +74,22 @@ function vboxInfo(callback) {
|
||||
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',
|
||||
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'),
|
||||
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'),
|
||||
rtc: util.getValue(lines, 'RTC'),
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user