This commit is contained in:
Sebastian Hildebrandt 2021-11-11 15:30:52 +01:00
commit de35fafb3a
13 changed files with 3779 additions and 3660 deletions

View File

@ -163,6 +163,7 @@ Full function reference with examples can be found at [https://systeminformation
| | version | X | X | X | X | | version |
| | releaseDate | X | X | | X | | release date |
| | revision | X | X | | X | | revision |
| | serial | X | | | X | | serial |
| si.baseboard(cb) | {...} | X | X | X | X | | baseboard information |
| | manufacturer | X | X | X | X | | e.g. 'ASUS' |
| | model | X | X | X | X | | model / product name |

View File

@ -205,7 +205,7 @@
<td>X</td>
<td></td>
<td></td>
<td>MUT maximum transmission unit</td>
<td>MTU maximum transmission unit</td>
</tr>
<tr>
<td></td>

View File

@ -293,6 +293,16 @@ si.uuid().then(data => console.log(data));</code></pre class="example">
<td></td>
<td>revision</td>
</tr>
<tr>
<td></td>
<td>serial</td>
<td>X</td>
<td></td>
<td></td>
<td>X</td>
<td></td>
<td>serial</td>
</tr>
<tr>
<td></td>
<td>language</td>
@ -588,4 +598,4 @@ si.chassis().then(data => console.log(data));</code></pre class="example">
</script>
</body>
</html>
</html>

View File

@ -160,7 +160,7 @@ module.exports = function (callback) {
}
}
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');
const batteries = parseInt('0' + util.getValue(lines, 'hw.acpi.battery.units'), 10);
const percent = parseInt('0' + util.getValue(lines, 'hw.acpi.battery.life'), 10);

View File

@ -126,24 +126,28 @@ function fsSize(callback) {
}
if (_windows) {
try {
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);
lines.forEach(function (line) {
if (line !== '') {
line = line.trim().split(/\s\s+/);
if (line.length >= 4 && parseInt(line[3], 10)) {
// util.wmic('logicaldisk get Caption,FileSystem,FreeSpace,Size').then((stdout) => {
util.powerShell('Get-WmiObject Win32_logicaldisk | fl *').then((stdout, error) => {
if (!error) {
let devices = stdout.toString().split(/\n\s*\n/);
devices.forEach(function (device) {
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({
fs: line[0],
type: line[1],
size: parseInt(line[3], 10),
used: parseInt(line[3], 10) - parseInt(line[2], 10),
available: parseInt(line[2], 10),
use: parseFloat(((100.0 * (parseInt(line[3]) - parseInt(line[2]))) / parseInt(line[3])).toFixed(2)),
mount: line[0]
fs: caption,
type: util.getValue(lines, 'filesystem', ':'),
size,
used: size - free,
available: free,
use: parseFloat(((100.0 * (size - free)) / size).toFixed(2)),
mount: caption
});
}
}
});
});
}
if (callback) {
callback(data);
}
@ -173,12 +177,12 @@ function fsOpenFiles(callback) {
available: null
};
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) {
if (!error) {
let lines = stdout.toString().split('\n');
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;
}
if (callback) {
@ -776,37 +780,37 @@ function diskLayout(callback) {
function getVendorFromModel(model) {
const diskManufacturers = [
{ pattern: '^WESTERN.+', manufacturer: 'Western Digital' },
{ pattern: '^WDC.+', manufacturer: 'Western Digital' },
{ pattern: 'WD.+', manufacturer: 'Western Digital' },
{ pattern: '^TOSHIBA.+', manufacturer: 'Toshiba' },
{ pattern: '^HITACHI.+', manufacturer: 'Hitachi' },
{ pattern: '^IC.+', manufacturer: 'Hitachi' },
{ pattern: '^HTS.+', manufacturer: 'Hitachi' },
{ pattern: '^SANDISK.+', manufacturer: 'SanDisk' },
{ pattern: '^KINGSTON.+', manufacturer: 'Kingston Technology' },
{ pattern: '^SONY.+', manufacturer: 'Sony' },
{ pattern: '^TRANSCEND.+', manufacturer: 'Transcend' },
{ pattern: 'SAMSUNG.+', manufacturer: 'Samsung' },
{ pattern: '^ST(?!I\\ ).+', manufacturer: 'Seagate' },
{ pattern: '^STI\\ .+', manufacturer: 'SimpleTech' },
{ pattern: '^D...-.+', manufacturer: 'IBM' },
{ pattern: '^IBM.+', manufacturer: 'IBM' },
{ pattern: '^FUJITSU.+', manufacturer: 'Fujitsu' },
{ pattern: '^MP.+', manufacturer: 'Fujitsu' },
{ pattern: '^MK.+', manufacturer: 'Toshiba' },
{ pattern: '^MAXTOR.+', manufacturer: 'Maxtor' },
{ pattern: '^Pioneer.+', manufacturer: 'Pioneer' },
{ pattern: '^PHILIPS.+', manufacturer: 'Philips' },
{ pattern: '^QUANTUM.+', manufacturer: 'Quantum Technology' },
{ pattern: 'FIREBALL.+', manufacturer: 'Quantum Technology' },
{ pattern: '^VBOX.+', manufacturer: 'VirtualBox' },
{ pattern: 'CORSAIR.+', manufacturer: 'Corsair Components' },
{ pattern: 'CRUCIAL.+', manufacturer: 'Crucial' },
{ pattern: 'ECM.+', manufacturer: 'ECM' },
{ pattern: 'INTEL.+', manufacturer: 'INTEL' },
{ pattern: '.+EVO', manufacturer: 'Samsung' },
{ pattern: 'APPLE.+', manufacturer: 'Apple' },
{ pattern: 'WESTERN.*', manufacturer: 'Western Digital' },
{ pattern: '^WDC.*', manufacturer: 'Western Digital' },
{ pattern: 'WD.*', manufacturer: 'Western Digital' },
{ pattern: 'TOSHIBA.*', manufacturer: 'Toshiba' },
{ pattern: 'HITACHI.*', manufacturer: 'Hitachi' },
{ pattern: '^IC.*', manufacturer: 'Hitachi' },
{ pattern: '^HTS.*', manufacturer: 'Hitachi' },
{ pattern: 'SANDISK.*', manufacturer: 'SanDisk' },
{ pattern: 'KINGSTON.*', manufacturer: 'Kingston Technology' },
{ pattern: '^SONY.*', manufacturer: 'Sony' },
{ pattern: 'TRANSCEND.*', manufacturer: 'Transcend' },
{ pattern: 'SAMSUNG.*', manufacturer: 'Samsung' },
{ pattern: '^ST(?!I\\ ).*', manufacturer: 'Seagate' },
{ pattern: '^STI\\ .*', manufacturer: 'SimpleTech' },
{ pattern: '^D...-.*', manufacturer: 'IBM' },
{ pattern: '^IBM.*', manufacturer: 'IBM' },
{ pattern: '^FUJITSU.*', manufacturer: 'Fujitsu' },
{ pattern: '^MP.*', manufacturer: 'Fujitsu' },
{ pattern: '^MK.*', manufacturer: 'Toshiba' },
{ pattern: 'MAXTO.*', manufacturer: 'Maxtor' },
{ pattern: 'PIONEER.*', manufacturer: 'Pioneer' },
{ pattern: 'PHILIPS.*', manufacturer: 'Philips' },
{ pattern: 'QUANTUM.*', manufacturer: 'Quantum Technology' },
{ pattern: 'FIREBALL.*', manufacturer: 'Quantum Technology' },
{ pattern: '^VBOX.*', manufacturer: 'VirtualBox' },
{ pattern: 'CORSAIR.*', manufacturer: 'Corsair Components' },
{ pattern: 'CRUCIAL.*', manufacturer: 'Crucial' },
{ pattern: 'ECM.*', manufacturer: 'ECM' },
{ pattern: 'INTEL.*', manufacturer: 'INTEL' },
{ pattern: 'EVO.*', manufacturer: 'Samsung' },
{ pattern: 'APPLE.*', manufacturer: 'Apple' },
];
let result = '';

View File

@ -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))),
sizeX: 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,
resolutionY: pixelParts.length > 1 ? parseInt(pixelParts[1], 10) : null,
currentResX: currentResolution.length > 1 ? parseInt(currentResolution[0], 10) : null,
@ -860,7 +860,7 @@ function graphics(callback) {
if (_pixelDepth) {
result.displays[0].pixelDepth = _pixelDepth;
}
if (_refreshRate && !result.displays[0].refreshRate) {
if (_refreshRate && !result.displays[0].currentRefreshRate) {
result.displays[0].currentRefreshRate = _refreshRate;
}
}

46
lib/index.d.ts vendored
View File

@ -38,6 +38,7 @@ export namespace Systeminformation {
version: string;
releaseDate: string;
revision: string;
serial?: string;
language?: string;
features?: string[];
}
@ -302,7 +303,7 @@ export namespace Systeminformation {
deviceId?: string;
bus: string;
busAddress?: string;
vram: number;
vram: number | null;
vramDynamic: boolean;
external?: boolean;
cores?: number;
@ -311,6 +312,7 @@ export namespace Systeminformation {
driverVersion?: string;
name?: string;
pciBus?: string;
pciID?: string;
fanSpeed?: number;
memoryTotal?: number;
memoryUsed?: number;
@ -327,21 +329,25 @@ export namespace Systeminformation {
interface GraphicsDisplayData {
vendor: string;
vendorId: string | null;
model: string;
deviceName: string;
productionYear: number | null;
serial: string | null;
deviceName: string | null;
displayId: string | null;
main: boolean;
builtin: boolean;
connection: string;
sizeX: number;
sizeY: number;
pixelDepth: number;
resolutionX: number;
resolutionY: number;
currentResX: number;
currentResY: number;
connection: string | null;
sizeX: number | null;
sizeY: number | null;
pixelDepth: number | null;
resolutionX: number | null;
resolutionY: number | null;
currentResX: number | null;
currentResY: number | null;
positionX: number;
positionY: number;
currentRefreshRate: number;
currentRefreshRate: number | null;
}
// 4. Operating System
@ -452,9 +458,9 @@ export namespace Systeminformation {
rx: number;
wx: number;
tx: number;
rx_sec: number;
wx_sec: number;
tx_sec: number;
rx_sec: number | null;
wx_sec: number | null;
tx_sec: number | null;
ms: number;
}
@ -462,9 +468,15 @@ export namespace Systeminformation {
rIO: number;
wIO: number;
tIO: number;
rIO_sec: number;
wIO_sec: number;
tIO_sec: number;
rIO_sec: number | null;
wIO_sec: number | null;
tIO_sec: number | null;
rWaitTime: number;
wWaitTime: number;
tWaitTime: number;
rWaitPercent: number | null;
wWaitPercent: number | null;
tWaitPercent: number | null;
ms: number;
}

View File

@ -198,7 +198,7 @@ function mem(callback) {
});
}
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) {
let lines = stdout.toString().split('\n');
const pagesize = parseInt(util.getValue(lines, 'vm.stats.vm.v_page_size'), 10);
@ -331,7 +331,7 @@ function memLayout(callback) {
serialNum: util.getValue(lines, 'Serial Number:'),
voltageConfigured: parseFloat(util.getValue(lines, 'Configured Voltage:')) || null,
voltageMin: parseFloat(util.getValue(lines, 'Minimum Voltage:')) || null,
voltageMax: parseFloat(util.getValue(lines, 'Maximum Voltage:'))|| null,
voltageMax: parseFloat(util.getValue(lines, 'Maximum Voltage:')) || null,
});
} else {
result.push({

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -283,16 +283,21 @@ function users(callback) {
}
if (_windows) {
try {
const workload = [];
// 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_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'));
Promise.all(
workload
).then(data => {
// const workload = [];
// // 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_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'));
// Promise.all(
// workload
// ).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
// let accounts = parseWinAccounts(data[0].split(/\n\s*\n/));
data = data.split('#-#-#-#');
let sessions = parseWinSessions(data[0].split(/\n\s*\n/));
let loggedons = parseWinLoggedOn(data[1].split(/\n\s*\n/));
let users = parseWinUsers(data[2].split(/\n\s*\n/));

View File

@ -360,7 +360,7 @@ function powerShell(cmd) {
return new Promise((resolve) => {
process.nextTick(() => {
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',
windowsHide: true,
maxBuffer: 1024 * 20000,
@ -875,6 +875,7 @@ function decodePiCpuinfo(lines) {
'0f': 'Internal use only',
'10': 'CM3+',
'11': '4B',
'12': 'Zero 2 W',
'13': '400',
'14': 'CM4'
};