starting sunos support
This commit is contained in:
parent
12d57c6943
commit
62bd03cc6c
@ -23,6 +23,7 @@ const _darwin = (_platform === 'darwin');
|
||||
const _windows = (_platform === 'win32');
|
||||
const _freebsd = (_platform === 'freebsd');
|
||||
const _openbsd = (_platform === 'openbsd');
|
||||
const _sunos = (_platform === 'sunos');
|
||||
|
||||
const opts = {
|
||||
windowsHide: true
|
||||
@ -120,12 +121,16 @@ module.exports = function (callback) {
|
||||
if (result.maxcapacity && result.currentcapacity) {
|
||||
result.hasbattery = true;
|
||||
result.percent = percent !== -1 ? percent : Math.round(100.0 * result.currentcapacity / result.maxcapacity);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (callback) { callback(result); }
|
||||
resolve(result);
|
||||
});
|
||||
}
|
||||
if (_sunos) {
|
||||
if (callback) { callback(result); }
|
||||
resolve(result);
|
||||
}
|
||||
if (_windows) {
|
||||
exec(util.getWmic() + ' Path Win32_Battery Get BatteryStatus, DesignCapacity, EstimatedChargeRemaining /value', opts, function (error, stdout) {
|
||||
if (stdout) {
|
||||
|
||||
11
lib/cpu.js
11
lib/cpu.js
@ -24,6 +24,7 @@ const _darwin = (_platform === 'darwin');
|
||||
const _windows = (_platform === 'win32');
|
||||
const _freebsd = (_platform === 'freebsd');
|
||||
const _openbsd = (_platform === 'openbsd');
|
||||
const _sunos = (_platform === 'sunos');
|
||||
|
||||
const opts = {
|
||||
windowsHide: true
|
||||
@ -274,7 +275,7 @@ function getCpu() {
|
||||
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);
|
||||
@ -291,8 +292,8 @@ function getCpu() {
|
||||
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;
|
||||
result.cache[cacheType + 'd'] = size / 2;
|
||||
result.cache[cacheType + 'i'] = size / 2;
|
||||
} else {
|
||||
result.cache[cacheType] = size;
|
||||
}
|
||||
@ -701,8 +702,8 @@ function cpuCache(callback) {
|
||||
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;
|
||||
result.cache[cacheType + 'd'] = size / 2;
|
||||
result.cache[cacheType + 'i'] = size / 2;
|
||||
} else {
|
||||
result.cache[cacheType] = size;
|
||||
}
|
||||
|
||||
@ -23,6 +23,7 @@ const _darwin = (_platform === 'darwin');
|
||||
const _windows = (_platform === 'win32');
|
||||
const _freebsd = (_platform === 'freebsd');
|
||||
const _openbsd = (_platform === 'openbsd');
|
||||
const _sunos = (_platform === 'sunos');
|
||||
|
||||
const NOT_SUPPORTED = 'not supported';
|
||||
|
||||
@ -61,7 +62,7 @@ function fsSize(callback) {
|
||||
'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]
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -272,7 +273,7 @@ function blockDevices(callback) {
|
||||
protocol: ''
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
if (callback) {
|
||||
callback(data);
|
||||
@ -628,7 +629,7 @@ function diskLayout(callback) {
|
||||
if (_freebsd || _openbsd) {
|
||||
if (callback) { callback(result); }
|
||||
resolve(result);
|
||||
}
|
||||
}
|
||||
|
||||
if (_darwin) {
|
||||
exec('system_profiler SPSerialATADataType SPNVMeDataType', function (error, stdout) {
|
||||
@ -646,7 +647,7 @@ function diskLayout(callback) {
|
||||
let sizeValue = 0;
|
||||
if (sizeStr.indexOf('(') >= 0) {
|
||||
sizeValue = parseInt(sizeStr.match(/\(([^)]+)\)/)[1].replace(/\./g, '').replace(/,/g, ''));
|
||||
}
|
||||
}
|
||||
if (!sizeValue) {
|
||||
sizeValue = parseInt(sizeStr);
|
||||
}
|
||||
@ -682,7 +683,7 @@ function diskLayout(callback) {
|
||||
let sizeValue = 0;
|
||||
if (sizeStr.indexOf('(') >= 0) {
|
||||
sizeValue = parseInt(sizeStr.match(/\(([^)]+)\)/)[1].replace(/\./g, '').replace(/,/g, ''));
|
||||
}
|
||||
}
|
||||
if (!sizeValue) {
|
||||
sizeValue = parseInt(sizeStr);
|
||||
}
|
||||
|
||||
@ -22,6 +22,7 @@ const _darwin = (_platform === 'darwin');
|
||||
const _windows = (_platform === 'win32');
|
||||
const _freebsd = (_platform === 'freebsd');
|
||||
const _openbsd = (_platform === 'openbsd');
|
||||
const _sunos = (_platform === 'sunos');
|
||||
|
||||
const opts = {
|
||||
windowsHide: true
|
||||
@ -330,7 +331,7 @@ 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', opts, function (error, stdout) {
|
||||
|
||||
@ -102,6 +102,7 @@ let _platform = process.platform;
|
||||
const _windows = (_platform === 'win32');
|
||||
const _freebsd = (_platform === 'freebsd');
|
||||
const _openbsd = (_platform === 'openbsd');
|
||||
const _sunos = (_platform === 'sunos');
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// 1. General
|
||||
|
||||
@ -22,6 +22,7 @@ const _darwin = (_platform === 'darwin');
|
||||
const _windows = (_platform === 'win32');
|
||||
const _freebsd = (_platform === 'freebsd');
|
||||
const _openbsd = (_platform === 'openbsd');
|
||||
const _sunos = (_platform === 'sunos');
|
||||
|
||||
const opts = {
|
||||
windowsHide: true
|
||||
|
||||
@ -23,6 +23,7 @@ const _darwin = (_platform === 'darwin');
|
||||
const _windows = (_platform === 'win32');
|
||||
const _freebsd = (_platform === 'freebsd');
|
||||
const _openbsd = (_platform === 'openbsd');
|
||||
const _sunos = (_platform === 'sunos');
|
||||
|
||||
const opts = {
|
||||
windowsHide: true
|
||||
@ -164,6 +165,10 @@ function mem(callback) {
|
||||
resolve(result);
|
||||
});
|
||||
}
|
||||
if (_sunos) {
|
||||
if (callback) { callback(result); }
|
||||
resolve(result);
|
||||
}
|
||||
if (_darwin) {
|
||||
exec('vm_stat | grep "Pages active"', function (error, stdout) {
|
||||
if (!error) {
|
||||
@ -319,6 +324,10 @@ function memLayout(callback) {
|
||||
resolve(result);
|
||||
});
|
||||
}
|
||||
if (_sunos) {
|
||||
if (callback) { callback(result); }
|
||||
resolve(result);
|
||||
}
|
||||
if (_windows) {
|
||||
const memoryTypes = 'Unknown|Other|DRAM|Synchronous DRAM|Cache DRAM|EDO|EDRAM|VRAM|SRAM|RAM|ROM|FLASH|EEPROM|FEPROM|EPROM|CDRAM|3DRAM|SDRAM|SGRAM|RDRAM|DDR|DDR2|DDR2 FB-DIMM|Reserved|DDR3|FBD2|DDR4|LPDDR|LPDDR2|LPDDR3|LPDDR4'.split('|');
|
||||
const FormFactors = 'Unknown|Other|SIP|DIP|ZIP|SOJ|Proprietary|SIMM|DIMM|TSOP|PGA|RIMM|SODIMM|SRIMM|SMD|SSMP|QFP|TQFP|SOIC|LCC|PLCC|BGA|FPBGA|LGA'.split('|');
|
||||
|
||||
@ -25,6 +25,7 @@ const _darwin = (_platform === 'darwin');
|
||||
const _windows = (_platform === 'win32');
|
||||
const _freebsd = (_platform === 'freebsd');
|
||||
const _openbsd = (_platform === 'openbsd');
|
||||
const _sunos = (_platform === 'sunos');
|
||||
|
||||
const opts = {
|
||||
windowsHide: true
|
||||
|
||||
@ -23,6 +23,7 @@ const _darwin = (_platform === 'darwin');
|
||||
const _windows = (_platform === 'win32');
|
||||
const _freebsd = (_platform === 'freebsd');
|
||||
const _openbsd = (_platform === 'openbsd');
|
||||
const _sunos = (_platform === 'sunos');
|
||||
|
||||
const opts = {
|
||||
windowsHide: true
|
||||
|
||||
@ -23,6 +23,7 @@ const _darwin = (_platform === 'darwin');
|
||||
const _windows = (_platform === 'win32');
|
||||
const _freebsd = (_platform === 'freebsd');
|
||||
const _openbsd = (_platform === 'openbsd');
|
||||
const _sunos = (_platform === 'sunos');
|
||||
|
||||
const opts = {
|
||||
windowsHide: true
|
||||
@ -81,7 +82,7 @@ function services(srv, callback) {
|
||||
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) {
|
||||
@ -140,7 +141,7 @@ function services(srv, callback) {
|
||||
'pmem': 0
|
||||
});
|
||||
dataSrv.push(srv);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
let srvsMissing = srvs.filter(function (e) {
|
||||
@ -154,7 +155,7 @@ function services(srv, callback) {
|
||||
'pmem': 0
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
if (callback) { callback(data); }
|
||||
resolve(data);
|
||||
} else {
|
||||
@ -170,7 +171,7 @@ function services(srv, callback) {
|
||||
resolve(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (callback) { callback({}); }
|
||||
resolve({});
|
||||
|
||||
@ -23,6 +23,7 @@ const _darwin = (_platform === 'darwin');
|
||||
const _windows = (_platform === 'win32');
|
||||
const _freebsd = (_platform === 'freebsd');
|
||||
const _openbsd = (_platform === 'openbsd');
|
||||
const _sunos = (_platform === 'sunos');
|
||||
|
||||
const opts = {
|
||||
windowsHide: true
|
||||
@ -57,7 +58,7 @@ function system(callback) {
|
||||
if (result.model.toLowerCase().indexOf('o.e.m.') !== -1) result.model = 'Computer';
|
||||
if (result.version.toLowerCase().indexOf('o.e.m.') !== -1) result.version = '-';
|
||||
if (result.sku.toLowerCase().indexOf('o.e.m.') !== -1) result.sku = '-';
|
||||
|
||||
|
||||
if (result.manufacturer === '' && result.model === 'Computer' && result.version === '-') {
|
||||
// Check Raspberry Pi
|
||||
exec('grep Hardware /proc/cpuinfo; grep Serial /proc/cpuinfo; grep Revision /proc/cpuinfo', function (error, stdout) {
|
||||
@ -69,7 +70,7 @@ function system(callback) {
|
||||
if (line.toLowerCase().indexOf('revision') !== -1) result.version = line.split(':')[1].trim();
|
||||
if (line.toLowerCase().indexOf('serial') !== -1) result.serial = line.split(':')[1].trim();
|
||||
}
|
||||
});
|
||||
});
|
||||
if (result.model === 'BCM2835') { // Pi 3
|
||||
result.manufacturer = 'Raspberry Pi Foundation';
|
||||
result.model = result.model + ' - Pi 3 Model B';
|
||||
@ -240,7 +241,7 @@ function bios(callback) {
|
||||
result.version = description.split(' Ver: ')[1].trim();
|
||||
} else {
|
||||
result.vendor = util.getValue(lines, 'manufacturer', '=');
|
||||
result.version = util.getValue(lines, 'version', '=');
|
||||
result.version = util.getValue(lines, 'version', '=');
|
||||
}
|
||||
result.releaseDate = util.getValue(lines, 'releasedate', '=');
|
||||
if (result.releaseDate.length >= 10) {
|
||||
@ -260,7 +261,7 @@ function bios(callback) {
|
||||
exports.bios = bios;
|
||||
|
||||
function baseboard(callback) {
|
||||
|
||||
|
||||
return new Promise((resolve) => {
|
||||
process.nextTick(() => {
|
||||
|
||||
@ -320,13 +321,13 @@ function baseboard(callback) {
|
||||
result.model = util.getValue(lines, 'model', '=');
|
||||
if (!result.model) {
|
||||
result.model = util.getValue(lines, 'product', '=');
|
||||
}
|
||||
result.version = util.getValue(lines, 'version', '=');
|
||||
}
|
||||
result.version = util.getValue(lines, 'version', '=');
|
||||
result.serial = util.getValue(lines, 'serialnumber', '=');
|
||||
result.assetTag = util.getValue(lines, 'partnumber', '=');
|
||||
if (!result.assetTag) {
|
||||
result.assetTag = util.getValue(lines, 'sku', '=');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (callback) { callback(result); }
|
||||
|
||||
@ -22,6 +22,7 @@ const _darwin = (_platform === 'darwin');
|
||||
const _windows = (_platform === 'win32');
|
||||
const _freebsd = (_platform === 'freebsd');
|
||||
const _openbsd = (_platform === 'openbsd');
|
||||
const _sunos = (_platform === 'sunos');
|
||||
|
||||
const opts = {
|
||||
windowsHide: true
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user