updated docs
This commit is contained in:
parent
d52fb6f520
commit
f93e8a622f
24
README.md
24
README.md
@ -235,10 +235,10 @@ and above.
|
||||
|
||||
I was able to test it on several Debian, Raspbian, Ubuntu distributions as well
|
||||
as macOS (Mavericks, Yosemite, El Captain, Sierra, High Sierra, Mojave,
|
||||
Catalina, Big Sur) and some Windows 7, Windows 8, Windows 10, FreeBSD, OpenBSD,
|
||||
NetBSD and SunOS machines. Not all functions are supported on all operating
|
||||
systems. Have a look at the function reference in the docs to get further
|
||||
details.
|
||||
Catalina, Big Sur, Monterey, Ventura, Sonoma, Sequoia, Tahoe) and some Windows 7,
|
||||
Windows 8, Windows 10, Windows 11, FreeBSD, OpenBSD, NetBSD and SunOS machines.
|
||||
Not all functions are supported on all operating systems. Have a look at the
|
||||
function reference in the docs to get further details.
|
||||
|
||||
If you have comments, suggestions & reports, please feel free to contact me!
|
||||
|
||||
@ -1018,21 +1018,27 @@ async function cpuData() {
|
||||
|
||||
#### macOS - Temperature Sensor
|
||||
|
||||
To be able to measure temperature on macOS I created a little additional
|
||||
package. Due to some difficulties in NPM with `optionalDependencies` I
|
||||
To be able to measure temperature on macOS I created two little additional
|
||||
packages. Due to some difficulties in NPM with `optionalDependencies` I
|
||||
unfortunately was getting unexpected warnings on other platforms. So I decided
|
||||
to drop this optional dependency for macOS - so by default, you will not get
|
||||
correct values.
|
||||
|
||||
This additional package is now also supporting Apple Silicon M1/M2/M3 machines.
|
||||
|
||||
But if you need to detect macOS temperature just run the following additional
|
||||
installation command:
|
||||
|
||||
For Intel based machines (deprecated lib) install
|
||||
|
||||
```bash
|
||||
$ npm install osx-temperature-sensor --save
|
||||
```
|
||||
|
||||
For Apple Silicon (ARM) based machines install
|
||||
|
||||
```bash
|
||||
$ npm install macos-temperature-sensor --save
|
||||
```
|
||||
|
||||
`systeminformation` will then detect this additional library and return the
|
||||
temperature when calling systeminformations standard function `cpuTemperature()`
|
||||
|
||||
@ -1163,7 +1169,7 @@ trademark of Fabrice Bellard, bochs is a trademark of The Bochs Project, USB and
|
||||
USB Logo are trademarks of USB Implementation Forum, Bluetooth and Bluetooth
|
||||
Logo are trademarks of Bluetooth SIG, Android is a trademark of Google LLC,
|
||||
Parallels is a trademarks of Parallels International GmbH. Bun is a trademark of
|
||||
Codeblog Corp. Deno is a trademark of Deno Land Inc.
|
||||
Codeblog Corp. Deno is a trademark of Deno Land Inc. Arm is a trademark of Arm Limited.
|
||||
|
||||
All other trademarks are the property of their respective owners.
|
||||
|
||||
|
||||
@ -50,6 +50,7 @@
|
||||
<li><strong>AMD</strong> is a trademark of Advanced Micro Devices Inc.</li>
|
||||
<li><strong>Android</strong> is a trademark of Google LLC.</li>
|
||||
<li><strong>Apple, macOS, OS X, CUPS</strong> are registered trademarks of Apple Inc.</li>
|
||||
<li><strong>Arm</strong> is a trademark of Arm Limited</li>
|
||||
<li><strong>ASUS</strong> is a registered trademark of ASUSTeK Computer.</li>
|
||||
<li><strong>Bluetooth and Bluetooth Logo</strong> are trademarks of Bluetooth SIG..</li>
|
||||
<li><strong>bochs</strong> is a trademark of The Bochs Project</li>
|
||||
|
||||
65
lib/index.js
65
lib/index.js
@ -42,12 +42,12 @@ const usb = require('./usb');
|
||||
const audio = require('./audio');
|
||||
const bluetooth = require('./bluetooth');
|
||||
|
||||
let _platform = process.platform;
|
||||
const _windows = (_platform === 'win32');
|
||||
const _freebsd = (_platform === 'freebsd');
|
||||
const _openbsd = (_platform === 'openbsd');
|
||||
const _netbsd = (_platform === 'netbsd');
|
||||
const _sunos = (_platform === 'sunos');
|
||||
const _platform = process.platform;
|
||||
const _windows = _platform === 'win32';
|
||||
const _freebsd = _platform === 'freebsd';
|
||||
const _openbsd = _platform === 'openbsd';
|
||||
const _netbsd = _platform === 'netbsd';
|
||||
const _sunos = _platform === 'sunos';
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// init
|
||||
@ -74,11 +74,9 @@ function version() {
|
||||
// get static data - they should not change until restarted
|
||||
|
||||
function getStaticData(callback) {
|
||||
|
||||
return new Promise((resolve) => {
|
||||
process.nextTick(() => {
|
||||
|
||||
let data = {};
|
||||
const data = {};
|
||||
|
||||
data.version = version();
|
||||
|
||||
@ -99,7 +97,7 @@ function getStaticData(callback) {
|
||||
audio.audio(),
|
||||
bluetooth.bluetoothDevices(),
|
||||
usb.usb(),
|
||||
printer.printer(),
|
||||
printer.printer()
|
||||
]).then((res) => {
|
||||
data.system = res[0];
|
||||
data.bios = res[1];
|
||||
@ -118,14 +116,15 @@ function getStaticData(callback) {
|
||||
data.bluetooth = res[14];
|
||||
data.usb = res[15];
|
||||
data.printer = res[16];
|
||||
if (callback) { callback(data); }
|
||||
if (callback) {
|
||||
callback(data);
|
||||
}
|
||||
resolve(data);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// --------------------------
|
||||
// get all dynamic data - e.g. for monitoring agents
|
||||
// may take some seconds to get all data
|
||||
@ -135,7 +134,6 @@ function getStaticData(callback) {
|
||||
// - iface: define network interface for which you like to monitor network speed e.g. "eth0"
|
||||
|
||||
function getDynamicData(srv, iface, callback) {
|
||||
|
||||
if (util.isFunction(iface)) {
|
||||
callback = iface;
|
||||
iface = '';
|
||||
@ -147,16 +145,21 @@ function getDynamicData(srv, iface, callback) {
|
||||
|
||||
return new Promise((resolve) => {
|
||||
process.nextTick(() => {
|
||||
|
||||
iface = iface || network.getDefaultNetworkInterface();
|
||||
srv = srv || '';
|
||||
|
||||
// use closure to track ƒ completion
|
||||
let functionProcessed = (function () {
|
||||
let functionProcessed = (() => {
|
||||
let totalFunctions = 15;
|
||||
if (_windows) { totalFunctions = 13; }
|
||||
if (_freebsd || _openbsd || _netbsd) { totalFunctions = 11; }
|
||||
if (_sunos) { totalFunctions = 6; }
|
||||
if (_windows) {
|
||||
totalFunctions = 13;
|
||||
}
|
||||
if (_freebsd || _openbsd || _netbsd) {
|
||||
totalFunctions = 11;
|
||||
}
|
||||
if (_sunos) {
|
||||
totalFunctions = 6;
|
||||
}
|
||||
|
||||
return function () {
|
||||
if (--totalFunctions === 0) {
|
||||
@ -168,7 +171,7 @@ function getDynamicData(srv, iface, callback) {
|
||||
};
|
||||
})();
|
||||
|
||||
let data = {};
|
||||
const data = {};
|
||||
|
||||
// get time
|
||||
data.time = osInfo.time();
|
||||
@ -286,7 +289,6 @@ function getDynamicData(srv, iface, callback) {
|
||||
// - iface: define network interface for which you like to monitor network speed e.g. "eth0"
|
||||
|
||||
function getAllData(srv, iface, callback) {
|
||||
|
||||
return new Promise((resolve) => {
|
||||
process.nextTick(() => {
|
||||
let data = {};
|
||||
@ -310,7 +312,9 @@ function getAllData(srv, iface, callback) {
|
||||
data[key] = res[key];
|
||||
}
|
||||
}
|
||||
if (callback) { callback(data); }
|
||||
if (callback) {
|
||||
callback(data);
|
||||
}
|
||||
resolve(data);
|
||||
});
|
||||
});
|
||||
@ -322,8 +326,8 @@ function get(valueObject, callback) {
|
||||
return new Promise((resolve) => {
|
||||
process.nextTick(() => {
|
||||
const allPromises = Object.keys(valueObject)
|
||||
.filter(func => ({}.hasOwnProperty.call(exports, func)))
|
||||
.map(func => {
|
||||
.filter((func) => ({}).hasOwnProperty.call(exports, func))
|
||||
.map((func) => {
|
||||
const params = valueObject[func].substring(valueObject[func].lastIndexOf('(') + 1, valueObject[func].lastIndexOf(')'));
|
||||
let funcWithoutParams = func.indexOf(')') >= 0 ? func.split(')')[1].trim() : func;
|
||||
funcWithoutParams = func.indexOf('|') >= 0 ? func.split('|')[0].trim() : funcWithoutParams;
|
||||
@ -361,12 +365,12 @@ function get(valueObject, callback) {
|
||||
if (Array.isArray(data[i])) {
|
||||
// result is in an array, go through all elements of array and pick only the right ones
|
||||
const partialArray = [];
|
||||
data[i].forEach(element => {
|
||||
data[i].forEach((element) => {
|
||||
let partialRes = {};
|
||||
if (keys.length === 1 && (keys[0] === '*' || keys[0] === 'all')) {
|
||||
partialRes = element;
|
||||
} else {
|
||||
keys.forEach(k => {
|
||||
keys.forEach((k) => {
|
||||
if ({}.hasOwnProperty.call(element, k)) {
|
||||
partialRes[k] = element[k];
|
||||
}
|
||||
@ -376,11 +380,11 @@ function get(valueObject, callback) {
|
||||
if (filter && filterParts.length === 2) {
|
||||
if ({}.hasOwnProperty.call(partialRes, filterParts[0].trim())) {
|
||||
const val = partialRes[filterParts[0].trim()];
|
||||
if (typeof val == 'number') {
|
||||
if (typeof val === 'number') {
|
||||
if (val === parseFloat(filterParts[1].trim())) {
|
||||
partialArray.push(partialRes);
|
||||
}
|
||||
} else if (typeof val == 'string') {
|
||||
} else if (typeof val === 'string') {
|
||||
if (val.toLowerCase() === filterParts[1].trim().toLowerCase()) {
|
||||
partialArray.push(partialRes);
|
||||
}
|
||||
@ -389,12 +393,11 @@ function get(valueObject, callback) {
|
||||
} else {
|
||||
partialArray.push(partialRes);
|
||||
}
|
||||
|
||||
});
|
||||
result[key] = partialArray;
|
||||
} else {
|
||||
const partialRes = {};
|
||||
keys.forEach(k => {
|
||||
keys.forEach((k) => {
|
||||
if ({}.hasOwnProperty.call(data[i], k)) {
|
||||
partialRes[k] = data[i][k];
|
||||
}
|
||||
@ -408,7 +411,9 @@ function get(valueObject, callback) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (callback) { callback(result); }
|
||||
if (callback) {
|
||||
callback(result);
|
||||
}
|
||||
resolve(result);
|
||||
});
|
||||
});
|
||||
|
||||
272
lib/osinfo.js
272
lib/osinfo.js
@ -21,13 +21,13 @@ const execSync = require('child_process').execSync;
|
||||
|
||||
let _platform = process.platform;
|
||||
|
||||
const _linux = (_platform === 'linux' || _platform === 'android');
|
||||
const _darwin = (_platform === 'darwin');
|
||||
const _windows = (_platform === 'win32');
|
||||
const _freebsd = (_platform === 'freebsd');
|
||||
const _openbsd = (_platform === 'openbsd');
|
||||
const _netbsd = (_platform === 'netbsd');
|
||||
const _sunos = (_platform === 'sunos');
|
||||
const _linux = _platform === 'linux' || _platform === 'android';
|
||||
const _darwin = _platform === 'darwin';
|
||||
const _windows = _platform === 'win32';
|
||||
const _freebsd = _platform === 'freebsd';
|
||||
const _openbsd = _platform === 'openbsd';
|
||||
const _netbsd = _platform === 'netbsd';
|
||||
const _sunos = _platform === 'sunos';
|
||||
|
||||
// --------------------------
|
||||
// Get current time and OS uptime
|
||||
@ -38,12 +38,12 @@ function time() {
|
||||
try {
|
||||
timezoneName = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||
} catch {
|
||||
timezoneName = (t.length >= 7) ? t.slice(6).join(' ').replace(/\(/g, '').replace(/\)/g, '') : '';
|
||||
timezoneName = t.length >= 7 ? t.slice(6).join(' ').replace(/\(/g, '').replace(/\)/g, '') : '';
|
||||
}
|
||||
const result = {
|
||||
current: Date.now(),
|
||||
uptime: os.uptime(),
|
||||
timezone: (t.length >= 7) ? t[5] : '',
|
||||
timezone: t.length >= 7 ? t[5] : '',
|
||||
timezoneName
|
||||
};
|
||||
if (_darwin || _linux) {
|
||||
@ -61,7 +61,7 @@ function time() {
|
||||
current: Date.now(),
|
||||
uptime: os.uptime(),
|
||||
timezone: lines[1] ? timezone + lines[1] : timezone,
|
||||
timezoneName: lines[2] && lines[2].indexOf('/zoneinfo/') > 0 ? (lines[2].split('/zoneinfo/')[1] || '') : ''
|
||||
timezoneName: lines[2] && lines[2].indexOf('/zoneinfo/') > 0 ? lines[2].split('/zoneinfo/')[1] || '' : ''
|
||||
};
|
||||
} catch (e) {
|
||||
util.noop();
|
||||
@ -81,116 +81,79 @@ function getLogoFile(distro) {
|
||||
let result = _platform;
|
||||
if (_windows) {
|
||||
result = 'windows';
|
||||
}
|
||||
else if (distro.indexOf('mac os') !== -1 || distro.indexOf('macos') !== -1) {
|
||||
} else if (distro.indexOf('mac os') !== -1 || distro.indexOf('macos') !== -1) {
|
||||
result = 'apple';
|
||||
}
|
||||
else if (distro.indexOf('arch') !== -1) {
|
||||
} else if (distro.indexOf('arch') !== -1) {
|
||||
result = 'arch';
|
||||
}
|
||||
else if (distro.indexOf('cachy') !== -1) {
|
||||
} else if (distro.indexOf('cachy') !== -1) {
|
||||
result = 'cachy';
|
||||
}
|
||||
else if (distro.indexOf('centos') !== -1) {
|
||||
} else if (distro.indexOf('centos') !== -1) {
|
||||
result = 'centos';
|
||||
}
|
||||
else if (distro.indexOf('coreos') !== -1) {
|
||||
} else if (distro.indexOf('coreos') !== -1) {
|
||||
result = 'coreos';
|
||||
}
|
||||
else if (distro.indexOf('debian') !== -1) {
|
||||
} else if (distro.indexOf('debian') !== -1) {
|
||||
result = 'debian';
|
||||
}
|
||||
else if (distro.indexOf('deepin') !== -1) {
|
||||
} else if (distro.indexOf('deepin') !== -1) {
|
||||
result = 'deepin';
|
||||
}
|
||||
else if (distro.indexOf('elementary') !== -1) {
|
||||
} else if (distro.indexOf('elementary') !== -1) {
|
||||
result = 'elementary';
|
||||
}
|
||||
else if (distro.indexOf('endeavour') !== -1) {
|
||||
} else if (distro.indexOf('endeavour') !== -1) {
|
||||
result = 'endeavour';
|
||||
}
|
||||
else if (distro.indexOf('fedora') !== -1) {
|
||||
} else if (distro.indexOf('fedora') !== -1) {
|
||||
result = 'fedora';
|
||||
}
|
||||
else if (distro.indexOf('gentoo') !== -1) {
|
||||
} else if (distro.indexOf('gentoo') !== -1) {
|
||||
result = 'gentoo';
|
||||
}
|
||||
else if (distro.indexOf('mageia') !== -1) {
|
||||
} else if (distro.indexOf('mageia') !== -1) {
|
||||
result = 'mageia';
|
||||
}
|
||||
else if (distro.indexOf('mandriva') !== -1) {
|
||||
} else if (distro.indexOf('mandriva') !== -1) {
|
||||
result = 'mandriva';
|
||||
}
|
||||
else if (distro.indexOf('manjaro') !== -1) {
|
||||
} else if (distro.indexOf('manjaro') !== -1) {
|
||||
result = 'manjaro';
|
||||
}
|
||||
else if (distro.indexOf('mint') !== -1) {
|
||||
} else if (distro.indexOf('mint') !== -1) {
|
||||
result = 'mint';
|
||||
}
|
||||
else if (distro.indexOf('mx') !== -1) {
|
||||
} else if (distro.indexOf('mx') !== -1) {
|
||||
result = 'mx';
|
||||
}
|
||||
else if (distro.indexOf('openbsd') !== -1) {
|
||||
} else if (distro.indexOf('openbsd') !== -1) {
|
||||
result = 'openbsd';
|
||||
}
|
||||
else if (distro.indexOf('freebsd') !== -1) {
|
||||
} else if (distro.indexOf('freebsd') !== -1) {
|
||||
result = 'freebsd';
|
||||
}
|
||||
else if (distro.indexOf('opensuse') !== -1) {
|
||||
} else if (distro.indexOf('opensuse') !== -1) {
|
||||
result = 'opensuse';
|
||||
}
|
||||
else if (distro.indexOf('pclinuxos') !== -1) {
|
||||
} else if (distro.indexOf('pclinuxos') !== -1) {
|
||||
result = 'pclinuxos';
|
||||
}
|
||||
else if (distro.indexOf('puppy') !== -1) {
|
||||
} else if (distro.indexOf('puppy') !== -1) {
|
||||
result = 'puppy';
|
||||
}
|
||||
else if (distro.indexOf('popos') !== -1) {
|
||||
} else if (distro.indexOf('popos') !== -1) {
|
||||
result = 'popos';
|
||||
}
|
||||
else if (distro.indexOf('raspbian') !== -1) {
|
||||
} else if (distro.indexOf('raspbian') !== -1) {
|
||||
result = 'raspbian';
|
||||
}
|
||||
else if (distro.indexOf('reactos') !== -1) {
|
||||
} else if (distro.indexOf('reactos') !== -1) {
|
||||
result = 'reactos';
|
||||
}
|
||||
else if (distro.indexOf('redhat') !== -1) {
|
||||
} else if (distro.indexOf('redhat') !== -1) {
|
||||
result = 'redhat';
|
||||
}
|
||||
else if (distro.indexOf('slackware') !== -1) {
|
||||
} else if (distro.indexOf('slackware') !== -1) {
|
||||
result = 'slackware';
|
||||
}
|
||||
else if (distro.indexOf('sugar') !== -1) {
|
||||
} else if (distro.indexOf('sugar') !== -1) {
|
||||
result = 'sugar';
|
||||
}
|
||||
else if (distro.indexOf('steam') !== -1) {
|
||||
} else if (distro.indexOf('steam') !== -1) {
|
||||
result = 'steam';
|
||||
}
|
||||
else if (distro.indexOf('suse') !== -1) {
|
||||
} else if (distro.indexOf('suse') !== -1) {
|
||||
result = 'suse';
|
||||
}
|
||||
else if (distro.indexOf('mate') !== -1) {
|
||||
} else if (distro.indexOf('mate') !== -1) {
|
||||
result = 'ubuntu-mate';
|
||||
}
|
||||
else if (distro.indexOf('lubuntu') !== -1) {
|
||||
} else if (distro.indexOf('lubuntu') !== -1) {
|
||||
result = 'lubuntu';
|
||||
}
|
||||
else if (distro.indexOf('xubuntu') !== -1) {
|
||||
} else if (distro.indexOf('xubuntu') !== -1) {
|
||||
result = 'xubuntu';
|
||||
}
|
||||
else if (distro.indexOf('ubuntu') !== -1) {
|
||||
} else if (distro.indexOf('ubuntu') !== -1) {
|
||||
result = 'ubuntu';
|
||||
}
|
||||
else if (distro.indexOf('solaris') !== -1) {
|
||||
} else if (distro.indexOf('solaris') !== -1) {
|
||||
result = 'solaris';
|
||||
}
|
||||
else if (distro.indexOf('tails') !== -1) {
|
||||
} else if (distro.indexOf('tails') !== -1) {
|
||||
result = 'tails';
|
||||
}
|
||||
else if (distro.indexOf('feren') !== -1) {
|
||||
} else if (distro.indexOf('feren') !== -1) {
|
||||
result = 'ferenos';
|
||||
}
|
||||
else if (distro.indexOf('robolinux') !== -1) {
|
||||
} else if (distro.indexOf('robolinux') !== -1) {
|
||||
result = 'robolinux';
|
||||
} else if (_linux && distro) {
|
||||
result = distro.toLowerCase().trim().replace(/\s+/g, '-');
|
||||
@ -234,12 +197,10 @@ function getFQDN() {
|
||||
// OS Information
|
||||
|
||||
function osInfo(callback) {
|
||||
|
||||
return new Promise((resolve) => {
|
||||
process.nextTick(() => {
|
||||
let result = {
|
||||
|
||||
platform: (_platform === 'win32' ? 'Windows' : _platform),
|
||||
platform: _platform === 'win32' ? 'Windows' : _platform,
|
||||
distro: 'unknown',
|
||||
release: 'unknown',
|
||||
codename: '',
|
||||
@ -256,7 +217,6 @@ function osInfo(callback) {
|
||||
};
|
||||
|
||||
if (_linux) {
|
||||
|
||||
exec('cat /etc/*-release; cat /usr/lib/os-release; cat /etc/openwrt_release', function (error, stdout) {
|
||||
/**
|
||||
* @namespace
|
||||
@ -289,7 +249,7 @@ function osInfo(callback) {
|
||||
result.codename = codename;
|
||||
result.codepage = util.getCodepage();
|
||||
result.build = (release.BUILD_ID || '').replace(/"/g, '').trim();
|
||||
isUefiLinux().then(uefi => {
|
||||
isUefiLinux().then((uefi) => {
|
||||
result.uefi = uefi;
|
||||
uuid().then((data) => {
|
||||
result.serial = data.os;
|
||||
@ -302,7 +262,6 @@ function osInfo(callback) {
|
||||
});
|
||||
}
|
||||
if (_freebsd || _openbsd || _netbsd) {
|
||||
|
||||
exec('sysctl kern.ostype kern.osrelease kern.osrevision kern.hostuuid machdep.bootmethod kern.geom.confxml', function (error, stdout) {
|
||||
let lines = stdout.toString().split('\n');
|
||||
const distro = util.getValue(lines, 'kern.ostype');
|
||||
@ -311,7 +270,7 @@ function osInfo(callback) {
|
||||
const serial = util.getValue(lines, 'kern.uuid');
|
||||
const bootmethod = util.getValue(lines, 'machdep.bootmethod');
|
||||
const uefiConf = stdout.toString().indexOf('<type>efi</type>') >= 0;
|
||||
const uefi = bootmethod ? bootmethod.toLowerCase().indexOf('uefi') >= 0 : (uefiConf ? uefiConf : null);
|
||||
const uefi = bootmethod ? bootmethod.toLowerCase().indexOf('uefi') >= 0 : uefiConf ? uefiConf : null;
|
||||
result.distro = distro || result.distro;
|
||||
result.logofile = logofile || result.logofile;
|
||||
result.release = release || result.release;
|
||||
@ -334,25 +293,24 @@ function osInfo(callback) {
|
||||
result.build = util.getValue(lines, 'BuildVersion');
|
||||
result.logofile = getLogoFile(result.distro);
|
||||
result.codename = 'macOS';
|
||||
result.codename = (result.release.indexOf('10.4') > -1 ? 'OS X Tiger' : result.codename);
|
||||
result.codename = (result.release.indexOf('10.5') > -1 ? 'OS X Leopard' : result.codename);
|
||||
result.codename = (result.release.indexOf('10.6') > -1 ? 'OS X Snow Leopard' : result.codename);
|
||||
result.codename = (result.release.indexOf('10.7') > -1 ? 'OS X Lion' : result.codename);
|
||||
result.codename = (result.release.indexOf('10.8') > -1 ? 'OS X Mountain Lion' : result.codename);
|
||||
result.codename = (result.release.indexOf('10.9') > -1 ? 'OS X Mavericks' : result.codename);
|
||||
result.codename = (result.release.indexOf('10.10') > -1 ? 'OS X Yosemite' : result.codename);
|
||||
result.codename = (result.release.indexOf('10.11') > -1 ? 'OS X El Capitan' : result.codename);
|
||||
result.codename = (result.release.indexOf('10.12') > -1 ? 'Sierra' : result.codename);
|
||||
result.codename = (result.release.indexOf('10.13') > -1 ? 'High Sierra' : result.codename);
|
||||
result.codename = (result.release.indexOf('10.14') > -1 ? 'Mojave' : result.codename);
|
||||
result.codename = (result.release.indexOf('10.15') > -1 ? 'Catalina' : result.codename);
|
||||
result.codename = (result.release.startsWith('11.') ? 'Big Sur' : result.codename);
|
||||
result.codename = (result.release.startsWith('12.') ? 'Monterey' : result.codename);
|
||||
result.codename = (result.release.startsWith('13.') ? 'Ventura' : result.codename);
|
||||
result.codename = (result.release.startsWith('14.') ? 'Sonoma' : result.codename);
|
||||
result.codename = (result.release.startsWith('15.') ? 'Sequoia' : result.codename);
|
||||
result.codename = (result.release.startsWith('16.') ? 'Tahoe' : result.codename);
|
||||
result.codename = (result.release.startsWith('26.') ? 'Tahoe' : result.codename);
|
||||
result.codename = result.release.indexOf('10.4') > -1 ? 'OS X Tiger' : result.codename;
|
||||
result.codename = result.release.indexOf('10.5') > -1 ? 'OS X Leopard' : result.codename;
|
||||
result.codename = result.release.indexOf('10.6') > -1 ? 'OS X Snow Leopard' : result.codename;
|
||||
result.codename = result.release.indexOf('10.7') > -1 ? 'OS X Lion' : result.codename;
|
||||
result.codename = result.release.indexOf('10.8') > -1 ? 'OS X Mountain Lion' : result.codename;
|
||||
result.codename = result.release.indexOf('10.9') > -1 ? 'OS X Mavericks' : result.codename;
|
||||
result.codename = result.release.indexOf('10.10') > -1 ? 'OS X Yosemite' : result.codename;
|
||||
result.codename = result.release.indexOf('10.11') > -1 ? 'OS X El Capitan' : result.codename;
|
||||
result.codename = result.release.indexOf('10.12') > -1 ? 'Sierra' : result.codename;
|
||||
result.codename = result.release.indexOf('10.13') > -1 ? 'High Sierra' : result.codename;
|
||||
result.codename = result.release.indexOf('10.14') > -1 ? 'Mojave' : result.codename;
|
||||
result.codename = result.release.indexOf('10.15') > -1 ? 'Catalina' : result.codename;
|
||||
result.codename = result.release.startsWith('11.') ? 'Big Sur' : result.codename;
|
||||
result.codename = result.release.startsWith('12.') ? 'Monterey' : result.codename;
|
||||
result.codename = result.release.startsWith('13.') ? 'Ventura' : result.codename;
|
||||
result.codename = result.release.startsWith('14.') ? 'Sonoma' : result.codename;
|
||||
result.codename = result.release.startsWith('15.') ? 'Sequoia' : result.codename;
|
||||
result.codename = result.release.startsWith('26.') ? 'Tahoe' : result.codename;
|
||||
result.uefi = true;
|
||||
result.codepage = util.getCodepage();
|
||||
if (callback) {
|
||||
@ -367,7 +325,9 @@ function osInfo(callback) {
|
||||
let lines = stdout.toString().split('\n');
|
||||
result.distro = lines[0];
|
||||
result.logofile = getLogoFile(result.distro);
|
||||
if (callback) { callback(result); }
|
||||
if (callback) {
|
||||
callback(result);
|
||||
}
|
||||
resolve(result);
|
||||
});
|
||||
}
|
||||
@ -379,9 +339,7 @@ function osInfo(callback) {
|
||||
workload.push(util.powerShell('Get-CimInstance Win32_OperatingSystem | select Caption,SerialNumber,BuildNumber,ServicePackMajorVersion,ServicePackMinorVersion | fl'));
|
||||
workload.push(util.powerShell('(Get-CimInstance Win32_ComputerSystem).HypervisorPresent'));
|
||||
workload.push(util.powerShell('Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SystemInformation]::TerminalServerSession'));
|
||||
util.promiseAll(
|
||||
workload
|
||||
).then((data) => {
|
||||
util.promiseAll(workload).then((data) => {
|
||||
let lines = data.results[0] ? data.results[0].toString().split('\r\n') : [''];
|
||||
result.distro = util.getValue(lines, 'Caption', ':').trim();
|
||||
result.serial = util.getValue(lines, 'SerialNumber', ':').trim();
|
||||
@ -391,8 +349,8 @@ function osInfo(callback) {
|
||||
const hyperv = data.results[1] ? data.results[1].toString().toLowerCase() : '';
|
||||
result.hypervisor = hyperv.indexOf('true') !== -1;
|
||||
const term = data.results[2] ? data.results[2].toString() : '';
|
||||
result.remoteSession = (term.toString().toLowerCase().indexOf('true') >= 0);
|
||||
isUefiWindows().then(uefi => {
|
||||
result.remoteSession = term.toString().toLowerCase().indexOf('true') >= 0;
|
||||
isUefiWindows().then((uefi) => {
|
||||
result.uefi = uefi;
|
||||
if (callback) {
|
||||
callback(result);
|
||||
@ -401,7 +359,9 @@ function osInfo(callback) {
|
||||
});
|
||||
});
|
||||
} catch (e) {
|
||||
if (callback) { callback(result); }
|
||||
if (callback) {
|
||||
callback(result);
|
||||
}
|
||||
resolve(result);
|
||||
}
|
||||
}
|
||||
@ -513,7 +473,7 @@ function versions(apps, callback) {
|
||||
versions: {},
|
||||
counter: 0
|
||||
};
|
||||
apps.forEach(el => {
|
||||
apps.forEach((el) => {
|
||||
if (el) {
|
||||
for (let key in versionObject) {
|
||||
if ({}.hasOwnProperty.call(versionObject, key)) {
|
||||
@ -524,7 +484,9 @@ function versions(apps, callback) {
|
||||
result.versions.systemOpensslLib = '';
|
||||
}
|
||||
|
||||
if (!result.versions[key]) { result.counter++; }
|
||||
if (!result.versions[key]) {
|
||||
result.counter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -542,7 +504,9 @@ function versions(apps, callback) {
|
||||
} else {
|
||||
apps = apps || '*';
|
||||
if (typeof apps !== 'string') {
|
||||
if (callback) { callback({}); }
|
||||
if (callback) {
|
||||
callback({});
|
||||
}
|
||||
return resolve({});
|
||||
}
|
||||
}
|
||||
@ -684,7 +648,7 @@ function versions(apps, callback) {
|
||||
exec('apachectl -v 2>&1', function (error, stdout) {
|
||||
if (!error) {
|
||||
const apache = (stdout.toString().split('\n')[0] || '').split(':');
|
||||
appsObj.versions.apache = (apache.length > 1 ? apache[1].replace('Apache', '').replace('/', '').split('(')[0].trim() : '');
|
||||
appsObj.versions.apache = apache.length > 1 ? apache[1].replace('Apache', '').replace('/', '').split('(')[0].trim() : '';
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
@ -854,7 +818,7 @@ function versions(apps, callback) {
|
||||
const gitHomebrewExists1 = fs.existsSync('/usr/local/Cellar/python');
|
||||
const gitHomebrewExists2 = fs.existsSync('/opt/homebrew/bin/python');
|
||||
if ((util.darwinXcodeExists() && util.semverCompare('12.0.1', osVersion) < 0) || gitHomebrewExists1 || gitHomebrewExists2) {
|
||||
const cmd = gitHomebrewExists1 ? '/usr/local/Cellar/python -V 2>&1' : (gitHomebrewExists2 ? '/opt/homebrew/bin/python -V 2>&1' : 'python -V 2>&1');
|
||||
const cmd = gitHomebrewExists1 ? '/usr/local/Cellar/python -V 2>&1' : gitHomebrewExists2 ? '/opt/homebrew/bin/python -V 2>&1' : 'python -V 2>&1';
|
||||
exec(cmd, function (error, stdout) {
|
||||
if (!error) {
|
||||
const python = stdout.toString().split('\n')[0] || '';
|
||||
@ -868,7 +832,6 @@ function versions(apps, callback) {
|
||||
} catch (e) {
|
||||
functionProcessed();
|
||||
}
|
||||
|
||||
} else {
|
||||
exec('python -V 2>&1', function (error, stdout) {
|
||||
if (!error) {
|
||||
@ -1080,7 +1043,9 @@ function versions(apps, callback) {
|
||||
exec('node -v', function (error, stdout) {
|
||||
if (!error) {
|
||||
let line = stdout.toString().split('\n')[0].trim();
|
||||
if (line.startsWith('v')) { line = line.slice(1); }
|
||||
if (line.startsWith('v')) {
|
||||
line = line.slice(1);
|
||||
}
|
||||
appsObj.versions.node = line;
|
||||
}
|
||||
functionProcessed();
|
||||
@ -1088,8 +1053,12 @@ function versions(apps, callback) {
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'powershell')) {
|
||||
if (_windows) {
|
||||
util.powerShell('$PSVersionTable').then(stdout => {
|
||||
const lines = stdout.toString().toLowerCase().split('\n').map(line => line.replace(/ +/g, ' ').replace(/ +/g, ':'));
|
||||
util.powerShell('$PSVersionTable').then((stdout) => {
|
||||
const lines = stdout
|
||||
.toString()
|
||||
.toLowerCase()
|
||||
.split('\n')
|
||||
.map((line) => line.replace(/ +/g, ' ').replace(/ +/g, ':'));
|
||||
appsObj.versions.powershell = util.getValue(lines, 'psversion');
|
||||
functionProcessed();
|
||||
});
|
||||
@ -1099,23 +1068,31 @@ function versions(apps, callback) {
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'dotnet')) {
|
||||
if (_windows) {
|
||||
util.powerShell('gci "HKLM:\\SOFTWARE\\Microsoft\\NET Framework Setup\\NDP" -recurse | gp -name Version,Release -EA 0 | where { $_.PSChildName -match "^(?!S)\\p{L}"} | select PSChildName, Version, Release').then(stdout => {
|
||||
const lines = stdout.toString().split('\r\n');
|
||||
let dotnet = '';
|
||||
lines.forEach(line => {
|
||||
line = line.replace(/ +/g, ' ');
|
||||
const parts = line.split(' ');
|
||||
dotnet = dotnet || (parts[0].toLowerCase().startsWith('client') && parts.length > 2 ? parts[1].trim() : (parts[0].toLowerCase().startsWith('full') && parts.length > 2 ? parts[1].trim() : ''));
|
||||
util
|
||||
.powerShell(
|
||||
'gci "HKLM:\\SOFTWARE\\Microsoft\\NET Framework Setup\\NDP" -recurse | gp -name Version,Release -EA 0 | where { $_.PSChildName -match "^(?!S)\\p{L}"} | select PSChildName, Version, Release'
|
||||
)
|
||||
.then((stdout) => {
|
||||
const lines = stdout.toString().split('\r\n');
|
||||
let dotnet = '';
|
||||
lines.forEach((line) => {
|
||||
line = line.replace(/ +/g, ' ');
|
||||
const parts = line.split(' ');
|
||||
dotnet =
|
||||
dotnet ||
|
||||
(parts[0].toLowerCase().startsWith('client') && parts.length > 2 ? parts[1].trim() : parts[0].toLowerCase().startsWith('full') && parts.length > 2 ? parts[1].trim() : '');
|
||||
});
|
||||
appsObj.versions.dotnet = dotnet.trim();
|
||||
functionProcessed();
|
||||
});
|
||||
appsObj.versions.dotnet = dotnet.trim();
|
||||
functionProcessed();
|
||||
});
|
||||
} else {
|
||||
functionProcessed();
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
if (callback) { callback(appsObj.versions); }
|
||||
if (callback) {
|
||||
callback(appsObj.versions);
|
||||
}
|
||||
resolve(appsObj.versions);
|
||||
}
|
||||
});
|
||||
@ -1130,7 +1107,7 @@ function shell(callback) {
|
||||
if (_windows) {
|
||||
try {
|
||||
const result = 'CMD';
|
||||
util.powerShell(`Get-CimInstance -className win32_process | where-object {$_.ProcessId -eq ${process.ppid} } | select Name`).then(stdout => {
|
||||
util.powerShell(`Get-CimInstance -className win32_process | where-object {$_.ProcessId -eq ${process.ppid} } | select Name`).then((stdout) => {
|
||||
let result = 'CMD';
|
||||
if (stdout) {
|
||||
if (stdout.toString().toLowerCase().indexOf('powershell') >= 0) {
|
||||
@ -1183,8 +1160,12 @@ function getUniqueMacAdresses() {
|
||||
}
|
||||
}
|
||||
macs = macs.sort(function (a, b) {
|
||||
if (a < b) { return -1; }
|
||||
if (a > b) { return 1; }
|
||||
if (a < b) {
|
||||
return -1;
|
||||
}
|
||||
if (a > b) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
} catch (e) {
|
||||
@ -1196,7 +1177,6 @@ function getUniqueMacAdresses() {
|
||||
function uuid(callback) {
|
||||
return new Promise((resolve) => {
|
||||
process.nextTick(() => {
|
||||
|
||||
let result = {
|
||||
os: '',
|
||||
hardware: '',
|
||||
@ -1248,8 +1228,12 @@ echo -n "hardware: "; cat /sys/class/dmi/id/product_uuid 2> /dev/null; echo;`;
|
||||
const lines = stdout.toString().split('\n');
|
||||
result.hardware = util.getValue(lines, 'kern.hostid', ':').toLowerCase();
|
||||
result.os = util.getValue(lines, 'kern.hostuuid', ':').toLowerCase();
|
||||
if (result.os.indexOf('unknown') >= 0) { result.os = ''; }
|
||||
if (result.hardware.indexOf('unknown') >= 0) { result.hardware = ''; }
|
||||
if (result.os.indexOf('unknown') >= 0) {
|
||||
result.os = '';
|
||||
}
|
||||
if (result.hardware.indexOf('unknown') >= 0) {
|
||||
result.hardware = '';
|
||||
}
|
||||
if (callback) {
|
||||
callback(result);
|
||||
}
|
||||
@ -1266,7 +1250,7 @@ echo -n "hardware: "; cat /sys/class/dmi/id/product_uuid 2> /dev/null; echo;`;
|
||||
result.hardware = util.getValue(lines, 'uuid', ':').toLowerCase();
|
||||
exec(`${sysdir}\\reg query "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography" /v MachineGuid`, util.execOptsWin, function (error, stdout) {
|
||||
parts = stdout.toString().split('\n\r')[0].split('REG_SZ');
|
||||
result.os = parts.length > 1 ? parts[1].replace(/\r+|\n+|\s+/ig, '').toLowerCase() : '';
|
||||
result.os = parts.length > 1 ? parts[1].replace(/\r+|\n+|\s+/gi, '').toLowerCase() : '';
|
||||
if (callback) {
|
||||
callback(result);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user