added versions().mysql and versions().nginx, starting SunOS support
This commit is contained in:
parent
72edb106c7
commit
8a6d691684
@ -100,6 +100,7 @@ Other changes
|
||||
|
||||
| Version | Date | Comment |
|
||||
| -------------- | -------------- | -------- |
|
||||
| 3.39.0 | 2018-04-29 | added `versions().mysql` and `versions().nginx`, starting `SunOS` support (untested) |
|
||||
| 3.38.0 | 2018-04-06 | added `battery().acconnected` |
|
||||
| 3.37.12 | 2018-04-05 | another optimization `battery().ischarging` for macOS |
|
||||
| 3.37.11 | 2018-04-05 | another optimization `battery().ischarging` for macOS |
|
||||
|
||||
@ -53,13 +53,13 @@ async function cpu() {
|
||||
### Latest Activity
|
||||
|
||||
(last 7 major and minor version releases)
|
||||
- Version 3.39.0: added `versions().mysql` and `versions().nginx`, starting `SunOS` support
|
||||
- Version 3.38.0: added `battery.acconnected`
|
||||
- Version 3.37.0: extended FreeBSD support `networkStats()`
|
||||
- Version 3.36.0: extended FreeBSD support `networkConnections()`
|
||||
- Version 3.35.0: extended FreeBSD support `processLoad()`
|
||||
- Version 3.34.0: first partial FreeBSD support
|
||||
- Version 3.33.0: added bios `bios()` and main board `baseboard()` information
|
||||
- Version 3.32.0: extended `memLayout()` - added manufacturer
|
||||
- ...
|
||||
|
||||
You can find all changes here: [detailed changelog][changelog-url]
|
||||
|
||||
15
lib/cpu.js
15
lib/cpu.js
@ -302,6 +302,9 @@ function getCpu() {
|
||||
resolve(result);
|
||||
});
|
||||
}
|
||||
if (_sunos) {
|
||||
resolve(result);
|
||||
}
|
||||
if (_windows) {
|
||||
exec(util.getWmic() + ' cpu get name, description, revision, l2cachesize, l3cachesize, manufacturer, currentclockspeed, maxclockspeed /value', opts, function (error, stdout) {
|
||||
if (!error) {
|
||||
@ -538,6 +541,10 @@ function cpuTemperature(callback) {
|
||||
if (callback) { callback(result); }
|
||||
resolve(result);
|
||||
}
|
||||
if (_sunos) {
|
||||
if (callback) { callback(result); }
|
||||
resolve(result);
|
||||
}
|
||||
if (_windows) {
|
||||
exec(util.getWmic() + ' /namespace:\\\\root\\wmi PATH MSAcpi_ThermalZoneTemperature get CurrentTemperature', opts, function (error, stdout) {
|
||||
if (!error) {
|
||||
@ -640,6 +647,10 @@ function cpuFlags(callback) {
|
||||
resolve(result);
|
||||
});
|
||||
}
|
||||
if (_sunos) {
|
||||
if (callback) { callback(result); }
|
||||
resolve(result);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -737,6 +748,10 @@ function cpuCache(callback) {
|
||||
resolve(result);
|
||||
});
|
||||
}
|
||||
if (_sunos) {
|
||||
if (callback) { callback(result); }
|
||||
resolve(result);
|
||||
}
|
||||
if (_windows) {
|
||||
exec(util.getWmic() + ' cpu get l2cachesize, l3cachesize /value', opts, function (error, stdout) {
|
||||
if (!error) {
|
||||
|
||||
@ -73,6 +73,10 @@ function fsSize(callback) {
|
||||
resolve(data);
|
||||
});
|
||||
}
|
||||
if (_sunos) {
|
||||
if (callback) { callback(data); }
|
||||
resolve(data);
|
||||
}
|
||||
if (_windows) {
|
||||
exec(util.getWmic() + ' logicaldisk get Caption,FileSystem,FreeSpace,Size', opts, function (error, stdout) {
|
||||
let lines = stdout.split('\r\n').filter(line => line.trim() !== '').filter((line, idx) => idx > 0);
|
||||
@ -248,6 +252,10 @@ function blockDevices(callback) {
|
||||
resolve(data);
|
||||
});
|
||||
}
|
||||
if (_sunos) {
|
||||
if (callback) { callback(data); }
|
||||
resolve(data);
|
||||
}
|
||||
if (_windows) {
|
||||
let drivetypes = ['Unknown', 'NoRoot', 'Removable', 'HDD', 'Network', 'CD/DVD', 'RAM'];
|
||||
exec(util.getWmic() + ' logicaldisk get Caption,Description,DeviceID,DriveType,FileSystem,FreeSpace,Name,Size,VolumeName,VolumeSerialNumber /value', opts, function (error, stdout) {
|
||||
@ -490,6 +498,13 @@ function disksIO(callback) {
|
||||
}
|
||||
reject(error);
|
||||
}
|
||||
if (_sunos) {
|
||||
let error = new Error(NOT_SUPPORTED);
|
||||
if (callback) {
|
||||
callback(NOT_SUPPORTED);
|
||||
}
|
||||
reject(error);
|
||||
}
|
||||
|
||||
let result = {
|
||||
rIO: 0,
|
||||
@ -630,6 +645,10 @@ function diskLayout(callback) {
|
||||
if (callback) { callback(result); }
|
||||
resolve(result);
|
||||
}
|
||||
if (_sunos) {
|
||||
if (callback) { callback(result); }
|
||||
resolve(result);
|
||||
}
|
||||
|
||||
if (_darwin) {
|
||||
exec('system_profiler SPSerialATADataType SPNVMeDataType', function (error, stdout) {
|
||||
|
||||
@ -332,6 +332,10 @@ function graphics(callback) {
|
||||
if (callback) { callback(result); }
|
||||
resolve(result);
|
||||
}
|
||||
if (_sunos) {
|
||||
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) {
|
||||
|
||||
@ -45,7 +45,7 @@ function inetChecksite(url, callback) {
|
||||
if (url) {
|
||||
url = url.toLowerCase();
|
||||
let t = Date.now();
|
||||
if (_linux || _freebsd || _openbsd || _darwin) {
|
||||
if (_linux || _freebsd || _openbsd || _darwin || _sunos) {
|
||||
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) {
|
||||
@ -140,6 +140,22 @@ function inetLatency(host, callback) {
|
||||
resolve(result);
|
||||
});
|
||||
}
|
||||
if (_sunos) {
|
||||
exec('ping -s -a ' + host + ' 56 2 | grep avg', {timeout: 3000}, function (error, stdout) {
|
||||
let result = -1;
|
||||
if (!error) {
|
||||
const line = stdout.toString().split('=');
|
||||
if (line.length > 1) {
|
||||
const parts = line[1].split('/');
|
||||
if (parts.length > 1) {
|
||||
result = parseFloat(parts[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (callback) { callback(result); }
|
||||
resolve(result);
|
||||
});
|
||||
}
|
||||
if (_windows) {
|
||||
exec('ping ' + host + ' -n 1', opts, function (error, stdout) {
|
||||
let result = -1;
|
||||
|
||||
@ -228,6 +228,14 @@ function osInfo(callback) {
|
||||
resolve(result);
|
||||
});
|
||||
}
|
||||
if (_sunos) {
|
||||
result.logofile = getLogoFile();
|
||||
result.release = result.kernel;
|
||||
exec('uname -o', function (error, stdout) {
|
||||
let lines = stdout.toString().split('\n');
|
||||
result.distro = lines[0];
|
||||
});
|
||||
}
|
||||
if (_windows) {
|
||||
result.logofile = getLogoFile();
|
||||
result.release = result.kernel;
|
||||
@ -260,6 +268,8 @@ function versions(callback) {
|
||||
grunt: '',
|
||||
git: '',
|
||||
tsc: '',
|
||||
mysql: '',
|
||||
nginx: ''
|
||||
};
|
||||
let parts = [];
|
||||
exec('npm -v', function (error, stdout) {
|
||||
@ -298,10 +308,24 @@ function versions(callback) {
|
||||
result.git = (result.git.toLowerCase().split('version')[1] || '').trim();
|
||||
result.git = (result.git.split(' ')[0] || '').trim();
|
||||
}
|
||||
if (callback) {
|
||||
callback(result);
|
||||
}
|
||||
resolve(result);
|
||||
exec('nginx -v', function (error, stdout) {
|
||||
if (!error) {
|
||||
result.nginx = stdout.toString().split('\n')[0] || '';
|
||||
result.nginx = (result.nginx.toLowerCase().split('/')[1] || '').trim();
|
||||
}
|
||||
exec('mysql -V', function (error, stdout) {
|
||||
if (!error) {
|
||||
result.mysql = stdout.toString().split('\n')[0] || '';
|
||||
result.mysql = (result.mysql.toLowerCase().split(',')[0] || '').trim();
|
||||
const parts = result.mysql.split(' ');
|
||||
result.mysql = (parts[parts.length - 1] || '').trim();
|
||||
}
|
||||
if (callback) {
|
||||
callback(result);
|
||||
}
|
||||
resolve(result);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -313,6 +337,7 @@ function versions(callback) {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
exports.versions = versions;
|
||||
|
||||
function shell(callback) {
|
||||
|
||||
@ -479,10 +479,11 @@ function processes(callback) {
|
||||
let cmd = '';
|
||||
|
||||
if ((_process_cpu.ms && Date.now() - _process_cpu.ms >= 500) || _process_cpu.ms === 0) {
|
||||
if (_linux || _freebsd || _openbsd || _darwin) {
|
||||
if (_linux || _freebsd || _openbsd || _darwin || _sunos) {
|
||||
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';
|
||||
if (_sunos) cmd = 'ps -Ao pid,pcpu,pmem,pri,vsz,rss,nice,stime,s,tty,user,comm';
|
||||
exec(cmd, function (error, stdout) {
|
||||
if (!error) {
|
||||
result.list = parseProcesses(stdout.toString().split('\n'));
|
||||
@ -551,6 +552,9 @@ function processes(callback) {
|
||||
}
|
||||
} else {
|
||||
cmd = 'ps -o pid,vsz,rss,nice,etime,stat,tty,user,comm';
|
||||
if (_sunos) {
|
||||
cmd = 'ps -o pid,vsz,rss,nice,etime,s,tty,user,comm';
|
||||
}
|
||||
exec(cmd, function (error, stdout) {
|
||||
if (!error) {
|
||||
let lines = stdout.toString().split('\n');
|
||||
|
||||
@ -163,6 +163,10 @@ function system(callback) {
|
||||
resolve(result);
|
||||
});
|
||||
}
|
||||
if (_sunos) {
|
||||
if (callback) { callback(result); }
|
||||
resolve(result);
|
||||
}
|
||||
if (_windows) {
|
||||
// exec('wmic csproduct get', function (error, stdout) {
|
||||
// TODO: refactor /value
|
||||
|
||||
11
lib/users.js
11
lib/users.js
@ -221,6 +221,17 @@ function users(callback) {
|
||||
resolve(result);
|
||||
});
|
||||
}
|
||||
if (_sunos) {
|
||||
exec('who; echo "---"; w -h', 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) {
|
||||
|
||||
@ -51,7 +51,8 @@
|
||||
"linux",
|
||||
"win32",
|
||||
"freebsd",
|
||||
"openbsd"
|
||||
"openbsd",
|
||||
"sunos"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=4.0.0"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user