first partial FreeBSD support

This commit is contained in:
Sebastian Hildebrandt
2018-02-10 19:19:53 +01:00
parent 42b7f6c42e
commit c22cdad6da
17 changed files with 827 additions and 545 deletions
+37 -25
View File
@@ -12,16 +12,17 @@
// 6. Battery
// ----------------------------------------------------------------------------------
const os = require('os');
const exec = require('child_process').exec;
const fs = require('fs');
const util = require('./util');
let _platform = os.type();
let _platform = process.platform;
const _linux = (_platform === 'Linux');
const _darwin = (_platform === 'Darwin');
const _windows = (_platform === 'Windows_NT');
const _linux = (_platform === 'linux');
const _darwin = (_platform === 'darwin');
const _windows = (_platform === 'win32');
const _freebsd = (_platform === 'freebsd');
const _openbsd = (_platform === 'openbsd');
module.exports = function (callback) {
@@ -79,30 +80,41 @@ module.exports = function (callback) {
resolve(result);
}
}
if (_freebsd || _openbsd) {
exec('sysctl hw.acpi.battery hw.acpi.acline', function (error, stdout) {
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 = -1;
result.ischarging = util.getValue(lines,'hw.acpi.acline') !== '1';
result.maxcapacity = -1;
result.currentcapacity = -1;
result.percent = batteries ? percent : -1;
if (callback) { callback(result); }
resolve(result);
});
}
if (_darwin) {
exec("ioreg -n AppleSmartBattery -r | grep '\"CycleCount\"';ioreg -n AppleSmartBattery -r | grep '\"IsCharging\"';ioreg -n AppleSmartBattery -r | grep '\"MaxCapacity\"';ioreg -n AppleSmartBattery -r | grep '\"CurrentCapacity\"';pmset -g batt | grep %", function (error, stdout) {
if (!error) {
let lines = stdout.toString().replace(/ +/g, '').replace(/"+/g, '').split('\n');
lines.forEach(function (line) {
if (line.indexOf('=') !== -1) {
if (line.toLowerCase().indexOf('cyclecount') !== -1) result.cyclecount = parseFloat(line.split('=')[1].trim());
if (line.toLowerCase().indexOf('ischarging') !== -1) result.ischarging = (line.split('=')[1].trim().toLowerCase() === 'yes');
if (line.toLowerCase().indexOf('maxcapacity') !== -1) result.maxcapacity = parseFloat(line.split('=')[1].trim());
if (line.toLowerCase().indexOf('internalbattery') !== -1) {
let parts = line.split(';');
if (parts && parts[0]) {
let parts2 = parts[0].split('\t');
if (parts2 && parts2[1]) {
result.percent = parseFloat(parts2[1].trim().replace('%', ''));
}
}
}
}
});
exec('ioreg -n AppleSmartBattery -r | egrep "CycleCount|IsCharging|MaxCapacity|CurrentCapacity";pmset -g batt | grep %', function (error, stdout) {
let lines = stdout.toString().replace(/ +/g, '').replace(/"+/g, '').replace(/-/g, '').split('\n');
result.cyclecount = parseInt('0' + util.getValue(lines,'cyclecount', '='), 10);
result.ischarging = util.getValue(lines,'ischarging', '=').toLowerCase === 'yes';
result.maxcapacity = parseInt('0' + util.getValue(lines,'maxcapacity', '='), 10);
result.currentcapacity = parseInt('0' + util.getValue(lines,'currentcapacity', '='), 10);
let percent = -1;
const line = util.getValue(lines,'internalbattery', '=');
let parts = line.split(';');
if (parts && parts[0]) {
let parts2 = parts[0].split('\t');
if (parts2 && parts2[1]) {
percent = parseFloat(parts2[1].trim().replace('%', ''));
}
}
if (result.maxcapacity && result.currentcapacity) {
result.hasbattery = true;
result.percent = 100.0 * result.currentcapacity / result.maxcapacity;
result.percent = percent !== -1 ? percent : 100.0 * result.currentcapacity / result.maxcapacity;
}
if (callback) { callback(result); }
resolve(result);
+173 -35
View File
@@ -23,7 +23,7 @@ const _linux = (_platform === 'linux');
const _darwin = (_platform === 'darwin');
const _windows = (_platform === 'win32');
const _freebsd = (_platform === 'freebsd');
const _sunos = (_platform === 'sunos');
const _openbsd = (_platform === 'openbsd');
let _cpu_speed = '0.00';
let _current_cpu = {
@@ -162,6 +162,7 @@ function getCpu() {
model: '',
stepping: '',
revision: '',
voltage: '',
speed: '0.00',
speedmin: '',
speedmax: '',
@@ -193,42 +194,105 @@ function getCpu() {
});
}
if (_linux) {
let modelline = '';
let lines = [];
if (os.cpus()[0] && os.cpus()[0].model) modelline = os.cpus()[0].model;
exec('export LC_ALL=C; lscpu; unset LC_ALL', function (error, stdout) {
if (!error) {
let lines = stdout.toString().split('\n');
const modelline = util.getValue(lines, 'model name');
result.brand = modelline.split('@')[0].trim();
result.speed = modelline.split('@')[1] ? parseFloat(modelline.split('@')[1].trim()).toFixed(2) : '0.00';
if (result.speed === '0.00' && result.brand.indexOf('AMD') > -1) {
result.speed = getAMDSpeed(result.brand);
}
if (result.speed === '0.00') {
let current = getCpuCurrentSpeedSync();
if (current !== '0.00') result.speed = current.avg.toFixed(2);
}
_cpu_speed = result.speed;
result.speedmin = Math.round(parseFloat(util.getValue(lines, 'cpu min mhz').replace(/,/g, '.')) / 10.0) / 100;
result.speedmin = result.speedmin ? parseFloat(result.speedmin).toFixed(2) : '';
result.speedmax = Math.round(parseFloat(util.getValue(lines, 'cpu max mhz').replace(/,/g, '.')) / 10.0) / 100;
result.speedmax = result.speedmax ? parseFloat(result.speedmax).toFixed(2) : '';
lines = stdout.toString().split('\n');
}
modelline = util.getValue(lines, 'model name') || modelline;
result.brand = modelline.split('@')[0].trim();
result.speed = modelline.split('@')[1] ? parseFloat(modelline.split('@')[1].trim()).toFixed(2) : '0.00';
if (result.speed === '0.00' && result.brand.indexOf('AMD') > -1) {
result.speed = getAMDSpeed(result.brand);
}
if (result.speed === '0.00') {
let current = getCpuCurrentSpeedSync();
if (current !== '0.00') result.speed = current.avg.toFixed(2);
}
_cpu_speed = result.speed;
result.speedmin = Math.round(parseFloat(util.getValue(lines, 'cpu min mhz').replace(/,/g, '.')) / 10.0) / 100;
result.speedmin = result.speedmin ? parseFloat(result.speedmin).toFixed(2) : '';
result.speedmax = Math.round(parseFloat(util.getValue(lines, 'cpu max mhz').replace(/,/g, '.')) / 10.0) / 100;
result.speedmax = result.speedmax ? parseFloat(result.speedmax).toFixed(2) : '';
result = cpuBrandManufacturer(result);
result.vendor = util.getValue(lines, 'vendor id');
// if (!result.vendor) { result.vendor = util.getValue(lines, 'anbieterkennung'); }
result.family = util.getValue(lines, 'cpu family');
// if (!result.family) { result.family = util.getValue(lines, 'prozessorfamilie'); }
result.model = util.getValue(lines, 'model:');
// if (!result.model) { result.model = util.getValue(lines, 'modell:'); }
result.stepping = util.getValue(lines, 'stepping');
result.revision = util.getValue(lines, 'cpu revision');
result.cache.l1d = util.getValue(lines, 'l1d cache');
if (result.cache.l1d) { result.cache.l1d = parseInt(result.cache.l1d) * (result.cache.l1d.indexOf('K') !== -1 ? 1024 : 1); }
result.cache.l1i = util.getValue(lines, 'l1i cache');
if (result.cache.l1i) { result.cache.l1i = parseInt(result.cache.l1i) * (result.cache.l1i.indexOf('K') !== -1 ? 1024 : 1); }
result.cache.l2 = util.getValue(lines, 'l2 cache');
if (result.cache.l2) { result.cache.l2 = parseInt(result.cache.l2) * (result.cache.l2.indexOf('K') !== -1 ? 1024 : 1); }
result.cache.l3 = util.getValue(lines, 'l3 cache');
if (result.cache.l3) { result.cache.l3 = parseInt(result.cache.l3) * (result.cache.l3.indexOf('K') !== -1 ? 1024 : 1); }
result = cpuBrandManufacturer(result);
result.vendor = util.getValue(lines, 'vendor id');
// if (!result.vendor) { result.vendor = util.getValue(lines, 'anbieterkennung'); }
result.family = util.getValue(lines, 'cpu family');
// if (!result.family) { result.family = util.getValue(lines, 'prozessorfamilie'); }
result.model = util.getValue(lines, 'model:');
// if (!result.model) { result.model = util.getValue(lines, 'modell:'); }
result.stepping = util.getValue(lines, 'stepping');
result.revision = util.getValue(lines, 'cpu revision');
result.cache.l1d = util.getValue(lines, 'l1d cache');
if (result.cache.l1d) { result.cache.l1d = parseInt(result.cache.l1d) * (result.cache.l1d.indexOf('K') !== -1 ? 1024 : 1); }
result.cache.l1i = util.getValue(lines, 'l1i cache');
if (result.cache.l1i) { result.cache.l1i = parseInt(result.cache.l1i) * (result.cache.l1i.indexOf('K') !== -1 ? 1024 : 1); }
result.cache.l2 = util.getValue(lines, 'l2 cache');
if (result.cache.l2) { result.cache.l2 = parseInt(result.cache.l2) * (result.cache.l2.indexOf('K') !== -1 ? 1024 : 1); }
result.cache.l3 = util.getValue(lines, 'l3 cache');
if (result.cache.l3) { result.cache.l3 = parseInt(result.cache.l3) * (result.cache.l3.indexOf('K') !== -1 ? 1024 : 1); }
resolve(result);
});
}
if (_freebsd || _openbsd) {
let modelline = '';
let lines = [];
if (os.cpus()[0] && os.cpus()[0].model) modelline = os.cpus()[0].model;
exec('export LC_ALL=C; dmidecode -t 4; dmidecode -t 7 ; unset LC_ALL', function (error, stdout) {
let cache = [];
if (!error) {
const data = stdout.toString().split('# dmidecode');
const processor = data.length > 0 ? data[1] : '';
cache = data.length > 1 ? data[2].split('Cache Information') : [];
lines = processor.split('\n');
}
result.brand = modelline.split('@')[0].trim();
result.speed = modelline.split('@')[1] ? parseFloat(modelline.split('@')[1].trim()).toFixed(2) : '0.00';
if (result.speed === '0.00' && result.brand.indexOf('AMD') > -1) {
result.speed = getAMDSpeed(result.brand);
}
if (result.speed === '0.00') {
let current = getCpuCurrentSpeedSync();
if (current !== '0.00') result.speed = current.avg.toFixed(2);
}
_cpu_speed = result.speed;
result.speedmin = '';
result.speedmax = Math.round(parseFloat(util.getValue(lines, 'max speed').replace(/Mhz/g, '')) / 10.0) / 100;
result.speedmax = result.speedmax ? parseFloat(result.speedmax).toFixed(2) : '';
result = cpuBrandManufacturer(result);
result.vendor = util.getValue(lines, 'manufacturer');
let sig = util.getValue(lines, 'signature');
sig = sig.split(',');
for (var i = 0; i < sig.length; i++) {
sig[i] = sig[i].trim();
}
result.family = util.getValue(sig, 'Family', ' ', true);
result.model = util.getValue(sig, 'Model', ' ', true);
result.stepping = util.getValue(sig, 'Stepping', ' ', true);
result.revision = '';
const voltage = parseFloat(util.getValue(lines, 'voltage'));
result.voltage = isNaN(voltage) ? '' : voltage.toFixed(2);
for (let i = 0; i < cache.length; i++) {
lines = cache[i].split('\n');
let cacheType = util.getValue(lines,'Socket Designation').toLowerCase().replace(' ', '-').split('-');
cacheType = cacheType.length ? cacheType[0] : '';
const sizeParts = util.getValue(lines,'Installed Size').split(' ');
let size = parseInt(sizeParts[0], 10);
const unit = sizeParts.length > 1 ? sizeParts[1] : 'kb';
size = size * (unit === 'kb' ? 1024 : (unit === 'mb' ? 1024 * 1024 : (unit === 'gb' ? 1024 * 1024 * 1024 : 1)));
if (cacheType) {
if (cacheType === 'l1') {
result.cache[cacheType + 'd'] = size / 2;
result.cache[cacheType + 'i'] = size / 2;
} else {
result.cache[cacheType] = size;
}
}
}
resolve(result);
});
@@ -433,6 +497,28 @@ function cpuTemperature(callback) {
}
});
}
if (_freebsd || _openbsd) {
exec('sysctl dev.cpu | grep temp', function (error, stdout) {
if (!error) {
let lines = stdout.toString().split('\n');
let sum = 0;
lines.forEach(function (line) {
const parts = line.split(':');
if (parts.length > 0) {
const temp = parseFloat(parts[1].replace(',', '.'), 10);
if (temp > result.max) result.max = temp;
sum = sum + temp;
result.cores.push(temp);
}
});
if (result.cores.length) {
result.main = Math.round(sum / result.cores.length * 100) / 100;
}
}
if (callback) { callback(result); }
resolve(result);
});
}
if (_darwin) {
let osxTemp = null;
try {
@@ -519,6 +605,24 @@ function cpuFlags(callback) {
resolve(result);
});
}
if (_freebsd || _openbsd) {
exec('export LC_ALL=C; dmidecode -t 4; unset LC_ALL', function (error, stdout) {
let flags = [];
if (!error) {
let parts = stdout.toString().split('\tFlags:');
const lines = parts.length > 1 ? parts[1].split('\tVersion:')[0].split['\n'] : [];
lines.forEach(function (line) {
let flag = (line.indexOf('(') ? line .split('(')[0].toLowerCase() : '').trim().replace(/\t/g, '');
if (flag) {
flags.push(flag);
}
});
}
result = flags.join(' ').trim();
if (callback) { callback(result); }
resolve(result);
});
}
if (_darwin) {
exec('sysctl machdep.cpu.features', function (error, stdout) {
if (!error) {
@@ -545,7 +649,12 @@ function cpuCache(callback) {
return new Promise((resolve) => {
process.nextTick(() => {
let result = {};
let result = {
l1d: -1,
l1i: -1,
l2: -1,
l3: -1,
};
if (_linux) {
exec('lscpu', function (error, stdout) {
if (!error) {
@@ -570,6 +679,35 @@ function cpuCache(callback) {
resolve(result);
});
}
if (_freebsd || _openbsd) {
exec('export LC_ALL=C; dmidecode -t 7 ; unset LC_ALL', function (error, stdout) {
let cache = [];
if (!error) {
const data = stdout.toString();
cache = data.split('Cache Information');
cache.shift();
}
for (let i = 0; i < cache.length; i++) {
const lines = cache[i].split('\n');
let cacheType = util.getValue(lines,'Socket Designation').toLowerCase().replace(' ', '-').split('-');
cacheType = cacheType.length ? cacheType[0] : '';
const sizeParts = util.getValue(lines,'Installed Size').split(' ');
let size = parseInt(sizeParts[0], 10);
const unit = sizeParts.length > 1 ? sizeParts[1] : 'kb';
size = size * (unit === 'kb' ? 1024 : (unit === 'mb' ? 1024 * 1024 : (unit === 'gb' ? 1024 * 1024 * 1024 : 1)));
if (cacheType) {
if (cacheType === 'l1') {
result.cache[cacheType + 'd'] = size / 2;
result.cache[cacheType + 'i'] = size / 2;
} else {
result.cache[cacheType] = size;
}
}
}
if (callback) { callback(result); }
resolve(result);
});
}
if (_darwin) {
exec('sysctl hw.l1icachesize hw.l1dcachesize hw.l2cachesize hw.l3cachesize', function (error, stdout) {
if (!error) {
+3
View File
@@ -88,6 +88,7 @@ function dockerContainers(all, callback) {
});
}
} catch (err) {
util.noop();
}
// }
@@ -244,6 +245,7 @@ function dockerContainerStats(containerID, callback) {
result.networks = (stats.networks ? stats.networks : {});
}
} catch (err) {
util.noop();
}
// }
if (callback) { callback(result); }
@@ -319,6 +321,7 @@ function dockerContainerProcesses(containerID, callback) {
});
}
} catch (err) {
util.noop();
}
if (callback) { callback(result); }
resolve(result);
+29 -17
View File
@@ -12,16 +12,18 @@
// 8. File System
// ----------------------------------------------------------------------------------
const os = require('os');
const exec = require('child_process').exec;
const execSync = require('child_process').execSync;
const util = require('./util');
let _platform = os.type();
let _platform = process.platform;
const _linux = (_platform === 'linux');
const _darwin = (_platform === 'darwin');
const _windows = (_platform === 'win32');
const _freebsd = (_platform === 'freebsd');
const _openbsd = (_platform === 'openbsd');
const _linux = (_platform === 'Linux');
const _darwin = (_platform === 'Darwin');
const _windows = (_platform === 'Windows_NT');
const NOT_SUPPORTED = 'not supported';
let _fs_speed = {};
@@ -35,8 +37,11 @@ function fsSize(callback) {
return new Promise((resolve) => {
process.nextTick(() => {
let data = [];
if (_linux || _darwin) {
let cmd = (_darwin ? 'df -lkP | grep ^/' : 'df -lkPT | grep ^/');
if (_linux || _freebsd || _openbsd || _darwin) {
let cmd = '';
if (_darwin) cmd = 'df -lkP | grep ^/';
if (_linux) cmd = 'df -lkPT | grep ^/';
if (_freebsd || _openbsd) cmd = 'df -lkPT';
exec(cmd, function (error, stdout) {
if (!error) {
let lines = stdout.toString().split('\n');
@@ -44,14 +49,16 @@ function fsSize(callback) {
lines.forEach(function (line) {
if (line !== '') {
line = line.replace(/ +/g, ' ').split(' ');
data.push({
'fs': line[0],
'type': (_linux ? line[1] : 'HFS'),
'size': parseInt((_linux ? line[2] : line[1])) * 1024,
'used': parseInt((_linux ? line[3] : line[2])) * 1024,
'use': parseFloat((100.0 * (_linux ? line[3] : line[2]) / (_linux ? line[2] : line[1])).toFixed(2)),
'mount': line[line.length - 1]
});
if (line && (line[0].startsWith('/')) || (line[6] && line[6] === '/')) {
data.push({
'fs': line[0],
'type': ((_linux || _freebsd || _openbsd) ? line[1] : 'HFS'),
'size': parseInt(((_linux || _freebsd || _openbsd) ? line[2] : line[1])) * 1024,
'used': parseInt(((_linux || _freebsd || _openbsd) ? line[3] : line[2])) * 1024,
'use': parseFloat((100.0 * ((_linux || _freebsd || _openbsd) ? line[3] : line[2]) / ((_linux || _freebsd || _openbsd) ? line[2] : line[1])).toFixed(2)),
'mount': line[line.length - 1]
});
}
}
});
}
@@ -360,7 +367,7 @@ function fsStats(callback) {
});
let output = fs_filter.join('|');
exec("cat /proc/diskstats | egrep '" + output + "'", function (error, stdout) {
exec('cat /proc/diskstats | egrep "' + output + '"', function (error, stdout) {
if (!error) {
let lines = stdout.toString().split('\n');
lines.forEach(function (line) {
@@ -492,7 +499,7 @@ function disksIO(callback) {
let wIO = 0;
if ((_disk_io && !_disk_io.ms) || (_disk_io && _disk_io.ms && Date.now() - _disk_io.ms >= 500)) {
if (_linux) {
if (_linux || _freebsd || _openbsd) {
// prints Block layer statistics for all mounted volumes
// var cmd = "for mount in `lsblk | grep / | sed -r 's/│ └─//' | cut -d ' ' -f 1`; do cat /sys/block/$mount/stat | sed -r 's/ +/;/g' | sed -r 's/^;//'; done";
// var cmd = "for mount in `lsblk | grep / | sed 's/[│└─├]//g' | awk '{$1=$1};1' | cut -d ' ' -f 1 | sort -u`; do cat /sys/block/$mount/stat | sed -r 's/ +/;/g' | sed -r 's/^;//'; done";
@@ -583,6 +590,7 @@ function diskLayout(callback) {
try {
mediumType = execSync('cat /sys/block/' + logical + '/queue/rotational').toString().split('\n')[0];
} catch (e) {
util.noop();
}
const sizeString = util.getValue(lines, 'size', ':', true).trim();
@@ -613,6 +621,10 @@ function diskLayout(callback) {
resolve(result);
});
}
if (_freebsd || _openbsd) {
if (callback) { callback(result); }
resolve(result);
}
if (_darwin) {
exec('system_profiler SPSerialATADataType SPNVMeDataType', function (error, stdout) {
+11 -5
View File
@@ -12,15 +12,17 @@
// 7. Graphics (controller, display)
// ----------------------------------------------------------------------------------
const os = require('os');
const exec = require('child_process').exec;
const util = require('./util');
let _platform = os.type();
let _platform = process.platform;
const _linux = (_platform === 'linux');
const _darwin = (_platform === 'darwin');
const _windows = (_platform === 'win32');
const _freebsd = (_platform === 'freebsd');
const _openbsd = (_platform === 'openbsd');
const _linux = (_platform === 'Linux');
const _darwin = (_platform === 'Darwin');
const _windows = (_platform === 'Windows_NT');
let _resolutionx = 0;
let _resolutiony = 0;
let _pixeldepth = 0;
@@ -321,6 +323,10 @@ function graphics(callback) {
});
});
}
if (_freebsd || _openbsd) {
if (callback) { callback(result); }
resolve(result);
}
if (_windows) {
// https://blogs.technet.microsoft.com/heyscriptingguy/2013/10/03/use-powershell-to-discover-multi-monitor-information/
exec(util.getWmic() + ' path win32_VideoController get AdapterCompatibility, AdapterDACType, name, PNPDeviceID, CurrentVerticalResolution, CurrentHorizontalResolution, CurrentNumberOfColors, AdapterRAM, CurrentBitsPerPixel, CurrentRefreshRate, MinRefreshRate, MaxRefreshRate, VideoMemoryType /value', function (error, stdout) {
+32 -15
View File
@@ -83,8 +83,6 @@
// Dependencies
// ----------------------------------------------------------------------------------
const os = require('os');
const lib_version = require('../package.json').version;
const util = require('./util');
const system = require('./system');
@@ -100,8 +98,10 @@ const users = require('./users');
const internet = require('./internet');
const docker = require('./docker');
let _platform = os.type();
let _windows = (_platform === 'Windows_NT');
let _platform = process.platform;
const _windows = (_platform === 'win32');
const _freebsd = (_platform === 'freebsd');
const _openbsd = (_platform === 'openbsd');
// ----------------------------------------------------------------------------------
// 1. General
@@ -185,7 +185,9 @@ function getDynamicData(srv, iface, callback) {
// use closure to track ƒ completion
let functionProcessed = (function () {
let totalFunctions = (_windows ? 10 : 14);
let totalFunctions = 14;
if (_windows) totalFunctions = 10;
if (_freebsd || _openbsd) totalFunctions = 10;
return function () {
if (--totalFunctions === 0) {
@@ -246,15 +248,19 @@ function getDynamicData(srv, iface, callback) {
functionProcessed();
});
network.networkStats(iface).then(res => {
data.networkStats = res;
functionProcessed();
});
if (!_openbsd && !_freebsd) {
network.networkStats(iface).then(res => {
data.networkStats = res;
functionProcessed();
});
}
network.networkConnections().then(res => {
data.networkConnections = res;
functionProcessed();
});
if (!_openbsd && !_freebsd) {
network.networkConnections().then(res => {
data.networkConnections = res;
functionProcessed();
});
}
memory.mem().then(res => {
data.mem = res;
@@ -278,14 +284,14 @@ function getDynamicData(srv, iface, callback) {
functionProcessed();
});
if (!_windows) {
if (!_windows && !_openbsd && !_freebsd) {
filesystem.fsStats().then(res => {
data.fsStats = res;
functionProcessed();
});
}
if (!_windows) {
if (!_windows && !_openbsd && !_freebsd) {
filesystem.disksIO().then(res => {
data.disksIO = res;
functionProcessed();
@@ -313,6 +319,17 @@ function getAllData(srv, iface, callback) {
process.nextTick(() => {
let data = {};
if (iface && util.isFunction(iface) && !callback) {
callback = iface;
iface = '';
}
if (srv && util.isFunction(srv) && !iface && !callback) {
callback = srv;
srv = '';
iface = '';
}
getStaticData().then(res => {
data = res;
getDynamicData(srv, iface).then(res => {
+12 -8
View File
@@ -12,15 +12,16 @@
// 12. Internet
// ----------------------------------------------------------------------------------
const os = require('os');
const exec = require('child_process').exec;
const util = require('./util');
let _platform = os.type();
let _platform = process.platform;
const _linux = (_platform === 'Linux');
const _darwin = (_platform === 'Darwin');
const _windows = (_platform === 'Windows_NT');
const _linux = (_platform === 'linux');
const _darwin = (_platform === 'darwin');
const _windows = (_platform === 'win32');
const _freebsd = (_platform === 'freebsd');
const _openbsd = (_platform === 'openbsd');
// --------------------------
// check if external site is available
@@ -39,7 +40,7 @@ function inetChecksite(url, callback) {
if (url) {
url = url.toLowerCase();
let t = Date.now();
if (_linux || _darwin) {
if (_linux || _freebsd || _openbsd || _darwin) {
let args = ' -I --connect-timeout 5 -m 5 ' + url + ' 2>/dev/null | head -n 1 | cut -d " " -f2';
let cmd = 'curl';
exec(cmd + args, function (error, stdout) {
@@ -73,7 +74,7 @@ function inetChecksite(url, callback) {
resolve(result);
});
}
}).on('error', err => {
}).on('error', () => {
if (callback) { callback(result); }
resolve(result);
});
@@ -108,10 +109,13 @@ function inetLatency(host, callback) {
return new Promise((resolve) => {
process.nextTick(() => {
let cmd;
if (_linux || _darwin) {
if (_linux || _freebsd || _openbsd || _darwin) {
if (_linux) {
cmd = 'ping -c 2 -w 3 ' + host + ' | grep rtt';
}
if (_freebsd || _openbsd) {
cmd = 'ping -c 2 -t 3 ' + host + ' | grep round-trip';
}
if (_darwin) {
cmd = 'ping -c 2 -t 3 ' + host + ' | grep avg';
}
+48 -21
View File
@@ -16,11 +16,14 @@ const os = require('os');
const exec = require('child_process').exec;
const util = require('./util');
let _platform = os.type();
let _platform = process.platform;
const _linux = (_platform === 'linux');
const _darwin = (_platform === 'darwin');
const _windows = (_platform === 'win32');
const _freebsd = (_platform === 'freebsd');
const _openbsd = (_platform === 'openbsd');
const _linux = (_platform === 'Linux');
const _darwin = (_platform === 'Darwin');
const _windows = (_platform === 'Windows_NT');
const OSX_RAM_manufacturers = {
'0x014F': 'Transcend Information',
@@ -134,8 +137,32 @@ function mem(callback) {
resolve(result);
});
}
if (_freebsd || _openbsd) {
exec('/sbin/sysctl -a | grep -E "hw.realmem|hw.physmem|vm.stats.vm.v_page_count|vm.stats.vm.v_wire_count|vm.stats.vm.v_active_count|vm.stats.vm.v_inactive_count|vm.stats.vm.v_cache_count|vm.stats.vm.v_free_count|vm.stats.vm.v_page_size"', function (error, stdout) {
if (!error) {
let lines = stdout.toString().split('\n');
const pagesize = parseInt(util.getValue(lines, 'vm.stats.vm.v_page_size'), 10);
const inactive = parseInt(util.getValue(lines, 'vm.stats.vm.v_inactive_count'), 10) * pagesize;
const cache = parseInt(util.getValue(lines, 'vm.stats.vm.v_cache_count'), 10) * pagesize;
result.total = parseInt(util.getValue(lines, 'hw.realmem'), 10);
if (isNaN(result.total)) result.total = parseInt(util.getValue(lines, 'hw.physmem'), 10);
result.free = parseInt(util.getValue(lines, 'vm.stats.vm.v_free_count'), 10) * pagesize;
result.buffcache = inactive + cache;
result.available = result.buffcache + result.free;
result.active = result.total - result.free - result.buffcache;
result.swaptotal = 0;
result.swapfree = 0;
result.swapused = 0;
}
if (callback) { callback(result); }
resolve(result);
});
}
if (_darwin) {
exec("vm_stat | grep 'Pages active'", function (error, stdout) {
exec('vm_stat | grep "Pages active"', function (error, stdout) {
if (!error) {
let lines = stdout.toString().split('\n');
@@ -203,34 +230,34 @@ function memLayout(callback) {
let result = [];
if (_linux) {
exec("dmidecode -t memory | grep -iE 'Size:|Type|Speed|Manufacturer|Form Factor|Locator|Memory Device|Serial Number|Voltage|Part Number'", function (error, stdout) {
if (_linux || _freebsd || _openbsd) {
exec('dmidecode -t memory | grep -iE "Size:|Type|Speed|Manufacturer|Form Factor|Locator|Memory Device|Serial Number|Voltage|Part Number"', function (error, stdout) {
if (!error) {
let devices = stdout.toString().split('Memory Device');
devices.shift();
devices.forEach(function (device) {
let lines = device.split('\n');
if (parseInt(util.getValue(lines, ' Size'), 10) > 0) {
if (parseInt(util.getValue(lines, 'Size'), 10) > 0) {
result.push({
size: parseInt(util.getValue(lines, ' Size'), 10)*1024*1024,
bank: util.getValue(lines, ' Bank Locator'),
type: util.getValue(lines, ' Type:'),
clockSpeed: (util.getValue(lines, ' Configured Clock Speed:') ? parseInt(util.getValue(lines, ' Configured Clock Speed:'), 10) : parseInt(util.getValue(lines, ' Speed:'), 10)),
formFactor: util.getValue(lines, ' Form Factor:'),
manufacturer: util.getValue(lines, ' Manufacturer:'),
partNum: util.getValue(lines, ' Part Number:'),
serialNum: util.getValue(lines, ' Serial Number:'),
voltageConfigured: parseFloat(util.getValue(lines, ' Configured Voltage:') || -1),
voltageMin: parseFloat(util.getValue(lines, ' Minimum Voltage:') || -1),
voltageMax: parseFloat(util.getValue(lines, ' Maximum Voltage:') || -1),
size: parseInt(util.getValue(lines, 'Size'), 10)*1024*1024,
bank: util.getValue(lines, 'Bank Locator'),
type: util.getValue(lines, 'Type:'),
clockSpeed: (util.getValue(lines, 'Configured Clock Speed:') ? parseInt(util.getValue(lines, 'Configured Clock Speed:'), 10) : (util.getValue(lines, 'Speed:') ? parseInt(util.getValue(lines, 'Speed:'), 10) : -1)),
formFactor: util.getValue(lines, 'Form Factor:'),
manufacturer: util.getValue(lines, 'Manufacturer:'),
partNum: util.getValue(lines, 'Part Number:'),
serialNum: util.getValue(lines, 'Serial Number:'),
voltageConfigured: parseFloat(util.getValue(lines, 'Configured Voltage:') || -1),
voltageMin: parseFloat(util.getValue(lines, 'Minimum Voltage:') || -1),
voltageMax: parseFloat(util.getValue(lines, 'Maximum Voltage:') || -1),
});
} else {
result.push({
size: 0,
bank: util.getValue(lines, ' Bank Locator'),
bank: util.getValue(lines, 'Bank Locator'),
type: 'Empty',
clockSpeed: 0,
formFactor: util.getValue(lines, ' Form Factor:'),
formFactor: util.getValue(lines, 'Form Factor:'),
partNum: '',
serialNum: '',
voltageConfigured: -1,
+20 -12
View File
@@ -18,11 +18,13 @@ const execSync = require('child_process').execSync;
const fs = require('fs');
const util = require('./util');
let _platform = os.type();
let _platform = process.platform;
const _linux = (_platform === 'Linux');
const _darwin = (_platform === 'Darwin');
const _windows = (_platform === 'Windows_NT');
const _linux = (_platform === 'linux');
const _darwin = (_platform === 'darwin');
const _windows = (_platform === 'win32');
const _freebsd = (_platform === 'freebsd');
const _openbsd = (_platform === 'openbsd');
let _network = {};
let _default_iface;
@@ -33,10 +35,16 @@ function getDefaultNetworkInterface() {
if (!_default_iface) {
let ifacename = '';
let scopeid = 9999;
if (_linux || _darwin) {
let cmd = (_linux ? "route 2>/dev/null | grep default | awk '{print $8}'" : "route get 0.0.0.0 2>/dev/null | grep interface: | awk '{print $2}'");
if (_linux || _darwin || _freebsd || _openbsd) {
let cmd = '';
if (_linux) cmd = 'route 2>/dev/null | grep default | awk "{print $8}"';
if (_darwin) cmd = 'route get 0.0.0.0 2>/dev/null | grep interface: | awk "{print $2}"';
if (_freebsd || _openbsd) cmd = 'route get 0.0.0.0 | grep interface:';
let result = execSync(cmd);
ifacename = result.toString().split('\n')[0];
if (ifacename.indexOf(':') > -1) {
ifacename = ifacename.split(':')[1].trim();
}
}
if (!ifacename) { // fallback - "first" external interface (sorted by scopeid)
@@ -65,7 +73,7 @@ function getMacAddresses() {
let iface = '';
let mac = '';
let result = {};
if (_linux) {
if (_linux || _freebsd || _openbsd) {
const cmd = 'export LC_ALL=C; /sbin/ifconfig; unset LC_ALL';
let res = execSync(cmd);
const lines = res.toString().split('\n');
@@ -265,7 +273,7 @@ function networkStats(iface, callback) {
let cmd, lines, stats;
if (!_network[iface] || (_network[iface] && !_network[iface].ms) || (_network[iface] && _network[iface].ms && Date.now() - _network[iface].ms >= 500)) {
if (_linux) {
if (_linux || _freebsd || _openbsd) {
if (fs.existsSync('/sys/class/net/' + iface)) {
cmd =
'cat /sys/class/net/' + iface + '/operstate; ' +
@@ -290,7 +298,7 @@ function networkStats(iface, callback) {
}
}
if (_darwin) {
cmd = "ifconfig " + iface + " | grep 'status'";
cmd = 'ifconfig ' + iface + ' | grep "status"';
exec(cmd, function (error, stdout) {
result.operstate = (stdout.toString().split(':')[1] || '').trim();
result.operstate = (result.operstate || '').toLowerCase();
@@ -396,7 +404,7 @@ function networkConnections(callback) {
process.nextTick(() => {
let result = [];
if (_linux) {
let cmd = "netstat -tuna | grep 'ESTABLISHED\\|SYN_SENT\\|SYN_RECV\\|FIN_WAIT1\\|FIN_WAIT2\\|TIME_WAIT\\|CLOSE\\|CLOSE_WAIT\\|LAST_ACK\\|LISTEN\\|CLOSING\\|UNKNOWN\\|VERBUNDEN'";
let cmd = 'netstat -tuna | grep "ESTABLISHED\\|SYN_SENT\\|SYN_RECV\\|FIN_WAIT1\\|FIN_WAIT2\\|TIME_WAIT\\|CLOSE\\|CLOSE_WAIT\\|LAST_ACK\\|LISTEN\\|CLOSING\\|UNKNOWN\\|VERBUNDEN"';
exec(cmd, function (error, stdout) {
if (!error) {
let lines = stdout.toString().split('\n');
@@ -438,7 +446,7 @@ function networkConnections(callback) {
}
resolve(result);
} else {
cmd = "ss -tuna | grep 'ESTAB\\|SYN-SENT\\|SYN-RECV\\|FIN-WAIT1\\|FIN-WAIT2\\|TIME-WAIT\\|CLOSE\\|CLOSE-WAIT\\|LAST-ACK\\|LISTEN\\|CLOSING'";
cmd = 'ss -tuna | grep "ESTAB\\|SYN-SENT\\|SYN-RECV\\|FIN-WAIT1\\|FIN-WAIT2\\|TIME-WAIT\\|CLOSE\\|CLOSE-WAIT\\|LAST-ACK\\|LISTEN\\|CLOSING"';
exec(cmd, function (error, stdout) {
if (!error) {
@@ -487,7 +495,7 @@ function networkConnections(callback) {
});
}
if (_darwin) {
let cmd = "netstat -nat | grep 'ESTABLISHED\\|SYN_SENT\\|SYN_RECV\\|FIN_WAIT1\\|FIN_WAIT2\\|TIME_WAIT\\|CLOSE\\|CLOSE_WAIT\\|LAST_ACK\\|LISTEN\\|CLOSING\\|UNKNOWN'";
let cmd = 'netstat -nat | grep "ESTABLISHED\\|SYN_SENT\\|SYN_RECV\\|FIN_WAIT1\\|FIN_WAIT2\\|TIME_WAIT\\|CLOSE\\|CLOSE_WAIT\\|LAST_ACK\\|LISTEN\\|CLOSING\\|UNKNOWN"';
exec(cmd, function (error, stdout) {
if (!error) {
+26 -4
View File
@@ -16,11 +16,14 @@ const os = require('os');
const exec = require('child_process').exec;
const util = require('./util');
let _platform = os.type();
let _platform = process.platform;
const _linux = (_platform === 'linux');
const _darwin = (_platform === 'darwin');
const _windows = (_platform === 'win32');
const _freebsd = (_platform === 'freebsd');
const _openbsd = (_platform === 'openbsd');
const _linux = (_platform === 'Linux');
const _darwin = (_platform === 'Darwin');
const _windows = (_platform === 'Windows_NT');
const NOT_SUPPORTED = 'not supported';
// --------------------------
@@ -91,6 +94,9 @@ function getLogoFile(distro) {
else if (distro.indexOf('openbsd') !== -1) {
result = 'openbsd';
}
else if (distro.indexOf('freebsd') !== -1) {
result = 'freebsd';
}
else if (distro.indexOf('opensuse') !== -1) {
result = 'opensuse';
}
@@ -185,6 +191,22 @@ function osInfo(callback) {
resolve(result);
});
}
if (_freebsd || _openbsd) {
exec('sysctl kern.ostype kern.osrelease kern.osrevision', function (error, stdout) {
if (!error) {
let lines = stdout.toString().split('\n');
result.distro = util.getValue(lines, 'kern.ostype');
result.logofile = getLogoFile(result.distro);
result.release = util.getValue(lines, 'kern.osrelease').split('-')[0];
result.codename = '';
}
if (callback) {
callback(result);
}
resolve(result);
});
}
if (_darwin) {
exec('sw_vers', function (error, stdout) {
let lines = stdout.toString().split('\n');
+88 -79
View File
@@ -16,11 +16,14 @@ const os = require('os');
const exec = require('child_process').exec;
const util = require('./util');
let _platform = os.type();
let _platform = process.platform;
const _linux = (_platform === 'linux');
const _darwin = (_platform === 'darwin');
const _windows = (_platform === 'win32');
const _freebsd = (_platform === 'freebsd');
const _openbsd = (_platform === 'openbsd');
const _linux = (_platform === 'Linux');
const _darwin = (_platform === 'Darwin');
const _windows = (_platform === 'Windows_NT');
const NOT_SUPPORTED = 'not supported';
let _process_cpu = {
@@ -69,32 +72,85 @@ function services(srv, callback) {
return new Promise((resolve) => {
process.nextTick(() => {
srv = srv.trim().toLowerCase().replace(/,+/g, ' ').replace(/ +/g, ' ').replace(/ +/g, '|');
let srvs = srv.split('|');
let data = [];
let dataSrv = [];
if (_linux || _darwin) {
let comm = (_darwin) ? 'ps -caxm -o pcpu,pmem,comm' : 'ps axo pcpu,pmem,comm';
if (srv !== '' && srvs.length > 0) {
exec(comm + " | grep -v grep | egrep '" + srv + "'", function (error, stdout) {
if (!error) {
let lines = stdout.toString().replace(/ +/g, ' ').replace(/,+/g, '.').split('\n');
srvs.forEach(function (srv) {
let ps = lines.filter(function (e) {
return e.indexOf(srv) !== -1;
if (srv) {
srv = srv.trim().toLowerCase().replace(/,+/g, ' ').replace(/ +/g, ' ').replace(/ +/g, '|');
let srvs = srv.split('|');
let data = [];
let dataSrv = [];
if (_linux || _freebsd || _openbsd || _darwin) {
let comm = (_darwin) ? 'ps -caxm -o pcpu,pmem,comm' : 'ps axo pcpu,pmem,comm';
if (srv !== '' && srvs.length > 0) {
exec(comm + " | grep -v grep | egrep '" + srv + "'", function (error, stdout) {
if (!error) {
let lines = stdout.toString().replace(/ +/g, ' ').replace(/,+/g, '.').split('\n');
srvs.forEach(function (srv) {
let ps = lines.filter(function (e) {
return e.indexOf(srv) !== -1;
});
data.push({
'name': srv,
'running': ps.length > 0,
'pcpu': parseFloat((ps.reduce(function (pv, cv) {
return pv + parseFloat(cv.trim().split(' ')[0]);
}, 0)).toFixed(2)),
'pmem': parseFloat((ps.reduce(function (pv, cv) {
return pv + parseFloat(cv.trim().split(' ')[1]);
}, 0)).toFixed(2))
});
});
if (callback) { callback(data); }
resolve(data);
} else {
srvs.forEach(function (srv) {
data.push({
'name': srv,
'running': false,
'pcpu': 0,
'pmem': 0
});
});
if (callback) { callback(data); }
resolve(data);
}
});
} else {
if (callback) { callback(data); }
resolve(data);
}
}
if (_windows) {
exec(util.getWmic() + ' service get /value', {maxBuffer: 1024 * 1000}, function (error, stdout) {
if (!error) {
let serviceSections = stdout.split(/\n\s*\n/);
for (let i = 0; i < serviceSections.length; i++) {
if (serviceSections[i].trim() !== '') {
let lines = serviceSections[i].trim().split('\r\n');
let srv = util.getValue(lines, 'Name', '=', true).toLowerCase();
let started = util.getValue(lines, 'Started', '=', true);
if (srvs.indexOf(srv) >= 0) {
data.push({
'name': srv,
'running': (started === 'TRUE'),
'pcpu': 0,
'pmem': 0
});
dataSrv.push(srv);
}
}
}
let srvsMissing = srvs.filter(function (e) {
return dataSrv.indexOf(e) === -1;
});
srvsMissing.forEach(function (srv) {
data.push({
'name': srv,
'running': ps.length > 0,
'pcpu': parseFloat((ps.reduce(function (pv, cv) {
return pv + parseFloat(cv.trim().split(' ')[0]);
}, 0)).toFixed(2)),
'pmem': parseFloat((ps.reduce(function (pv, cv) {
return pv + parseFloat(cv.trim().split(' ')[1]);
}, 0)).toFixed(2))
'running': false,
'pcpu': 0,
'pmem': 0
});
});
if (callback) { callback(data); }
resolve(data);
} else {
@@ -110,58 +166,10 @@ function services(srv, callback) {
resolve(data);
}
});
} else {
if (callback) { callback(data); }
resolve(data);
}
}
if (_windows) {
exec(util.getWmic() + ' service get /value', {maxBuffer: 1024 * 1000}, function (error, stdout) {
if (!error) {
let serviceSections = stdout.split(/\n\s*\n/);
for (let i = 0; i < serviceSections.length; i++) {
if (serviceSections[i].trim() !== '') {
let lines = serviceSections[i].trim().split('\r\n');
let srv = util.getValue(lines, 'Name', '=', true).toLowerCase();
let started = util.getValue(lines, 'Started', '=', true);
if (srvs.indexOf(srv) >= 0) {
data.push({
'name': srv,
'running': (started === 'TRUE'),
'pcpu': 0,
'pmem': 0
});
dataSrv.push(srv);
}
}
}
let srvsMissing = srvs.filter(function (e) {
return dataSrv.indexOf(e) === -1;
});
srvsMissing.forEach(function (srv) {
data.push({
'name': srv,
'running': false,
'pcpu': 0,
'pmem': 0
});
});
if (callback) { callback(data); }
resolve(data);
} else {
srvs.forEach(function (srv) {
data.push({
'name': srv,
'running': false,
'pcpu': 0,
'pmem': 0
});
});
if (callback) { callback(data); }
resolve(data);
}
});
}
} else {
if (callback) { callback({}); }
resolve({});
}
});
});
@@ -407,8 +415,9 @@ function processes(callback) {
let cmd = '';
if ((_process_cpu.ms && Date.now() - _process_cpu.ms >= 500) || _process_cpu.ms === 0) {
if (_linux || _darwin) {
if (_linux || _freebsd || _openbsd || _darwin) {
if (_linux) cmd = 'ps axo pid:10,pcpu:6,pmem:6,pri:5,vsz:10,rss:10,ni:5,start:20,state:20,tty:20,user:20,command';
if (_freebsd || _openbsd) cmd = 'ps axo pid,pcpu,pmem,pri,vsz,rss,ni,start,state,tty,user,command';
if (_darwin) cmd = 'ps acxo pid,pcpu,pmem,pri,vsz,rss,nice,start,state,tty,user,command -r';
exec(cmd, function (error, stdout) {
if (!error) {
@@ -426,7 +435,7 @@ function processes(callback) {
if (_linux) {
// calc process_cpu - ps is not accurate in linux!
cmd = "cat /proc/stat | grep 'cpu '";
cmd = 'cat /proc/stat | grep "cpu "';
for (let i = 0; i < result.list.length; i++) {
cmd += (';cat /proc/' + result.list[i].pid + '/stat');
}
+5 -5
View File
@@ -22,7 +22,7 @@ const _linux = (_platform === 'linux');
const _darwin = (_platform === 'darwin');
const _windows = (_platform === 'win32');
const _freebsd = (_platform === 'freebsd');
const _sunos = (_platform === 'sunos');
const _openbsd = (_platform === 'openbsd');
function system(callback) {
@@ -38,7 +38,7 @@ function system(callback) {
sku: '-',
};
if (_linux) {
if (_linux || _freebsd || _openbsd) {
exec('dmidecode -t system', function (error, stdout) {
if (!error) {
let lines = stdout.toString().split('\n');
@@ -194,7 +194,7 @@ function bios(callback) {
revision: '',
};
let cmd = '';
if (_linux) {
if (_linux || _freebsd || _openbsd) {
if (process.arch === 'arm') {
cmd = 'cat /proc/cpuinfo | grep Serial';
@@ -207,7 +207,7 @@ function bios(callback) {
result.vendor = util.getValue(lines, 'Vendor');
result.version = util.getValue(lines, 'Version');
const datetime = util.getValue(lines, 'Release Date');
result.releaseDate = datetime.date;
result.releaseDate = util.parseDateTime(datetime).date;
result.revision = util.getValue(lines, 'BIOS Revision');
}
@@ -268,7 +268,7 @@ function baseboard(callback) {
assetTag: '-',
};
let cmd = '';
if (_linux) {
if (_linux || _freebsd || _openbsd) {
if (process.arch === 'arm') {
cmd = 'cat /proc/cpuinfo | grep Serial';
// 'BCM2709', 'BCM2835', 'BCM2708' -->
+17 -5
View File
@@ -12,15 +12,16 @@
// 11. Users/Sessions
// ----------------------------------------------------------------------------------
const os = require('os');
const exec = require('child_process').exec;
const util = require('./util');
let _platform = os.type();
let _platform = process.platform;
const _linux = (_platform === 'Linux');
const _darwin = (_platform === 'Darwin');
const _windows = (_platform === 'Windows_NT');
const _linux = (_platform === 'linux');
const _darwin = (_platform === 'darwin');
const _windows = (_platform === 'win32');
const _freebsd = (_platform === 'freebsd');
const _openbsd = (_platform === 'openbsd');
// --------------------------
// array of users online = sessions
@@ -204,6 +205,17 @@ function users(callback) {
}
});
}
if (_freebsd || _openbsd) {
exec('who; echo "---"; w -ih', function (error, stdout) {
if (!error) {
// lines / split
let lines = stdout.toString().split('\n');
result = parseUsersDarwin(lines);
}
if (callback) { callback(result); }
resolve(result);
});
}
if (_darwin) {
exec('who; echo "---"; w -ih', function (error, stdout) {
+6 -3
View File
@@ -65,11 +65,11 @@ function getValue(lines, property, separator, trimmed) {
property = property.toLowerCase();
trimmed = trimmed || false;
for (let i = 0; i < lines.length; i++) {
let line = lines[i].toLowerCase();
let line = lines[i].toLowerCase().replace(/\t/g, '');
if (trimmed) {
line = line.trim();
}
if (line.toLowerCase().startsWith(property)) {
if (line.startsWith(property)) {
const parts = lines[i].split(separator);
if (parts.length >= 2) {
parts.shift();
@@ -128,11 +128,13 @@ function getWmic() {
if (os.type() === 'Windows_NT' && !wmic) {
if (fs.existsSync(process.env.WINDIR + '\\system32\\wbem\\wmic.exe')) {
wmic = process.env.WINDIR + '\\system32\\wbem\\wmic.exe';
} else wmic = 'wmic'
} else wmic = 'wmic';
}
return wmic;
}
function noop(){}
exports.isFunction = isFunction;
exports.unique = unique;
exports.sortByKey= sortByKey;
@@ -141,3 +143,4 @@ exports.getValue = getValue;
exports.decodeEscapeSequence = decodeEscapeSequence;
exports.parseDateTime = parseDateTime;
exports.getWmic = getWmic;
exports.noop = noop;