code improvements, typings improvement

This commit is contained in:
Sebastian Hildebrandt 2021-10-25 22:26:03 +02:00
parent 432f916359
commit 37f4e94c73
6 changed files with 89 additions and 30 deletions

View File

@ -85,7 +85,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page.
| 5.9.6 | 2021-10-08 | `system()` fixed virtual on WSL2 | | 5.9.6 | 2021-10-08 | `system()` fixed virtual on WSL2 |
| 5.9.5 | 2021-10-08 | `battery()` fixed isCharging (windows) | | 5.9.5 | 2021-10-08 | `battery()` fixed isCharging (windows) |
| 5.9.4 | 2021-09-23 | `processes()` fixed memVsz, Memrss (macOS M1) | | 5.9.4 | 2021-09-23 | `processes()` fixed memVsz, Memrss (macOS M1) |
| 5.9.3 | 2021-09-17 | `cpuTemperature()` improved tdie detection (linus) | | 5.9.3 | 2021-09-17 | `cpuTemperature()` improved tdie detection (linux) |
| 5.9.2 | 2021-09-16 | `graohics()` (macOS), `memLayout()` (win) improvements | | 5.9.2 | 2021-09-16 | `graohics()` (macOS), `memLayout()` (win) improvements |
| 5.9.1 | 2021-09-15 | `diskLayout()` fix size (macOS) | | 5.9.1 | 2021-09-15 | `diskLayout()` fix size (macOS) |
| 5.9.0 | 2021-09-15 | `graphics()` new XML parser, added properties (macOS) | | 5.9.0 | 2021-09-15 | `graphics()` new XML parser, added properties (macOS) |

View File

@ -373,10 +373,12 @@ const AMDBaseFrequencies = {
'4700G': '3.6', '4700G': '3.6',
'Pro 4750G': '3.6', 'Pro 4750G': '3.6',
'4300U': '2.7', '4300U': '2.7',
'4450U': '2.5',
'Pro 4450U': '2.5', 'Pro 4450U': '2.5',
'4500U': '2.3', '4500U': '2.3',
'4600U': '2.1', '4600U': '2.1',
'PRO 4650U': '2.1', 'PRO 4650U': '2.1',
'4680U': '2.1',
'4600HS': '3.0', '4600HS': '3.0',
'4600H': '3.0', '4600H': '3.0',
'4700U': '2.0', '4700U': '2.0',
@ -386,6 +388,9 @@ const AMDBaseFrequencies = {
'4800H': '2.9', '4800H': '2.9',
'4900HS': '3.0', '4900HS': '3.0',
'4900H': '3.3', '4900H': '3.3',
'5300U': '2.6',
'5500U': '2.1',
'5700U': '1.8',
// ZEN2 - EPYC // ZEN2 - EPYC
'7232P': '3.1', '7232P': '3.1',
@ -414,6 +419,28 @@ const AMDBaseFrequencies = {
'7F52': '3.5', '7F52': '3.5',
'7F72': '3.2', '7F72': '3.2',
// Epyc (Milan)
'7763': '2.45',
'7713': '2.0',
'7713P': '2.0',
'7663': '2.0',
'7643': '2.3',
'75F3': '2.95',
'7543': '2.8',
'7543P': '2.8',
'7513': '2.6',
'7453': '2.75',
'74F3': '3.2',
'7443': '2.85',
'7443P': '2.85',
'7413': '2.65',
'73F3': '3.5',
'7343': '3.2',
'7313': '3.0',
'7313P': '3.0',
'72F3': '3.7',
// ZEN3 // ZEN3
'5600X': '3.7', '5600X': '3.7',
'5800X': '3.8', '5800X': '3.8',
@ -421,6 +448,7 @@ const AMDBaseFrequencies = {
'5950X': '3.4' '5950X': '3.4'
}; };
const socketTypes = { const socketTypes = {
1: 'Other', 1: 'Other',
2: 'Unknown', 2: 'Unknown',
@ -484,6 +512,7 @@ const socketTypes = {
60: 'BGA1528', 60: 'BGA1528',
61: 'LGA4189', 61: 'LGA4189',
62: 'LGA1200', 62: 'LGA1200',
63: 'LGA4677',
}; };
function cpuBrandManufacturer(res) { function cpuBrandManufacturer(res) {
@ -739,8 +768,8 @@ function getCpu() {
const threadCount = util.getValue(lines, 'thread count').trim(); const threadCount = util.getValue(lines, 'thread count').trim();
const coreCount = util.getValue(lines, 'core count').trim(); const coreCount = util.getValue(lines, 'core count').trim();
if (coreCount && threadCount) { if (coreCount && threadCount) {
result.cores = threadCount; result.cores = parseInt(threadCount, 10);
result.physicalCores = coreCount; result.physicalCores = parseInt(coreCount, 10);
} }
resolve(result); resolve(result);
}); });
@ -1237,7 +1266,7 @@ function cpuFlags(callback) {
let flags = []; let flags = [];
if (!error) { if (!error) {
let parts = stdout.toString().split('\tFlags:'); let parts = stdout.toString().split('\tFlags:');
const lines = parts.length > 1 ? parts[1].split('\tVersion:')[0].split['\n'] : []; const lines = parts.length > 1 ? parts[1].split('\tVersion:')[0].split('\n') : [];
lines.forEach(function (line) { lines.forEach(function (line) {
let flag = (line.indexOf('(') ? line.split('(')[0].toLowerCase() : '').trim().replace(/\t/g, ''); let flag = (line.indexOf('(') ? line.split('(')[0].toLowerCase() : '').trim().replace(/\t/g, '');
if (flag) { if (flag) {
@ -1538,18 +1567,18 @@ function getLoad() {
} }
result = { result = {
avgLoad: avgLoad, avgLoad: avgLoad,
currentload: _current_cpu.currentload, currentload: _current_cpu.currentLoad,
currentloadUser: _current_cpu.currentloadUser, currentloadUser: _current_cpu.currentLoadUser,
currentloadSystem: _current_cpu.currentloadSystem, currentloadSystem: _current_cpu.currentLoadSystem,
currentloadNice: _current_cpu.currentloadNice, currentloadNice: _current_cpu.currentLoadNice,
currentloadIdle: _current_cpu.currentloadIdle, currentloadIdle: _current_cpu.currentLoadIdle,
currentloadIrq: _current_cpu.currentloadIrq, currentloadIrq: _current_cpu.currentLoadIrq,
rawCurrentload: _current_cpu.rawCurrentload, rawCurrentload: _current_cpu.rawCurrentLoad,
rawCurrentloadUser: _current_cpu.rawCurrentloadUser, rawCurrentloadUser: _current_cpu.rawCurrentLoadUser,
rawCurrentloadSystem: _current_cpu.rawCurrentloadSystem, rawCurrentloadSystem: _current_cpu.rawCurrentLoadSystem,
rawCurrentloadNice: _current_cpu.rawCurrentloadNice, rawCurrentloadNice: _current_cpu.rawCurrentLoadNice,
rawCurrentloadIdle: _current_cpu.rawCurrentloadIdle, rawCurrentloadIdle: _current_cpu.rawCurrentLoadIdle,
rawCurrentloadIrq: _current_cpu.rawCurrentloadIrq, rawCurrentloadIrq: _current_cpu.rawCurrentLoadIrq,
cpus: cores cpus: cores
}; };
} }

View File

@ -543,7 +543,12 @@ function dockerContainerStatsSingle(containerID) {
blockIO: { blockIO: {
r: 0, r: 0,
w: 0 w: 0
} },
restartCount: 0,
cpuStats: {},
precpuStats: {},
memoryStats: {},
networks: {},
}; };
return new Promise((resolve) => { return new Promise((resolve) => {
process.nextTick(() => { process.nextTick(() => {

36
lib/index.d.ts vendored
View File

@ -48,6 +48,8 @@ export namespace Systeminformation {
version: string; version: string;
serial: string; serial: string;
assetTag: string; assetTag: string;
memMax: number | null;
memSlots: number | null;
} }
interface ChassisData { interface ChassisData {
@ -127,14 +129,15 @@ export namespace Systeminformation {
size: number; size: number;
bank: string; bank: string;
type: string; type: string;
ecc?: boolean; ecc?: boolean | null;
clockSpeed: number; clockSpeed: number | null;
formFactor: string; formFactor: string;
manufacturer?: string;
partNum: string; partNum: string;
serialNum: string; serialNum: string;
voltageConfigured: number; voltageConfigured: number | null;
voltageMin: number; voltageMin: number | null;
voltageMax: number; voltageMax: number | null;
} }
interface SmartData { interface SmartData {
@ -360,11 +363,13 @@ export namespace Systeminformation {
uefi: boolean; uefi: boolean;
hypervizor?: boolean; hypervizor?: boolean;
remoteSession?: boolean; remoteSession?: boolean;
hypervisor?: boolean;
} }
interface UuidData { interface UuidData {
os: string; os: string;
hardware: string; hardware: string;
macs: string[];
} }
interface VersionData { interface VersionData {
@ -537,6 +542,7 @@ export namespace Systeminformation {
iface: string; iface: string;
model: string; model: string;
vendor: string; vendor: string;
mac: string;
} }
interface WifiConnectionData { interface WifiConnectionData {
@ -741,6 +747,7 @@ export namespace Systeminformation {
memLimit: number; memLimit: number;
memPercent: number; memPercent: number;
cpuPercent: number; cpuPercent: number;
pids: number;
netIO: { netIO: {
rx: number; rx: number;
wx: number; wx: number;
@ -756,6 +763,23 @@ export namespace Systeminformation {
networks: any; networks: any;
} }
interface DockerContainerProcessData {
pidHost: string;
ppid: string;
pgid: string;
user: string;
ruser: string;
group: string;
rgroup: string;
stat: string;
time: string;
elapsed: string;
nice: string;
rss: string;
vsz: string;
command: string;
}
interface DockerVolumeData { interface DockerVolumeData {
name: string; name: string;
driver: string; driver: string;
@ -931,7 +955,7 @@ export function dockerInfo(cb?: (data: Systeminformation.DockerInfoData) => any)
export function dockerImages(all?: boolean, cb?: (data: Systeminformation.DockerImageData[]) => any): Promise<Systeminformation.DockerImageData[]>; export function dockerImages(all?: boolean, cb?: (data: Systeminformation.DockerImageData[]) => any): Promise<Systeminformation.DockerImageData[]>;
export function dockerContainers(all?: boolean, cb?: (data: Systeminformation.DockerContainerData[]) => any): Promise<Systeminformation.DockerContainerData[]>; export function dockerContainers(all?: boolean, cb?: (data: Systeminformation.DockerContainerData[]) => any): Promise<Systeminformation.DockerContainerData[]>;
export function dockerContainerStats(id?: string, cb?: (data: Systeminformation.DockerContainerStatsData[]) => any): Promise<Systeminformation.DockerContainerStatsData[]>; export function dockerContainerStats(id?: string, cb?: (data: Systeminformation.DockerContainerStatsData[]) => any): Promise<Systeminformation.DockerContainerStatsData[]>;
export function dockerContainerProcesses(id?: string, cb?: (data: any) => any): Promise<any>; export function dockerContainerProcesses(id?: string, cb?: (data: any) => any): Promise<Systeminformation.DockerContainerProcessData[]>;
export function dockerVolumes(cb?: (data: Systeminformation.DockerVolumeData[]) => any): Promise<Systeminformation.DockerVolumeData[]>; export function dockerVolumes(cb?: (data: Systeminformation.DockerVolumeData[]) => any): Promise<Systeminformation.DockerVolumeData[]>;
export function dockerAll(cb?: (data: any) => any): Promise<any>; export function dockerAll(cb?: (data: any) => any): Promise<any>;

View File

@ -329,9 +329,9 @@ function memLayout(callback) {
manufacturer: getManufacturerLinux(util.getValue(lines, 'Manufacturer:')), manufacturer: getManufacturerLinux(util.getValue(lines, 'Manufacturer:')),
partNum: util.getValue(lines, 'Part Number:'), partNum: util.getValue(lines, 'Part Number:'),
serialNum: util.getValue(lines, 'Serial Number:'), serialNum: util.getValue(lines, 'Serial Number:'),
voltageConfigured: parseFloat(util.getValue(lines, 'Configured Voltage:') || null), voltageConfigured: parseFloat(util.getValue(lines, 'Configured Voltage:')) || null,
voltageMin: parseFloat(util.getValue(lines, 'Minimum 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 { } else {
result.push({ result.push({
@ -384,14 +384,14 @@ function memLayout(callback) {
result[0].type = version && version[2] && version[2] === '3' ? 'LPDDR4' : result[0].type; result[0].type = version && version[2] && version[2] === '3' ? 'LPDDR4' : result[0].type;
result[0].ecc = false; result[0].ecc = false;
result[0].clockSpeed = version && version[2] && clockSpeed[version[2]] || 400; result[0].clockSpeed = version && version[2] && clockSpeed[version[2]] || 400;
result[0].clockSpeed = version && version[4] && version[4] === 'd' ? '500' : result[0].clockSpeed; result[0].clockSpeed = version && version[4] && version[4] === 'd' ? 500 : result[0].clockSpeed;
result[0].formFactor = 'SoC'; result[0].formFactor = 'SoC';
stdout = execSync('vcgencmd get_config sdram_freq 2>/dev/null'); stdout = execSync('vcgencmd get_config sdram_freq 2>/dev/null');
lines = stdout.toString().split('\n'); lines = stdout.toString().split('\n');
let freq = parseInt(util.getValue(lines, 'sdram_freq', '=', true), 10) || 0; let freq = parseInt(util.getValue(lines, 'sdram_freq', '=', true), 10) || 0;
if (freq) { if (freq) {
result.clockSpeed = freq; result[0].clockSpeed = freq;
} }
stdout = execSync('vcgencmd measure_volts sdram_p 2>/dev/null'); stdout = execSync('vcgencmd measure_volts sdram_p 2>/dev/null');
@ -469,7 +469,7 @@ function memLayout(callback) {
if (size && type) { if (size && type) {
result.push({ result.push({
size: size * 1024 * 1024 * 1024, size: size * 1024 * 1024 * 1024,
bank: 0, bank: '0',
type, type,
ecc: false, ecc: false,
clockSpeed: 0, clockSpeed: 0,

View File

@ -196,7 +196,7 @@ function osInfo(callback) {
process.nextTick(() => { process.nextTick(() => {
let result = { let result = {
platform: (_platform === 'Windows_NT' ? 'Windows' : _platform), platform: (_platform === 'win32' ? 'Windows' : _platform),
distro: 'unknown', distro: 'unknown',
release: 'unknown', release: 'unknown',
codename: '', codename: '',
@ -299,6 +299,7 @@ function osInfo(callback) {
result.codename = (result.release.indexOf('10.14') > -1 ? 'macOS Mojave' : result.codename); result.codename = (result.release.indexOf('10.14') > -1 ? 'macOS Mojave' : result.codename);
result.codename = (result.release.indexOf('10.15') > -1 ? 'macOS Catalina' : result.codename); result.codename = (result.release.indexOf('10.15') > -1 ? 'macOS Catalina' : result.codename);
result.codename = (result.release.startsWith('11.') ? 'macOS Big Sur' : result.codename); result.codename = (result.release.startsWith('11.') ? 'macOS Big Sur' : result.codename);
result.codename = (result.release.startsWith('12.') ? 'macOS Monterey' : result.codename);
result.uefi = true; result.uefi = true;
result.codepage = util.getCodepage(); result.codepage = util.getCodepage();
if (callback) { if (callback) {