starting sunos support

This commit is contained in:
Sebastian Hildebrandt 2018-04-22 19:23:39 +02:00
parent 12d57c6943
commit 62bd03cc6c
12 changed files with 47 additions and 23 deletions

View File

@ -23,6 +23,7 @@ const _darwin = (_platform === 'darwin');
const _windows = (_platform === 'win32'); const _windows = (_platform === 'win32');
const _freebsd = (_platform === 'freebsd'); const _freebsd = (_platform === 'freebsd');
const _openbsd = (_platform === 'openbsd'); const _openbsd = (_platform === 'openbsd');
const _sunos = (_platform === 'sunos');
const opts = { const opts = {
windowsHide: true windowsHide: true
@ -120,12 +121,16 @@ module.exports = function (callback) {
if (result.maxcapacity && result.currentcapacity) { if (result.maxcapacity && result.currentcapacity) {
result.hasbattery = true; result.hasbattery = true;
result.percent = percent !== -1 ? percent : Math.round(100.0 * result.currentcapacity / result.maxcapacity); result.percent = percent !== -1 ? percent : Math.round(100.0 * result.currentcapacity / result.maxcapacity);
} }
} }
if (callback) { callback(result); } if (callback) { callback(result); }
resolve(result); resolve(result);
}); });
} }
if (_sunos) {
if (callback) { callback(result); }
resolve(result);
}
if (_windows) { if (_windows) {
exec(util.getWmic() + ' Path Win32_Battery Get BatteryStatus, DesignCapacity, EstimatedChargeRemaining /value', opts, function (error, stdout) { exec(util.getWmic() + ' Path Win32_Battery Get BatteryStatus, DesignCapacity, EstimatedChargeRemaining /value', opts, function (error, stdout) {
if (stdout) { if (stdout) {

View File

@ -24,6 +24,7 @@ const _darwin = (_platform === 'darwin');
const _windows = (_platform === 'win32'); const _windows = (_platform === 'win32');
const _freebsd = (_platform === 'freebsd'); const _freebsd = (_platform === 'freebsd');
const _openbsd = (_platform === 'openbsd'); const _openbsd = (_platform === 'openbsd');
const _sunos = (_platform === 'sunos');
const opts = { const opts = {
windowsHide: true windowsHide: true
@ -274,7 +275,7 @@ function getCpu() {
sig = sig.split(','); sig = sig.split(',');
for (var i = 0; i < sig.length; i++) { for (var i = 0; i < sig.length; i++) {
sig[i] = sig[i].trim(); sig[i] = sig[i].trim();
} }
result.family = util.getValue(sig, 'Family', ' ', true); result.family = util.getValue(sig, 'Family', ' ', true);
result.model = util.getValue(sig, 'Model', ' ', true); result.model = util.getValue(sig, 'Model', ' ', true);
result.stepping = util.getValue(sig, 'Stepping', ' ', 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))); size = size * (unit === 'kb' ? 1024 : (unit === 'mb' ? 1024 * 1024 : (unit === 'gb' ? 1024 * 1024 * 1024 : 1)));
if (cacheType) { if (cacheType) {
if (cacheType === 'l1') { if (cacheType === 'l1') {
result.cache[cacheType + 'd'] = size / 2; result.cache[cacheType + 'd'] = size / 2;
result.cache[cacheType + 'i'] = size / 2; result.cache[cacheType + 'i'] = size / 2;
} else { } else {
result.cache[cacheType] = size; 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))); size = size * (unit === 'kb' ? 1024 : (unit === 'mb' ? 1024 * 1024 : (unit === 'gb' ? 1024 * 1024 * 1024 : 1)));
if (cacheType) { if (cacheType) {
if (cacheType === 'l1') { if (cacheType === 'l1') {
result.cache[cacheType + 'd'] = size / 2; result.cache[cacheType + 'd'] = size / 2;
result.cache[cacheType + 'i'] = size / 2; result.cache[cacheType + 'i'] = size / 2;
} else { } else {
result.cache[cacheType] = size; result.cache[cacheType] = size;
} }

View File

@ -23,6 +23,7 @@ const _darwin = (_platform === 'darwin');
const _windows = (_platform === 'win32'); const _windows = (_platform === 'win32');
const _freebsd = (_platform === 'freebsd'); const _freebsd = (_platform === 'freebsd');
const _openbsd = (_platform === 'openbsd'); const _openbsd = (_platform === 'openbsd');
const _sunos = (_platform === 'sunos');
const NOT_SUPPORTED = 'not supported'; const NOT_SUPPORTED = 'not supported';
@ -61,7 +62,7 @@ function fsSize(callback) {
'used': parseInt(((_linux || _freebsd || _openbsd) ? line[3] : line[2])) * 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)), '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] 'mount': line[line.length - 1]
}); });
} }
} }
}); });
@ -272,7 +273,7 @@ function blockDevices(callback) {
protocol: '' protocol: ''
}); });
} }
}); });
} }
if (callback) { if (callback) {
callback(data); callback(data);
@ -628,7 +629,7 @@ function diskLayout(callback) {
if (_freebsd || _openbsd) { if (_freebsd || _openbsd) {
if (callback) { callback(result); } if (callback) { callback(result); }
resolve(result); resolve(result);
} }
if (_darwin) { if (_darwin) {
exec('system_profiler SPSerialATADataType SPNVMeDataType', function (error, stdout) { exec('system_profiler SPSerialATADataType SPNVMeDataType', function (error, stdout) {
@ -646,7 +647,7 @@ function diskLayout(callback) {
let sizeValue = 0; let sizeValue = 0;
if (sizeStr.indexOf('(') >= 0) { if (sizeStr.indexOf('(') >= 0) {
sizeValue = parseInt(sizeStr.match(/\(([^)]+)\)/)[1].replace(/\./g, '').replace(/,/g, '')); sizeValue = parseInt(sizeStr.match(/\(([^)]+)\)/)[1].replace(/\./g, '').replace(/,/g, ''));
} }
if (!sizeValue) { if (!sizeValue) {
sizeValue = parseInt(sizeStr); sizeValue = parseInt(sizeStr);
} }
@ -682,7 +683,7 @@ function diskLayout(callback) {
let sizeValue = 0; let sizeValue = 0;
if (sizeStr.indexOf('(') >= 0) { if (sizeStr.indexOf('(') >= 0) {
sizeValue = parseInt(sizeStr.match(/\(([^)]+)\)/)[1].replace(/\./g, '').replace(/,/g, '')); sizeValue = parseInt(sizeStr.match(/\(([^)]+)\)/)[1].replace(/\./g, '').replace(/,/g, ''));
} }
if (!sizeValue) { if (!sizeValue) {
sizeValue = parseInt(sizeStr); sizeValue = parseInt(sizeStr);
} }

View File

@ -22,6 +22,7 @@ const _darwin = (_platform === 'darwin');
const _windows = (_platform === 'win32'); const _windows = (_platform === 'win32');
const _freebsd = (_platform === 'freebsd'); const _freebsd = (_platform === 'freebsd');
const _openbsd = (_platform === 'openbsd'); const _openbsd = (_platform === 'openbsd');
const _sunos = (_platform === 'sunos');
const opts = { const opts = {
windowsHide: true windowsHide: true
@ -330,7 +331,7 @@ function graphics(callback) {
if (_freebsd || _openbsd) { if (_freebsd || _openbsd) {
if (callback) { callback(result); } if (callback) { callback(result); }
resolve(result); resolve(result);
} }
if (_windows) { if (_windows) {
// https://blogs.technet.microsoft.com/heyscriptingguy/2013/10/03/use-powershell-to-discover-multi-monitor-information/ // 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) { 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) {

View File

@ -102,6 +102,7 @@ let _platform = process.platform;
const _windows = (_platform === 'win32'); const _windows = (_platform === 'win32');
const _freebsd = (_platform === 'freebsd'); const _freebsd = (_platform === 'freebsd');
const _openbsd = (_platform === 'openbsd'); const _openbsd = (_platform === 'openbsd');
const _sunos = (_platform === 'sunos');
// ---------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------
// 1. General // 1. General

View File

@ -22,6 +22,7 @@ const _darwin = (_platform === 'darwin');
const _windows = (_platform === 'win32'); const _windows = (_platform === 'win32');
const _freebsd = (_platform === 'freebsd'); const _freebsd = (_platform === 'freebsd');
const _openbsd = (_platform === 'openbsd'); const _openbsd = (_platform === 'openbsd');
const _sunos = (_platform === 'sunos');
const opts = { const opts = {
windowsHide: true windowsHide: true

View File

@ -23,6 +23,7 @@ const _darwin = (_platform === 'darwin');
const _windows = (_platform === 'win32'); const _windows = (_platform === 'win32');
const _freebsd = (_platform === 'freebsd'); const _freebsd = (_platform === 'freebsd');
const _openbsd = (_platform === 'openbsd'); const _openbsd = (_platform === 'openbsd');
const _sunos = (_platform === 'sunos');
const opts = { const opts = {
windowsHide: true windowsHide: true
@ -164,6 +165,10 @@ function mem(callback) {
resolve(result); resolve(result);
}); });
} }
if (_sunos) {
if (callback) { callback(result); }
resolve(result);
}
if (_darwin) { if (_darwin) {
exec('vm_stat | grep "Pages active"', function (error, stdout) { exec('vm_stat | grep "Pages active"', function (error, stdout) {
if (!error) { if (!error) {
@ -319,6 +324,10 @@ function memLayout(callback) {
resolve(result); resolve(result);
}); });
} }
if (_sunos) {
if (callback) { callback(result); }
resolve(result);
}
if (_windows) { 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 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('|'); 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('|');

View File

@ -25,6 +25,7 @@ const _darwin = (_platform === 'darwin');
const _windows = (_platform === 'win32'); const _windows = (_platform === 'win32');
const _freebsd = (_platform === 'freebsd'); const _freebsd = (_platform === 'freebsd');
const _openbsd = (_platform === 'openbsd'); const _openbsd = (_platform === 'openbsd');
const _sunos = (_platform === 'sunos');
const opts = { const opts = {
windowsHide: true windowsHide: true

View File

@ -23,6 +23,7 @@ const _darwin = (_platform === 'darwin');
const _windows = (_platform === 'win32'); const _windows = (_platform === 'win32');
const _freebsd = (_platform === 'freebsd'); const _freebsd = (_platform === 'freebsd');
const _openbsd = (_platform === 'openbsd'); const _openbsd = (_platform === 'openbsd');
const _sunos = (_platform === 'sunos');
const opts = { const opts = {
windowsHide: true windowsHide: true

View File

@ -23,6 +23,7 @@ const _darwin = (_platform === 'darwin');
const _windows = (_platform === 'win32'); const _windows = (_platform === 'win32');
const _freebsd = (_platform === 'freebsd'); const _freebsd = (_platform === 'freebsd');
const _openbsd = (_platform === 'openbsd'); const _openbsd = (_platform === 'openbsd');
const _sunos = (_platform === 'sunos');
const opts = { const opts = {
windowsHide: true windowsHide: true
@ -81,7 +82,7 @@ function services(srv, callback) {
let srvs = srv.split('|'); let srvs = srv.split('|');
let data = []; let data = [];
let dataSrv = []; let dataSrv = [];
if (_linux || _freebsd || _openbsd || _darwin) { if (_linux || _freebsd || _openbsd || _darwin) {
let comm = (_darwin) ? 'ps -caxm -o pcpu,pmem,comm' : 'ps axo pcpu,pmem,comm'; let comm = (_darwin) ? 'ps -caxm -o pcpu,pmem,comm' : 'ps axo pcpu,pmem,comm';
if (srv !== '' && srvs.length > 0) { if (srv !== '' && srvs.length > 0) {
@ -140,7 +141,7 @@ function services(srv, callback) {
'pmem': 0 'pmem': 0
}); });
dataSrv.push(srv); dataSrv.push(srv);
} }
} }
} }
let srvsMissing = srvs.filter(function (e) { let srvsMissing = srvs.filter(function (e) {
@ -154,7 +155,7 @@ function services(srv, callback) {
'pmem': 0 'pmem': 0
}); });
}); });
if (callback) { callback(data); } if (callback) { callback(data); }
resolve(data); resolve(data);
} else { } else {
@ -170,7 +171,7 @@ function services(srv, callback) {
resolve(data); resolve(data);
} }
}); });
} }
} else { } else {
if (callback) { callback({}); } if (callback) { callback({}); }
resolve({}); resolve({});

View File

@ -23,6 +23,7 @@ const _darwin = (_platform === 'darwin');
const _windows = (_platform === 'win32'); const _windows = (_platform === 'win32');
const _freebsd = (_platform === 'freebsd'); const _freebsd = (_platform === 'freebsd');
const _openbsd = (_platform === 'openbsd'); const _openbsd = (_platform === 'openbsd');
const _sunos = (_platform === 'sunos');
const opts = { const opts = {
windowsHide: true windowsHide: true
@ -57,7 +58,7 @@ function system(callback) {
if (result.model.toLowerCase().indexOf('o.e.m.') !== -1) result.model = 'Computer'; 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.version.toLowerCase().indexOf('o.e.m.') !== -1) result.version = '-';
if (result.sku.toLowerCase().indexOf('o.e.m.') !== -1) result.sku = '-'; if (result.sku.toLowerCase().indexOf('o.e.m.') !== -1) result.sku = '-';
if (result.manufacturer === '' && result.model === 'Computer' && result.version === '-') { if (result.manufacturer === '' && result.model === 'Computer' && result.version === '-') {
// Check Raspberry Pi // Check Raspberry Pi
exec('grep Hardware /proc/cpuinfo; grep Serial /proc/cpuinfo; grep Revision /proc/cpuinfo', function (error, stdout) { 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('revision') !== -1) result.version = line.split(':')[1].trim();
if (line.toLowerCase().indexOf('serial') !== -1) result.serial = line.split(':')[1].trim(); if (line.toLowerCase().indexOf('serial') !== -1) result.serial = line.split(':')[1].trim();
} }
}); });
if (result.model === 'BCM2835') { // Pi 3 if (result.model === 'BCM2835') { // Pi 3
result.manufacturer = 'Raspberry Pi Foundation'; result.manufacturer = 'Raspberry Pi Foundation';
result.model = result.model + ' - Pi 3 Model B'; result.model = result.model + ' - Pi 3 Model B';
@ -240,7 +241,7 @@ function bios(callback) {
result.version = description.split(' Ver: ')[1].trim(); result.version = description.split(' Ver: ')[1].trim();
} else { } else {
result.vendor = util.getValue(lines, 'manufacturer', '='); result.vendor = util.getValue(lines, 'manufacturer', '=');
result.version = util.getValue(lines, 'version', '='); result.version = util.getValue(lines, 'version', '=');
} }
result.releaseDate = util.getValue(lines, 'releasedate', '='); result.releaseDate = util.getValue(lines, 'releasedate', '=');
if (result.releaseDate.length >= 10) { if (result.releaseDate.length >= 10) {
@ -260,7 +261,7 @@ function bios(callback) {
exports.bios = bios; exports.bios = bios;
function baseboard(callback) { function baseboard(callback) {
return new Promise((resolve) => { return new Promise((resolve) => {
process.nextTick(() => { process.nextTick(() => {
@ -320,13 +321,13 @@ function baseboard(callback) {
result.model = util.getValue(lines, 'model', '='); result.model = util.getValue(lines, 'model', '=');
if (!result.model) { if (!result.model) {
result.model = util.getValue(lines, 'product', '='); 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.serial = util.getValue(lines, 'serialnumber', '=');
result.assetTag = util.getValue(lines, 'partnumber', '='); result.assetTag = util.getValue(lines, 'partnumber', '=');
if (!result.assetTag) { if (!result.assetTag) {
result.assetTag = util.getValue(lines, 'sku', '='); result.assetTag = util.getValue(lines, 'sku', '=');
} }
} }
if (callback) { callback(result); } if (callback) { callback(result); }

View File

@ -22,6 +22,7 @@ const _darwin = (_platform === 'darwin');
const _windows = (_platform === 'win32'); const _windows = (_platform === 'win32');
const _freebsd = (_platform === 'freebsd'); const _freebsd = (_platform === 'freebsd');
const _openbsd = (_platform === 'openbsd'); const _openbsd = (_platform === 'openbsd');
const _sunos = (_platform === 'sunos');
const opts = { const opts = {
windowsHide: true windowsHide: true