diff --git a/lib/battery.js b/lib/battery.js index 4933098..9657205 100644 --- a/lib/battery.js +++ b/lib/battery.js @@ -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) { diff --git a/lib/cpu.js b/lib/cpu.js index 7953948..6906b43 100644 --- a/lib/cpu.js +++ b/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; } diff --git a/lib/filesystem.js b/lib/filesystem.js index 3fb2fe6..99d2bc8 100644 --- a/lib/filesystem.js +++ b/lib/filesystem.js @@ -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); } diff --git a/lib/graphics.js b/lib/graphics.js index 6987620..5a2e1c9 100644 --- a/lib/graphics.js +++ b/lib/graphics.js @@ -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) { diff --git a/lib/index.js b/lib/index.js index f8e2b5c..cd1f261 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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 diff --git a/lib/internet.js b/lib/internet.js index d969942..8754cc0 100644 --- a/lib/internet.js +++ b/lib/internet.js @@ -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 diff --git a/lib/memory.js b/lib/memory.js index f9bce8a..155c7d0 100644 --- a/lib/memory.js +++ b/lib/memory.js @@ -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('|'); diff --git a/lib/network.js b/lib/network.js index 5f541ca..7f61a85 100644 --- a/lib/network.js +++ b/lib/network.js @@ -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 diff --git a/lib/osinfo.js b/lib/osinfo.js index a08dd3e..35372df 100644 --- a/lib/osinfo.js +++ b/lib/osinfo.js @@ -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 diff --git a/lib/processes.js b/lib/processes.js index ee72aa2..32cb3da 100644 --- a/lib/processes.js +++ b/lib/processes.js @@ -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({}); diff --git a/lib/system.js b/lib/system.js index 726cbb9..0a3d0ba 100644 --- a/lib/system.js +++ b/lib/system.js @@ -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); } diff --git a/lib/users.js b/lib/users.js index e091e57..4904040 100644 --- a/lib/users.js +++ b/lib/users.js @@ -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