diff --git a/core/modules/Metrics/svRuntime/perfUtils.ts b/core/modules/Metrics/svRuntime/perfUtils.ts index c9536aaa8..aca7a1fb8 100644 --- a/core/modules/Metrics/svRuntime/perfUtils.ts +++ b/core/modules/Metrics/svRuntime/perfUtils.ts @@ -1,4 +1,4 @@ -import pidusage from 'pidusage'; +import si from 'systeminformation'; import { cloneDeep } from 'lodash-es'; import type { SvRtPerfCountsType } from "./perfSchemas"; import got from '@lib/got'; @@ -6,7 +6,6 @@ import { parseRawPerf } from './perfParser'; import { PERF_DATA_BUCKET_COUNT } from './config'; import { txEnv } from '@core/globalData'; - //Consts const perfDataRawThreadsTemplate: SvRtPerfCountsType = { svSync: { @@ -108,14 +107,15 @@ export const fetchRawPerfData = async (fxServerHost: string) => { /** * Get the fxserver memory usage - * FIXME: migrate to use gwmi on windows by default */ export const fetchFxsMemory = async (fxsPid?: number) => { if (!fxsPid) return; try { - const pidUsage = await pidusage(fxsPid); - const memoryMb = pidUsage.memory / 1024 / 1024; + const totalMem = (await si.mem()).total + const pidUsage = (await si.processLoad("fxServer"))[0].mem /* Limitations only allow us to use process names to get memory */ + const memoryMb = (totalMem * (pidUsage / 100)) / (1024 * 1024); return parseFloat((memoryMb).toFixed(2)); + } catch (error) { if ((error as any).code = 'ENOENT') { console.error('Failed to get processes tree usage data.');