Merge branch 'master' of https://github.com/sebhildebrandt/systeminformation
This commit is contained in:
commit
de35fafb3a
@ -163,6 +163,7 @@ Full function reference with examples can be found at [https://systeminformation
|
|||||||
| | version | X | X | X | X | | version |
|
| | version | X | X | X | X | | version |
|
||||||
| | releaseDate | X | X | | X | | release date |
|
| | releaseDate | X | X | | X | | release date |
|
||||||
| | revision | X | X | | X | | revision |
|
| | revision | X | X | | X | | revision |
|
||||||
|
| | serial | X | | | X | | serial |
|
||||||
| si.baseboard(cb) | {...} | X | X | X | X | | baseboard information |
|
| si.baseboard(cb) | {...} | X | X | X | X | | baseboard information |
|
||||||
| | manufacturer | X | X | X | X | | e.g. 'ASUS' |
|
| | manufacturer | X | X | X | X | | e.g. 'ASUS' |
|
||||||
| | model | X | X | X | X | | model / product name |
|
| | model | X | X | X | X | | model / product name |
|
||||||
|
|||||||
@ -205,7 +205,7 @@
|
|||||||
<td>X</td>
|
<td>X</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>MUT maximum transmission unit</td>
|
<td>MTU maximum transmission unit</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
|
|||||||
@ -293,6 +293,16 @@ si.uuid().then(data => console.log(data));</code></pre class="example">
|
|||||||
<td></td>
|
<td></td>
|
||||||
<td>revision</td>
|
<td>revision</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td></td>
|
||||||
|
<td>serial</td>
|
||||||
|
<td>X</td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td>X</td>
|
||||||
|
<td></td>
|
||||||
|
<td>serial</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>language</td>
|
<td>language</td>
|
||||||
|
|||||||
@ -160,7 +160,7 @@ module.exports = function (callback) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_freebsd || _openbsd || _netbsd) {
|
if (_freebsd || _openbsd || _netbsd) {
|
||||||
exec('sysctl hw.acpi.battery hw.acpi.acline', function (error, stdout) {
|
exec('sysctl -i hw.acpi.battery hw.acpi.acline', function (error, stdout) {
|
||||||
let lines = stdout.toString().split('\n');
|
let lines = stdout.toString().split('\n');
|
||||||
const batteries = parseInt('0' + util.getValue(lines, 'hw.acpi.battery.units'), 10);
|
const batteries = parseInt('0' + util.getValue(lines, 'hw.acpi.battery.units'), 10);
|
||||||
const percent = parseInt('0' + util.getValue(lines, 'hw.acpi.battery.life'), 10);
|
const percent = parseInt('0' + util.getValue(lines, 'hw.acpi.battery.life'), 10);
|
||||||
|
|||||||
@ -126,24 +126,28 @@ function fsSize(callback) {
|
|||||||
}
|
}
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
try {
|
try {
|
||||||
util.wmic('logicaldisk get Caption,FileSystem,FreeSpace,Size').then((stdout) => {
|
// util.wmic('logicaldisk get Caption,FileSystem,FreeSpace,Size').then((stdout) => {
|
||||||
let lines = stdout.split('\r\n').filter(line => line.trim() !== '').filter((line, idx) => idx > 0);
|
util.powerShell('Get-WmiObject Win32_logicaldisk | fl *').then((stdout, error) => {
|
||||||
lines.forEach(function (line) {
|
if (!error) {
|
||||||
if (line !== '') {
|
let devices = stdout.toString().split(/\n\s*\n/);
|
||||||
line = line.trim().split(/\s\s+/);
|
devices.forEach(function (device) {
|
||||||
if (line.length >= 4 && parseInt(line[3], 10)) {
|
let lines = device.split('\r\n');
|
||||||
|
const size = util.toInt(util.getValue(lines, 'size', ':'));
|
||||||
|
const free = util.toInt(util.getValue(lines, 'freespace', ':'));
|
||||||
|
const caption = util.getValue(lines, 'caption', ':');
|
||||||
|
if (size) {
|
||||||
data.push({
|
data.push({
|
||||||
fs: line[0],
|
fs: caption,
|
||||||
type: line[1],
|
type: util.getValue(lines, 'filesystem', ':'),
|
||||||
size: parseInt(line[3], 10),
|
size,
|
||||||
used: parseInt(line[3], 10) - parseInt(line[2], 10),
|
used: size - free,
|
||||||
available: parseInt(line[2], 10),
|
available: free,
|
||||||
use: parseFloat(((100.0 * (parseInt(line[3]) - parseInt(line[2]))) / parseInt(line[3])).toFixed(2)),
|
use: parseFloat(((100.0 * (size - free)) / size).toFixed(2)),
|
||||||
mount: line[0]
|
mount: caption
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(data);
|
callback(data);
|
||||||
}
|
}
|
||||||
@ -173,12 +177,12 @@ function fsOpenFiles(callback) {
|
|||||||
available: null
|
available: null
|
||||||
};
|
};
|
||||||
if (_freebsd || _openbsd || _netbsd || _darwin) {
|
if (_freebsd || _openbsd || _netbsd || _darwin) {
|
||||||
let cmd = 'sysctl -a | grep \'kern.*files\'';
|
let cmd = 'sysctl -i kern.maxfiles kern.num_files kern.open_files';
|
||||||
exec(cmd, { maxBuffer: 1024 * 1024 }, function (error, stdout) {
|
exec(cmd, { maxBuffer: 1024 * 1024 }, function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
let lines = stdout.toString().split('\n');
|
let lines = stdout.toString().split('\n');
|
||||||
result.max = parseInt(util.getValue(lines, 'kern.maxfiles', ':'), 10);
|
result.max = parseInt(util.getValue(lines, 'kern.maxfiles', ':'), 10);
|
||||||
result.allocated = parseInt(util.getValue(lines, 'kern.num_files', ':'), 10);
|
result.allocated = parseInt(util.getValue(lines, 'kern.num_files', ':'), 10) || parseInt(util.getValue(lines, 'kern.open_files', ':'), 10);
|
||||||
result.available = result.max - result.allocated;
|
result.available = result.max - result.allocated;
|
||||||
}
|
}
|
||||||
if (callback) {
|
if (callback) {
|
||||||
@ -776,37 +780,37 @@ function diskLayout(callback) {
|
|||||||
|
|
||||||
function getVendorFromModel(model) {
|
function getVendorFromModel(model) {
|
||||||
const diskManufacturers = [
|
const diskManufacturers = [
|
||||||
{ pattern: '^WESTERN.+', manufacturer: 'Western Digital' },
|
{ pattern: 'WESTERN.*', manufacturer: 'Western Digital' },
|
||||||
{ pattern: '^WDC.+', manufacturer: 'Western Digital' },
|
{ pattern: '^WDC.*', manufacturer: 'Western Digital' },
|
||||||
{ pattern: 'WD.+', manufacturer: 'Western Digital' },
|
{ pattern: 'WD.*', manufacturer: 'Western Digital' },
|
||||||
{ pattern: '^TOSHIBA.+', manufacturer: 'Toshiba' },
|
{ pattern: 'TOSHIBA.*', manufacturer: 'Toshiba' },
|
||||||
{ pattern: '^HITACHI.+', manufacturer: 'Hitachi' },
|
{ pattern: 'HITACHI.*', manufacturer: 'Hitachi' },
|
||||||
{ pattern: '^IC.+', manufacturer: 'Hitachi' },
|
{ pattern: '^IC.*', manufacturer: 'Hitachi' },
|
||||||
{ pattern: '^HTS.+', manufacturer: 'Hitachi' },
|
{ pattern: '^HTS.*', manufacturer: 'Hitachi' },
|
||||||
{ pattern: '^SANDISK.+', manufacturer: 'SanDisk' },
|
{ pattern: 'SANDISK.*', manufacturer: 'SanDisk' },
|
||||||
{ pattern: '^KINGSTON.+', manufacturer: 'Kingston Technology' },
|
{ pattern: 'KINGSTON.*', manufacturer: 'Kingston Technology' },
|
||||||
{ pattern: '^SONY.+', manufacturer: 'Sony' },
|
{ pattern: '^SONY.*', manufacturer: 'Sony' },
|
||||||
{ pattern: '^TRANSCEND.+', manufacturer: 'Transcend' },
|
{ pattern: 'TRANSCEND.*', manufacturer: 'Transcend' },
|
||||||
{ pattern: 'SAMSUNG.+', manufacturer: 'Samsung' },
|
{ pattern: 'SAMSUNG.*', manufacturer: 'Samsung' },
|
||||||
{ pattern: '^ST(?!I\\ ).+', manufacturer: 'Seagate' },
|
{ pattern: '^ST(?!I\\ ).*', manufacturer: 'Seagate' },
|
||||||
{ pattern: '^STI\\ .+', manufacturer: 'SimpleTech' },
|
{ pattern: '^STI\\ .*', manufacturer: 'SimpleTech' },
|
||||||
{ pattern: '^D...-.+', manufacturer: 'IBM' },
|
{ pattern: '^D...-.*', manufacturer: 'IBM' },
|
||||||
{ pattern: '^IBM.+', manufacturer: 'IBM' },
|
{ pattern: '^IBM.*', manufacturer: 'IBM' },
|
||||||
{ pattern: '^FUJITSU.+', manufacturer: 'Fujitsu' },
|
{ pattern: '^FUJITSU.*', manufacturer: 'Fujitsu' },
|
||||||
{ pattern: '^MP.+', manufacturer: 'Fujitsu' },
|
{ pattern: '^MP.*', manufacturer: 'Fujitsu' },
|
||||||
{ pattern: '^MK.+', manufacturer: 'Toshiba' },
|
{ pattern: '^MK.*', manufacturer: 'Toshiba' },
|
||||||
{ pattern: '^MAXTOR.+', manufacturer: 'Maxtor' },
|
{ pattern: 'MAXTO.*', manufacturer: 'Maxtor' },
|
||||||
{ pattern: '^Pioneer.+', manufacturer: 'Pioneer' },
|
{ pattern: 'PIONEER.*', manufacturer: 'Pioneer' },
|
||||||
{ pattern: '^PHILIPS.+', manufacturer: 'Philips' },
|
{ pattern: 'PHILIPS.*', manufacturer: 'Philips' },
|
||||||
{ pattern: '^QUANTUM.+', manufacturer: 'Quantum Technology' },
|
{ pattern: 'QUANTUM.*', manufacturer: 'Quantum Technology' },
|
||||||
{ pattern: 'FIREBALL.+', manufacturer: 'Quantum Technology' },
|
{ pattern: 'FIREBALL.*', manufacturer: 'Quantum Technology' },
|
||||||
{ pattern: '^VBOX.+', manufacturer: 'VirtualBox' },
|
{ pattern: '^VBOX.*', manufacturer: 'VirtualBox' },
|
||||||
{ pattern: 'CORSAIR.+', manufacturer: 'Corsair Components' },
|
{ pattern: 'CORSAIR.*', manufacturer: 'Corsair Components' },
|
||||||
{ pattern: 'CRUCIAL.+', manufacturer: 'Crucial' },
|
{ pattern: 'CRUCIAL.*', manufacturer: 'Crucial' },
|
||||||
{ pattern: 'ECM.+', manufacturer: 'ECM' },
|
{ pattern: 'ECM.*', manufacturer: 'ECM' },
|
||||||
{ pattern: 'INTEL.+', manufacturer: 'INTEL' },
|
{ pattern: 'INTEL.*', manufacturer: 'INTEL' },
|
||||||
{ pattern: '.+EVO', manufacturer: 'Samsung' },
|
{ pattern: 'EVO.*', manufacturer: 'Samsung' },
|
||||||
{ pattern: 'APPLE.+', manufacturer: 'Apple' },
|
{ pattern: 'APPLE.*', manufacturer: 'Apple' },
|
||||||
];
|
];
|
||||||
|
|
||||||
let result = '';
|
let result = '';
|
||||||
|
|||||||
@ -181,7 +181,7 @@ function graphics(callback) {
|
|||||||
connection: ((connectionType.indexOf('_internal') > -1) ? 'Internal' : ((connectionType.indexOf('_displayport') > -1) ? 'Display Port' : ((connectionType.indexOf('_hdmi') > -1) ? 'HDMI' : null))),
|
connection: ((connectionType.indexOf('_internal') > -1) ? 'Internal' : ((connectionType.indexOf('_displayport') > -1) ? 'Display Port' : ((connectionType.indexOf('_hdmi') > -1) ? 'HDMI' : null))),
|
||||||
sizeX: null,
|
sizeX: null,
|
||||||
sizeY: null,
|
sizeY: null,
|
||||||
pixelDepth: (pixelDepthString === 'CGSThirtyBitColor' ? 30 : (pixelDepthString === 'CGSThirtytwoBitColor' ? 32 : (pixelDepthString === 'CGSTwentyfourBitColor' ? 24 : ''))),
|
pixelDepth: (pixelDepthString === 'CGSThirtyBitColor' ? 30 : (pixelDepthString === 'CGSThirtytwoBitColor' ? 32 : (pixelDepthString === 'CGSTwentyfourBitColor' ? 24 : null))),
|
||||||
resolutionX: pixelParts.length > 1 ? parseInt(pixelParts[0], 10) : null,
|
resolutionX: pixelParts.length > 1 ? parseInt(pixelParts[0], 10) : null,
|
||||||
resolutionY: pixelParts.length > 1 ? parseInt(pixelParts[1], 10) : null,
|
resolutionY: pixelParts.length > 1 ? parseInt(pixelParts[1], 10) : null,
|
||||||
currentResX: currentResolution.length > 1 ? parseInt(currentResolution[0], 10) : null,
|
currentResX: currentResolution.length > 1 ? parseInt(currentResolution[0], 10) : null,
|
||||||
@ -860,7 +860,7 @@ function graphics(callback) {
|
|||||||
if (_pixelDepth) {
|
if (_pixelDepth) {
|
||||||
result.displays[0].pixelDepth = _pixelDepth;
|
result.displays[0].pixelDepth = _pixelDepth;
|
||||||
}
|
}
|
||||||
if (_refreshRate && !result.displays[0].refreshRate) {
|
if (_refreshRate && !result.displays[0].currentRefreshRate) {
|
||||||
result.displays[0].currentRefreshRate = _refreshRate;
|
result.displays[0].currentRefreshRate = _refreshRate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
46
lib/index.d.ts
vendored
46
lib/index.d.ts
vendored
@ -38,6 +38,7 @@ export namespace Systeminformation {
|
|||||||
version: string;
|
version: string;
|
||||||
releaseDate: string;
|
releaseDate: string;
|
||||||
revision: string;
|
revision: string;
|
||||||
|
serial?: string;
|
||||||
language?: string;
|
language?: string;
|
||||||
features?: string[];
|
features?: string[];
|
||||||
}
|
}
|
||||||
@ -302,7 +303,7 @@ export namespace Systeminformation {
|
|||||||
deviceId?: string;
|
deviceId?: string;
|
||||||
bus: string;
|
bus: string;
|
||||||
busAddress?: string;
|
busAddress?: string;
|
||||||
vram: number;
|
vram: number | null;
|
||||||
vramDynamic: boolean;
|
vramDynamic: boolean;
|
||||||
external?: boolean;
|
external?: boolean;
|
||||||
cores?: number;
|
cores?: number;
|
||||||
@ -311,6 +312,7 @@ export namespace Systeminformation {
|
|||||||
driverVersion?: string;
|
driverVersion?: string;
|
||||||
name?: string;
|
name?: string;
|
||||||
pciBus?: string;
|
pciBus?: string;
|
||||||
|
pciID?: string;
|
||||||
fanSpeed?: number;
|
fanSpeed?: number;
|
||||||
memoryTotal?: number;
|
memoryTotal?: number;
|
||||||
memoryUsed?: number;
|
memoryUsed?: number;
|
||||||
@ -327,21 +329,25 @@ export namespace Systeminformation {
|
|||||||
|
|
||||||
interface GraphicsDisplayData {
|
interface GraphicsDisplayData {
|
||||||
vendor: string;
|
vendor: string;
|
||||||
|
vendorId: string | null;
|
||||||
model: string;
|
model: string;
|
||||||
deviceName: string;
|
productionYear: number | null;
|
||||||
|
serial: string | null;
|
||||||
|
deviceName: string | null;
|
||||||
|
displayId: string | null;
|
||||||
main: boolean;
|
main: boolean;
|
||||||
builtin: boolean;
|
builtin: boolean;
|
||||||
connection: string;
|
connection: string | null;
|
||||||
sizeX: number;
|
sizeX: number | null;
|
||||||
sizeY: number;
|
sizeY: number | null;
|
||||||
pixelDepth: number;
|
pixelDepth: number | null;
|
||||||
resolutionX: number;
|
resolutionX: number | null;
|
||||||
resolutionY: number;
|
resolutionY: number | null;
|
||||||
currentResX: number;
|
currentResX: number | null;
|
||||||
currentResY: number;
|
currentResY: number | null;
|
||||||
positionX: number;
|
positionX: number;
|
||||||
positionY: number;
|
positionY: number;
|
||||||
currentRefreshRate: number;
|
currentRefreshRate: number | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. Operating System
|
// 4. Operating System
|
||||||
@ -452,9 +458,9 @@ export namespace Systeminformation {
|
|||||||
rx: number;
|
rx: number;
|
||||||
wx: number;
|
wx: number;
|
||||||
tx: number;
|
tx: number;
|
||||||
rx_sec: number;
|
rx_sec: number | null;
|
||||||
wx_sec: number;
|
wx_sec: number | null;
|
||||||
tx_sec: number;
|
tx_sec: number | null;
|
||||||
ms: number;
|
ms: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -462,9 +468,15 @@ export namespace Systeminformation {
|
|||||||
rIO: number;
|
rIO: number;
|
||||||
wIO: number;
|
wIO: number;
|
||||||
tIO: number;
|
tIO: number;
|
||||||
rIO_sec: number;
|
rIO_sec: number | null;
|
||||||
wIO_sec: number;
|
wIO_sec: number | null;
|
||||||
tIO_sec: number;
|
tIO_sec: number | null;
|
||||||
|
rWaitTime: number;
|
||||||
|
wWaitTime: number;
|
||||||
|
tWaitTime: number;
|
||||||
|
rWaitPercent: number | null;
|
||||||
|
wWaitPercent: number | null;
|
||||||
|
tWaitPercent: number | null;
|
||||||
ms: number;
|
ms: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -198,7 +198,7 @@ function mem(callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (_freebsd || _openbsd || _netbsd) {
|
if (_freebsd || _openbsd || _netbsd) {
|
||||||
exec('/sbin/sysctl -a 2>/dev/null | grep -E "hw.realmem|hw.physmem|vm.stats.vm.v_page_count|vm.stats.vm.v_wire_count|vm.stats.vm.v_active_count|vm.stats.vm.v_inactive_count|vm.stats.vm.v_cache_count|vm.stats.vm.v_free_count|vm.stats.vm.v_page_size"', function (error, stdout) {
|
exec('/sbin/sysctl hw.realmem hw.physmem vm.stats.vm.v_page_count vm.stats.vm.v_wire_count vm.stats.vm.v_active_count vm.stats.vm.v_inactive_count vm.stats.vm.v_cache_count vm.stats.vm.v_free_count vm.stats.vm.v_page_size', function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
let lines = stdout.toString().split('\n');
|
let lines = stdout.toString().split('\n');
|
||||||
const pagesize = parseInt(util.getValue(lines, 'vm.stats.vm.v_page_size'), 10);
|
const pagesize = parseInt(util.getValue(lines, 'vm.stats.vm.v_page_size'), 10);
|
||||||
|
|||||||
224
lib/network.js
224
lib/network.js
@ -218,23 +218,23 @@ function parseLinesWindowsNics(sections, nconfigsections) {
|
|||||||
|
|
||||||
let lines = sections[i].trim().split('\r\n');
|
let lines = sections[i].trim().split('\r\n');
|
||||||
let linesNicConfig = nconfigsections[i].trim().split('\r\n');
|
let linesNicConfig = nconfigsections[i].trim().split('\r\n');
|
||||||
let netEnabled = util.getValue(lines, 'NetEnabled', '=');
|
let netEnabled = util.getValue(lines, 'NetEnabled', ':');
|
||||||
let adapterType = util.getValue(lines, 'AdapterTypeID', '=') === '9' ? 'wireless' : 'wired';
|
let adapterType = util.getValue(lines, 'AdapterTypeID', ':') === '9' ? 'wireless' : 'wired';
|
||||||
let ifacename = util.getValue(lines, 'Name', '=').replace(/\]/g, ')').replace(/\[/g, '(');
|
let ifacename = util.getValue(lines, 'Name', ':').replace(/\]/g, ')').replace(/\[/g, '(');
|
||||||
let iface = util.getValue(lines, 'NetConnectionID', '=').replace(/\]/g, ')').replace(/\[/g, '(');
|
let iface = util.getValue(lines, 'NetConnectionID', ':').replace(/\]/g, ')').replace(/\[/g, '(');
|
||||||
if (ifacename.toLowerCase().indexOf('wi-fi') >= 0 || ifacename.toLowerCase().indexOf('wireless') >= 0) {
|
if (ifacename.toLowerCase().indexOf('wi-fi') >= 0 || ifacename.toLowerCase().indexOf('wireless') >= 0) {
|
||||||
adapterType = 'wireless';
|
adapterType = 'wireless';
|
||||||
}
|
}
|
||||||
if (netEnabled !== '') {
|
if (netEnabled !== '') {
|
||||||
const speed = parseInt(util.getValue(lines, 'speed', '=').trim(), 10) / 1000000;
|
const speed = parseInt(util.getValue(lines, 'speed', ':').trim(), 10) / 1000000;
|
||||||
nics.push({
|
nics.push({
|
||||||
mac: util.getValue(lines, 'MACAddress', '=').toLowerCase(),
|
mac: util.getValue(lines, 'MACAddress', ':').toLowerCase(),
|
||||||
dhcp: util.getValue(linesNicConfig, 'dhcpEnabled', '=').toLowerCase(),
|
dhcp: util.getValue(linesNicConfig, 'dhcpEnabled', ':').toLowerCase() === 'true',
|
||||||
name: ifacename,
|
name: ifacename,
|
||||||
iface,
|
iface,
|
||||||
netEnabled: netEnabled === 'TRUE',
|
netEnabled: netEnabled === 'TRUE',
|
||||||
speed: isNaN(speed) ? null : speed,
|
speed: isNaN(speed) ? null : speed,
|
||||||
operstate: util.getValue(lines, 'NetConnectionStatus', '=') === '2' ? 'up' : 'down',
|
operstate: util.getValue(lines, 'NetConnectionStatus', ':') === '2' ? 'up' : 'down',
|
||||||
type: adapterType
|
type: adapterType
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -245,15 +245,24 @@ function parseLinesWindowsNics(sections, nconfigsections) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getWindowsNics() {
|
function getWindowsNics() {
|
||||||
const cmd = util.getWmic() + ' nic get /value';
|
// const cmd = util.getWmic() + ' nic get /value';
|
||||||
const cmdnicconfig = util.getWmic() + ' nicconfig get dhcpEnabled /value';
|
// const cmdnicconfig = util.getWmic() + ' nicconfig get dhcpEnabled /value';
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
process.nextTick(() => {
|
||||||
|
let cmd = 'Get-WmiObject Win32_NetworkAdapter | fl *' + '; echo \'#-#-#-#\';';
|
||||||
|
cmd += 'Get-WmiObject Win32_NetworkAdapterConfiguration | fl DHCPEnabled' + '';
|
||||||
try {
|
try {
|
||||||
const nsections = execSync(cmd, util.execOptsWin).split(/\n\s*\n/);
|
util.powerShell(cmd).then(data => {
|
||||||
const nconfigsections = execSync(cmdnicconfig, util.execOptsWin).split(/\n\s*\n/);
|
data = data.split('#-#-#-#');
|
||||||
return (parseLinesWindowsNics(nsections, nconfigsections));
|
const nsections = data[0].split(/\n\s*\n/);
|
||||||
|
const nconfigsections = data[1].split(/\n\s*\n/);
|
||||||
|
resolve(parseLinesWindowsNics(nsections, nconfigsections));
|
||||||
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return [];
|
resolve([]);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getWindowsDNSsuffixes() {
|
function getWindowsDNSsuffixes() {
|
||||||
@ -743,7 +752,8 @@ function networkInterfaces(callback, rescan) {
|
|||||||
_networkInterfaces = result;
|
_networkInterfaces = result;
|
||||||
if (callback) { callback(result); }
|
if (callback) { callback(result); }
|
||||||
resolve(result);
|
resolve(result);
|
||||||
} else {
|
}
|
||||||
|
if (_linux) {
|
||||||
if ((JSON.stringify(ifaces) === JSON.stringify(_ifaces)) && !rescan) {
|
if ((JSON.stringify(ifaces) === JSON.stringify(_ifaces)) && !rescan) {
|
||||||
// no changes - just return object
|
// no changes - just return object
|
||||||
result = _networkInterfaces;
|
result = _networkInterfaces;
|
||||||
@ -751,35 +761,9 @@ function networkInterfaces(callback, rescan) {
|
|||||||
if (callback) { callback(result); }
|
if (callback) { callback(result); }
|
||||||
resolve(result);
|
resolve(result);
|
||||||
} else {
|
} else {
|
||||||
_ifaces = Object.assign({}, ifaces);
|
_ifaces = JSON.parse(JSON.stringify(ifaces));
|
||||||
|
|
||||||
if (_windows) {
|
|
||||||
nics = getWindowsNics();
|
|
||||||
nics.forEach(nic => {
|
|
||||||
let found = false;
|
|
||||||
Object.keys(ifaces).forEach(key => {
|
|
||||||
if (!found) {
|
|
||||||
ifaces[key].forEach(value => {
|
|
||||||
if (Object.keys(value).indexOf('mac') >= 0) {
|
|
||||||
found = value['mac'] === nic.mac;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!found) {
|
|
||||||
ifaces[nic.name] = [{ mac: nic.mac }];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
nics8021xInfo = getWindowsWiredProfilesInformation();
|
|
||||||
dnsSuffixes = getWindowsDNSsuffixes();
|
|
||||||
}
|
|
||||||
if (_linux) {
|
|
||||||
_dhcpNics = getLinuxDHCPNics();
|
_dhcpNics = getLinuxDHCPNics();
|
||||||
}
|
|
||||||
for (let dev in ifaces) {
|
for (let dev in ifaces) {
|
||||||
let iface = dev;
|
|
||||||
let ip4 = '';
|
let ip4 = '';
|
||||||
let ip4subnet = '';
|
let ip4subnet = '';
|
||||||
let ip6 = '';
|
let ip6 = '';
|
||||||
@ -819,7 +803,6 @@ function networkInterfaces(callback, rescan) {
|
|||||||
mac = _mac[dev] || '';
|
mac = _mac[dev] || '';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (_linux) {
|
|
||||||
let iface = dev.split(':')[0].trim().toLowerCase();
|
let iface = dev.split(':')[0].trim().toLowerCase();
|
||||||
const cmd = `echo -n "addr_assign_type: "; cat /sys/class/net/${iface}/addr_assign_type 2>/dev/null; echo;
|
const cmd = `echo -n "addr_assign_type: "; cat /sys/class/net/${iface}/addr_assign_type 2>/dev/null; echo;
|
||||||
echo -n "address: "; cat /sys/class/net/${iface}/address 2>/dev/null; echo;
|
echo -n "address: "; cat /sys/class/net/${iface}/address 2>/dev/null; echo;
|
||||||
@ -872,32 +855,7 @@ function networkInterfaces(callback, rescan) {
|
|||||||
operstate = util.getValue(lines, 'operstate');
|
operstate = util.getValue(lines, 'operstate');
|
||||||
type = operstate === 'up' ? (util.getValue(lines, 'wireless').trim() ? 'wireless' : 'wired') : 'unknown';
|
type = operstate === 'up' ? (util.getValue(lines, 'wireless').trim() ? 'wireless' : 'wired') : 'unknown';
|
||||||
if (iface === 'lo' || iface.startsWith('bond')) { type = 'virtual'; }
|
if (iface === 'lo' || iface.startsWith('bond')) { type = 'virtual'; }
|
||||||
}
|
|
||||||
if (_windows) {
|
|
||||||
|
|
||||||
|
|
||||||
dnsSuffix = getWindowsIfaceDNSsuffix(dnsSuffixes.ifaces, dev);
|
|
||||||
let foundFirst = false;
|
|
||||||
nics.forEach(detail => {
|
|
||||||
if (detail.mac === mac && !foundFirst) {
|
|
||||||
iface = detail.iface || iface;
|
|
||||||
ifaceName = detail.name;
|
|
||||||
dhcp = detail.dhcp;
|
|
||||||
operstate = detail.operstate;
|
|
||||||
speed = detail.speed;
|
|
||||||
type = detail.type;
|
|
||||||
foundFirst = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (dev.toLowerCase().indexOf('wlan') >= 0 || ifaceName.toLowerCase().indexOf('wlan') >= 0 || ifaceName.toLowerCase().indexOf('802.11n') >= 0 || ifaceName.toLowerCase().indexOf('wireless') >= 0 || ifaceName.toLowerCase().indexOf('wi-fi') >= 0 || ifaceName.toLowerCase().indexOf('wifi') >= 0) {
|
|
||||||
type = 'wireless';
|
|
||||||
}
|
|
||||||
|
|
||||||
const IEEE8021x = getWindowsIEEE8021x(type, dev, nics8021xInfo);
|
|
||||||
ieee8021xAuth = IEEE8021x.protocol;
|
|
||||||
ieee8021xState = IEEE8021x.state;
|
|
||||||
}
|
|
||||||
let internal = (ifaces[dev] && ifaces[dev][0]) ? ifaces[dev][0].internal : false;
|
let internal = (ifaces[dev] && ifaces[dev][0]) ? ifaces[dev][0].internal : false;
|
||||||
if (dev.toLowerCase().indexOf('loopback') > -1 || ifaceName.toLowerCase().indexOf('loopback') > -1) {
|
if (dev.toLowerCase().indexOf('loopback') > -1 || ifaceName.toLowerCase().indexOf('loopback') > -1) {
|
||||||
internal = true;
|
internal = true;
|
||||||
@ -931,6 +889,134 @@ function networkInterfaces(callback, rescan) {
|
|||||||
resolve(result);
|
resolve(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (_windows) {
|
||||||
|
if ((JSON.stringify(ifaces) === JSON.stringify(_ifaces)) && !rescan) {
|
||||||
|
// no changes - just return object
|
||||||
|
result = _networkInterfaces;
|
||||||
|
|
||||||
|
if (callback) { callback(result); }
|
||||||
|
resolve(result);
|
||||||
|
} else {
|
||||||
|
_ifaces = JSON.parse(JSON.stringify(ifaces));
|
||||||
|
|
||||||
|
getWindowsNics().then(function (nics) {
|
||||||
|
nics.forEach(nic => {
|
||||||
|
let found = false;
|
||||||
|
Object.keys(ifaces).forEach(key => {
|
||||||
|
if (!found) {
|
||||||
|
ifaces[key].forEach(value => {
|
||||||
|
if (Object.keys(value).indexOf('mac') >= 0) {
|
||||||
|
found = value['mac'] === nic.mac;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
|
ifaces[nic.name] = [{ mac: nic.mac }];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
nics8021xInfo = getWindowsWiredProfilesInformation();
|
||||||
|
dnsSuffixes = getWindowsDNSsuffixes();
|
||||||
|
for (let dev in ifaces) {
|
||||||
|
let iface = dev;
|
||||||
|
let ip4 = '';
|
||||||
|
let ip4subnet = '';
|
||||||
|
let ip6 = '';
|
||||||
|
let ip6subnet = '';
|
||||||
|
let mac = '';
|
||||||
|
let duplex = '';
|
||||||
|
let mtu = '';
|
||||||
|
let speed = null;
|
||||||
|
let carrierChanges = 0;
|
||||||
|
let operstate = 'down';
|
||||||
|
let dhcp = false;
|
||||||
|
let dnsSuffix = '';
|
||||||
|
let ieee8021xAuth = '';
|
||||||
|
let ieee8021xState = '';
|
||||||
|
let type = '';
|
||||||
|
|
||||||
|
if ({}.hasOwnProperty.call(ifaces, dev)) {
|
||||||
|
let ifaceName = dev;
|
||||||
|
ifaces[dev].forEach(function (details) {
|
||||||
|
if (details.family === 'IPv4') {
|
||||||
|
ip4 = details.address;
|
||||||
|
ip4subnet = details.netmask;
|
||||||
|
}
|
||||||
|
if (details.family === 'IPv6') {
|
||||||
|
if (!ip6 || ip6.match(/^fe80::/i)) {
|
||||||
|
ip6 = details.address;
|
||||||
|
ip6subnet = details.netmask;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mac = details.mac;
|
||||||
|
// fallback due to https://github.com/nodejs/node/issues/13581 (node 8.1 - node 8.2)
|
||||||
|
const nodeMainVersion = parseInt(process.versions.node.split('.'), 10);
|
||||||
|
if (mac.indexOf('00:00:0') > -1 && (_linux || _darwin) && (!details.internal) && nodeMainVersion >= 8 && nodeMainVersion <= 11) {
|
||||||
|
if (Object.keys(_mac).length === 0) {
|
||||||
|
_mac = getMacAddresses();
|
||||||
|
}
|
||||||
|
mac = _mac[dev] || '';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
dnsSuffix = getWindowsIfaceDNSsuffix(dnsSuffixes.ifaces, dev);
|
||||||
|
let foundFirst = false;
|
||||||
|
nics.forEach(detail => {
|
||||||
|
if (detail.mac === mac && !foundFirst) {
|
||||||
|
iface = detail.iface || iface;
|
||||||
|
ifaceName = detail.name;
|
||||||
|
dhcp = detail.dhcp;
|
||||||
|
operstate = detail.operstate;
|
||||||
|
speed = detail.speed;
|
||||||
|
type = detail.type;
|
||||||
|
foundFirst = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (dev.toLowerCase().indexOf('wlan') >= 0 || ifaceName.toLowerCase().indexOf('wlan') >= 0 || ifaceName.toLowerCase().indexOf('802.11n') >= 0 || ifaceName.toLowerCase().indexOf('wireless') >= 0 || ifaceName.toLowerCase().indexOf('wi-fi') >= 0 || ifaceName.toLowerCase().indexOf('wifi') >= 0) {
|
||||||
|
type = 'wireless';
|
||||||
|
}
|
||||||
|
|
||||||
|
const IEEE8021x = getWindowsIEEE8021x(type, dev, nics8021xInfo);
|
||||||
|
ieee8021xAuth = IEEE8021x.protocol;
|
||||||
|
ieee8021xState = IEEE8021x.state;
|
||||||
|
let internal = (ifaces[dev] && ifaces[dev][0]) ? ifaces[dev][0].internal : false;
|
||||||
|
if (dev.toLowerCase().indexOf('loopback') > -1 || ifaceName.toLowerCase().indexOf('loopback') > -1) {
|
||||||
|
internal = true;
|
||||||
|
}
|
||||||
|
const virtual = internal ? false : testVirtualNic(dev, ifaceName, mac);
|
||||||
|
result.push({
|
||||||
|
iface,
|
||||||
|
ifaceName,
|
||||||
|
ip4,
|
||||||
|
ip4subnet,
|
||||||
|
ip6,
|
||||||
|
ip6subnet,
|
||||||
|
mac,
|
||||||
|
internal,
|
||||||
|
virtual,
|
||||||
|
operstate,
|
||||||
|
type,
|
||||||
|
duplex,
|
||||||
|
mtu,
|
||||||
|
speed,
|
||||||
|
dhcp,
|
||||||
|
dnsSuffix,
|
||||||
|
ieee8021xAuth,
|
||||||
|
ieee8021xState,
|
||||||
|
carrierChanges,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_networkInterfaces = result;
|
||||||
|
if (callback) { callback(result); }
|
||||||
|
resolve(result);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1425,7 +1511,7 @@ function networkConnections(callback) {
|
|||||||
peeraddress.pop();
|
peeraddress.pop();
|
||||||
peerip = peeraddress.join(':');
|
peerip = peeraddress.join(':');
|
||||||
}
|
}
|
||||||
let pid = line[4];
|
let pid = util.toInt(line[4]);
|
||||||
let connstate = line[3];
|
let connstate = line[3];
|
||||||
if (connstate === 'HERGESTELLT') { connstate = 'ESTABLISHED'; }
|
if (connstate === 'HERGESTELLT') { connstate = 'ESTABLISHED'; }
|
||||||
if (connstate.startsWith('ABH')) { connstate = 'LISTEN'; }
|
if (connstate.startsWith('ABH')) { connstate = 'LISTEN'; }
|
||||||
|
|||||||
@ -1111,12 +1111,10 @@ echo -n "hardware: "; cat /sys/class/dmi/id/product_uuid 2> /dev/null; echo;`;
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (_freebsd || _openbsd || _netbsd) {
|
if (_freebsd || _openbsd || _netbsd) {
|
||||||
const cmd = `echo -n "os: "; sysctl -n kern.hostid; echo;
|
exec('sysctl -i kern.hostid kern.hostuuid', function (error, stdout) {
|
||||||
echo -n "hardware: "; sysctl -n kern.hostuuid; echo;`;
|
|
||||||
exec(cmd, function (error, stdout) {
|
|
||||||
const lines = stdout.toString().split('\n');
|
const lines = stdout.toString().split('\n');
|
||||||
result.os = util.getValue(lines, 'os').toLowerCase();
|
result.os = util.getValue(lines, 'kern.hostid', ':').toLowerCase();
|
||||||
result.hardware = util.getValue(lines, 'hardware').toLowerCase();
|
result.hardware = util.getValue(lines, 'kern.hostuuid', ':').toLowerCase();
|
||||||
if (result.os.indexOf('unknown') >= 0) { result.os = ''; }
|
if (result.os.indexOf('unknown') >= 0) { result.os = ''; }
|
||||||
if (result.hardware.indexOf('unknown') >= 0) { result.hardware = ''; }
|
if (result.hardware.indexOf('unknown') >= 0) { result.hardware = ''; }
|
||||||
if (callback) {
|
if (callback) {
|
||||||
|
|||||||
@ -461,6 +461,7 @@ function bios(callback) {
|
|||||||
let datetime = util.getValue(lines, 'Release Date');
|
let datetime = util.getValue(lines, 'Release Date');
|
||||||
result.releaseDate = util.parseDateTime(datetime).date;
|
result.releaseDate = util.parseDateTime(datetime).date;
|
||||||
result.revision = util.getValue(lines, 'BIOS Revision');
|
result.revision = util.getValue(lines, 'BIOS Revision');
|
||||||
|
result.serial = util.getValue(lines, 'SerialNumber');
|
||||||
let language = util.getValue(lines, 'Currently Installed Language').split('|')[0];
|
let language = util.getValue(lines, 'Currently Installed Language').split('|')[0];
|
||||||
if (language) {
|
if (language) {
|
||||||
result.language = language;
|
result.language = language;
|
||||||
@ -538,6 +539,7 @@ function bios(callback) {
|
|||||||
result.releaseDate = result.releaseDate.substr(0, 4) + '-' + result.releaseDate.substr(4, 2) + '-' + result.releaseDate.substr(6, 2);
|
result.releaseDate = result.releaseDate.substr(0, 4) + '-' + result.releaseDate.substr(4, 2) + '-' + result.releaseDate.substr(6, 2);
|
||||||
}
|
}
|
||||||
result.revision = util.getValue(lines, 'buildnumber', ':');
|
result.revision = util.getValue(lines, 'buildnumber', ':');
|
||||||
|
result.serial = util.getValue(lines, 'serialnumber', ':');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (callback) { callback(result); }
|
if (callback) { callback(result); }
|
||||||
|
|||||||
21
lib/users.js
21
lib/users.js
@ -283,16 +283,21 @@ function users(callback) {
|
|||||||
}
|
}
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
try {
|
try {
|
||||||
const workload = [];
|
// const workload = [];
|
||||||
// workload.push(util.powerShell('Get-CimInstance -ClassName Win32_Account | fl *'));
|
// // workload.push(util.powerShell('Get-CimInstance -ClassName Win32_Account | fl *'));
|
||||||
workload.push(util.powerShell('Get-WmiObject Win32_LogonSession | fl *'));
|
// workload.push(util.powerShell('Get-WmiObject Win32_LogonSession | fl *'));
|
||||||
workload.push(util.powerShell('Get-WmiObject Win32_LoggedOnUser | fl *'));
|
// workload.push(util.powerShell('Get-WmiObject Win32_LoggedOnUser | fl *'));
|
||||||
workload.push(util.powerShell('Get-WmiObject Win32_Process -Filter "name=\'explorer.exe\'" | Select @{Name="domain";Expression={$_.GetOwner().Domain}}, @{Name="username";Expression={$_.GetOwner().User}} | fl'));
|
// workload.push(util.powerShell('Get-WmiObject Win32_Process -Filter "name=\'explorer.exe\'" | Select @{Name="domain";Expression={$_.GetOwner().Domain}}, @{Name="username";Expression={$_.GetOwner().User}} | fl'));
|
||||||
Promise.all(
|
// Promise.all(
|
||||||
workload
|
// workload
|
||||||
).then(data => {
|
// ).then(data => {
|
||||||
|
let cmd = 'Get-WmiObject Win32_LogonSession | fl *' + '; echo \'#-#-#-#\';';
|
||||||
|
cmd += 'Get-WmiObject Win32_LoggedOnUser | fl *' + '; echo \'#-#-#-#\';';
|
||||||
|
cmd += 'Get-WmiObject Win32_Process -Filter "name=\'explorer.exe\'" | Select @{Name="domain";Expression={$_.GetOwner().Domain}}, @{Name="username";Expression={$_.GetOwner().User}} | fl';
|
||||||
|
util.powerShell(cmd).then(data => {
|
||||||
// controller + vram
|
// controller + vram
|
||||||
// let accounts = parseWinAccounts(data[0].split(/\n\s*\n/));
|
// let accounts = parseWinAccounts(data[0].split(/\n\s*\n/));
|
||||||
|
data = data.split('#-#-#-#');
|
||||||
let sessions = parseWinSessions(data[0].split(/\n\s*\n/));
|
let sessions = parseWinSessions(data[0].split(/\n\s*\n/));
|
||||||
let loggedons = parseWinLoggedOn(data[1].split(/\n\s*\n/));
|
let loggedons = parseWinLoggedOn(data[1].split(/\n\s*\n/));
|
||||||
let users = parseWinUsers(data[2].split(/\n\s*\n/));
|
let users = parseWinUsers(data[2].split(/\n\s*\n/));
|
||||||
|
|||||||
@ -360,7 +360,7 @@ function powerShell(cmd) {
|
|||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
process.nextTick(() => {
|
process.nextTick(() => {
|
||||||
try {
|
try {
|
||||||
const child = spawn('powershell.exe', ['-NoLogo', '-InputFormat', 'Text', '-NoExit', '-ExecutionPolicy', 'Unrestricted', '-Command', '-'], {
|
const child = spawn('powershell.exe', ['-NoLogo', '-NoProfile', '-InputFormat', 'Text', '-NoExit', '-ExecutionPolicy', 'Unrestricted', '-Command', '-'], { // added NoProfile
|
||||||
stdio: 'pipe',
|
stdio: 'pipe',
|
||||||
windowsHide: true,
|
windowsHide: true,
|
||||||
maxBuffer: 1024 * 20000,
|
maxBuffer: 1024 * 20000,
|
||||||
@ -875,6 +875,7 @@ function decodePiCpuinfo(lines) {
|
|||||||
'0f': 'Internal use only',
|
'0f': 'Internal use only',
|
||||||
'10': 'CM3+',
|
'10': 'CM3+',
|
||||||
'11': '4B',
|
'11': '4B',
|
||||||
|
'12': 'Zero 2 W',
|
||||||
'13': '400',
|
'13': '400',
|
||||||
'14': 'CM4'
|
'14': 'CM4'
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user