versions() fix postgres, code cleanup

This commit is contained in:
Sebastian Hildebrandt 2022-10-15 00:39:22 +02:00
parent 601bc680d0
commit 69b3571d98
8 changed files with 574 additions and 599 deletions

File diff suppressed because it is too large Load Diff

View File

@ -208,7 +208,7 @@ Full function reference with examples can be found at [https://systeminformation
| | governor | X | | | | | e.g. 'powersave' |
| | cores | X | X | X | X | | # cores |
| | physicalCores | X | X | X | X | | # physical cores |
| | efficiencyCores | X | | X | | | # efficiancy cores |
| | efficiencyCores | X | | X | | | # efficiency cores |
| | performanceCores | X | | X | | | # performance cores |
| | processors | X | X | X | X | | # processors |
| | socket | X | X | | X | | socket type e.g. "LGA1356" |

View File

@ -57,6 +57,11 @@
</tr>
</thead>
<tbody>
<tr>
<th scope="row">5.12.7</th>
<td>2022-10-15</td>
<td><span class="code">versions()</span> fix postgres</td>
</tr>
<tr>
<th scope="row">5.12.6</th>
<td>2022-08-18</td>

View File

@ -170,7 +170,7 @@
<img class="logo" src="assets/logo.png" alt="logo">
<div class="title">systeminformation</div>
<div class="subtitle"><span id="typed"></span>&nbsp;</div>
<div class="version">New Version: <span id="version">5.12.6</span></div>
<div class="version">New Version: <span id="version">5.12.7</span></div>
<button class="btn btn-light" onclick="location.href='https://github.com/sebhildebrandt/systeminformation'">View on Github <i class=" fab fa-github"></i></button>
</div>
<div class="down">
@ -214,7 +214,7 @@
<div class="title">Downloads last month</div>
</div>
<div class="col-xl-4 col-lg-4 col-md-4 col-12">
<div class="numbers">583</div>
<div class="numbers">585</div>
<div class="title">Dependents</div>
</div>
</div>

View File

@ -16,7 +16,6 @@
const exec = require('child_process').exec;
const execSync = require('child_process').execSync;
const util = require('./util');
// const fs = require('fs');
let _platform = process.platform;
@ -79,7 +78,6 @@ function parseLinuxAudioPciMM(lines, audioPCI) {
result.id = slotId;
result.name = util.getValue(lines, 'SDevice');
// result.type = util.getValue(lines, 'Class');
result.manufacturer = util.getValue(lines, 'SVendor');
result.revision = util.getValue(lines, 'Rev');
result.driver = pciMatch && pciMatch.length === 1 && pciMatch[0].driver ? pciMatch[0].driver : '';
@ -128,7 +126,6 @@ function parseDarwinAudio(audioObject, id) {
function parseWindowsAudio(lines) {
const result = {};
const status = util.getValue(lines, 'StatusInfo', ':');
// const description = util.getValue(lines, 'Description', ':');
result.id = util.getValue(lines, 'DeviceID', ':'); // PNPDeviceID??
result.name = util.getValue(lines, 'name', ':');

View File

@ -51,7 +51,7 @@ function parseWinBatteryPart(lines, designedCapacity, fullChargeCapacity) {
result.capacityUnit = 'mWh';
result.percent = parseInt(util.getValue(lines, 'EstimatedChargeRemaining', ':') || 0);
result.currentCapacity = parseInt(result.maxCapacity * result.percent / 100);
result.isCharging = (statusValue >= 6 && statusValue <= 9) || statusValue === 11 || (!(statusValue === 3) && !(statusValue === 1) && result.percent < 100);
result.isCharging = (statusValue >= 6 && statusValue <= 9) || statusValue === 11 || ((statusValue !== 3) && (statusValue !== 1) && result.percent < 100);
result.acConnected = result.isCharging || statusValue === 2;
result.model = util.getValue(lines, 'DeviceID', ':');
} else {
@ -232,7 +232,6 @@ module.exports = function (callback) {
workload
).then(data => {
if (data) {
// let parts = data.results[0].split(/\n\s*\n/);
let parts = data.results[0].split(/\n\s*\n/);
let batteries = [];
const hasValue = value => /\S/.test(value);

View File

@ -617,14 +617,6 @@ function getCpu() {
cpuFlags().then(flags => {
result.flags = flags;
result.virtualization = flags.indexOf('vmx') > -1 || flags.indexOf('svm') > -1;
// if (_windows) {
// try {
// const systeminfo = execSync('systeminfo', util.execOptsWin).toString();
// result.virtualization = result.virtualization || (systeminfo.indexOf('Virtualization Enabled In Firmware: Yes') !== -1) || (systeminfo.indexOf('Virtualisierung in Firmware aktiviert: Ja') !== -1) || (systeminfo.indexOf('Virtualisation activée dans le microprogramme : Qiu') !== -1);
// } catch (e) {
// util.noop();
// }
// }
if (_darwin) {
exec('sysctl machdep.cpu hw.cpufrequency_max hw.cpufrequency_min hw.packages hw.physicalcpu_max hw.ncpu hw.tbfrequency hw.cpufamily hw.cpusubfamily', function (error, stdout) {
let lines = stdout.toString().split('\n');
@ -695,12 +687,9 @@ function getCpu() {
result = cpuBrandManufacturer(result);
result.vendor = cpuManufacturer(util.getValue(lines, 'vendor id'));
// if (!result.vendor) { result.vendor = util.getValue(lines, 'anbieterkennung'); }
result.family = util.getValue(lines, 'cpu family');
// if (!result.family) { result.family = util.getValue(lines, 'prozessorfamilie'); }
result.model = util.getValue(lines, 'model:');
// if (!result.model) { result.model = util.getValue(lines, 'modell:'); }
result.stepping = util.getValue(lines, 'stepping');
result.revision = util.getValue(lines, 'cpu revision');
result.cache.l1d = util.getValue(lines, 'l1d cache');
@ -713,11 +702,9 @@ function getCpu() {
if (result.cache.l3) { result.cache.l3 = parseInt(result.cache.l3) * (result.cache.l3.indexOf('M') !== -1 ? 1024 * 1024 : (result.cache.l3.indexOf('K') !== -1 ? 1024 : 1)); }
const threadsPerCore = util.getValue(lines, 'thread(s) per core') || '1';
// const coresPerSocketInt = parseInt(util.getValue(lines, 'cores(s) per socket') || '1', 10);
const processors = util.getValue(lines, 'socket(s)') || '1';
let threadsPerCoreInt = parseInt(threadsPerCore, 10); // threads per code (normally only for performance cores)
let processorsInt = parseInt(processors, 10) || 1; // number of sockets / processor units in machine (normally 1)
// const cpus = (parseInt(util.getValue(lines, 'cpu(s)'), 10) || 1); // overall number of cores (e.g. 24 on i12900)
const coresPerSocket = parseInt(util.getValue(lines, 'core(s) per socket'), 10); // number of cores (e.g. 16 on i12900)
result.physicalCores = coresPerSocket ? coresPerSocket * processorsInt : result.cores / threadsPerCoreInt;
result.performanceCores = threadsPerCoreInt > 1 ? result.cores - result.physicalCores : result.cores;
@ -779,7 +766,7 @@ function getCpu() {
result.vendor = cpuManufacturer(util.getValue(lines, 'manufacturer'));
let sig = util.getValue(lines, 'signature');
sig = sig.split(',');
for (var i = 0; i < sig.length; i++) {
for (let i = 0; i < sig.length; i++) {
sig[i] = sig[i].trim();
}
result.family = util.getValue(sig, 'Family', ' ', true);
@ -825,7 +812,6 @@ function getCpu() {
const workload = [];
workload.push(util.powerShell('Get-WmiObject Win32_processor | select Name, Revision, L2CacheSize, L3CacheSize, Manufacturer, MaxClockSpeed, Description, UpgradeMethod, Caption, NumberOfLogicalProcessors, NumberOfCores | fl'));
workload.push(util.powerShell('Get-WmiObject Win32_CacheMemory | select CacheType,InstalledSize,Level | fl'));
// workload.push(util.powerShell('Get-ComputerInfo -property "HyperV*"'));
workload.push(util.powerShell('(Get-CimInstance Win32_ComputerSystem).HypervisorPresent'));
Promise.all(
@ -915,9 +901,6 @@ function getCpu() {
result.cache.l1d = parseInt(installedSize, 10) / 2;
}
});
// lines = data[2].split('\r\n');
// result.virtualization = (util.getValue(lines, 'HyperVRequirementVirtualizationFirmwareEnabled').toLowerCase() === 'true');
// result.virtualization = (util.getValue(lines, 'HyperVisorPresent').toLowerCase() === 'true');
const hyperv = data[2] ? data[2].toString().toLowerCase() : '';
result.virtualization = hyperv.indexOf('true') !== -1;
@ -1067,9 +1050,7 @@ function cpuTemperature(callback) {
});
if (result.cores.length > 0) {
// if (result.main === null) {
result.main = Math.round(result.cores.reduce((a, b) => a + b, 0) / result.cores.length);
// }
let maxtmp = Math.max.apply(Math, result.cores);
result.max = (maxtmp > result.main) ? maxtmp : result.main;
}
@ -1123,9 +1104,7 @@ function cpuTemperature(callback) {
}
});
if (result.cores.length > 0) {
// if (result.main === null) {
result.main = Math.round(result.cores.reduce((a, b) => a + b, 0) / result.cores.length);
// }
let maxtmp = Math.max.apply(Math, result.cores);
result.max = (maxtmp > result.main) ? maxtmp : result.main;
} else {
@ -1702,8 +1681,6 @@ function getFullLoad() {
let totalTicks = totalIdle + totalIrq + totalNice + totalSystem + totalUser;
result = (totalTicks - totalIdle) / totalTicks * 100.0;
} else {
result = 0;
}
resolve(result);
});

View File

@ -331,8 +331,6 @@ function osInfo(callback) {
try {
const workload = [];
workload.push(util.powerShell('Get-WmiObject Win32_OperatingSystem | select Caption,SerialNumber,BuildNumber,ServicePackMajorVersion,ServicePackMinorVersion | fl'));
// workload.push(execPromise('systeminfo', util.execOptsWin));
// workload.push(util.powerShell('Get-ComputerInfo -property "HyperV*"'));
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(
@ -344,10 +342,6 @@ function osInfo(callback) {
result.build = util.getValue(lines, 'BuildNumber', ':').trim();
result.servicepack = util.getValue(lines, 'ServicePackMajorVersion', ':').trim() + '.' + util.getValue(lines, 'ServicePackMinorVersion', ':').trim();
result.codepage = util.getCodepage();
// const systeminfo = data.results[1] ? data.results[1].toString() : '';
// result.hypervisor = (systeminfo.indexOf('hypervisor has been detected') !== -1) || (systeminfo.indexOf('ein Hypervisor erkannt') !== -1) || (systeminfo.indexOf('Un hyperviseur a ') !== -1);
// const hyperv = data.results[1] ? data.results[1].toString().split('\r\n') : [];
// result.hypervisor = (util.getValue(hyperv, 'HyperVisorPresent').toLowerCase() === 'true');
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() : '';
@ -740,7 +734,6 @@ function versions(apps, callback) {
}
functionProcessed();
});
functionProcessed();
}
});
} else {
@ -1003,17 +996,21 @@ function versions(apps, callback) {
}
}
if ({}.hasOwnProperty.call(appsObj.versions, 'dotnet')) {
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() : '')));
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() : ''));
});
appsObj.versions.dotnet = dotnet.trim();
functionProcessed();
});
appsObj.versions.dotnet = dotnet.trim();
} else {
functionProcessed();
});
}
}
} catch (e) {
if (callback) { callback(appsObj.versions); }
@ -1140,7 +1137,6 @@ echo -n "hardware: "; cat /sys/class/dmi/id/product_uuid 2> /dev/null; echo;`;
sysdir = '%windir%\\sysnative\\cmd.exe /c %windir%\\System32';
}
util.powerShell('Get-WmiObject Win32_ComputerSystemProduct | select UUID | fl').then((stdout) => {
// let lines = stdout.split('\r\n').filter(line => line.trim() !== '').filter((line, idx) => idx > 0)[0].trim().split(/\s\s+/);
let lines = stdout.split('\r\n');
result.hardware = util.getValue(lines, 'uuid', ':').toLowerCase();
exec(`${sysdir}\\reg query "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography" /v MachineGuid`, util.execOptsWin, function (error, stdout) {