Skip to content

Commit

Permalink
feat: [gpu] allow to filter-out some controller
Browse files Browse the repository at this point in the history
Based on model containing blacklisted words.
  • Loading branch information
Victor333Huesca authored and MauriceNino committed Jan 6, 2024
1 parent b6bb8cf commit 9651122
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions apps/server/src/data/gpu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,18 @@ const normalizeGpuModel = (model: string) => {
return model ? model.replace(/\[.*\]/gi, '').trim() : undefined;
};

const isValidController = (controller: si.Systeminformation.GraphicsControllerData) => {
const blacklist = ['monitor'];
const model = controller.model.toLowerCase();
return blacklist.every( w => ! model.includes(w) );
};

export default {
dynamic: async (): Promise<GpuLoad> => {
const gpuInfo = await si.graphics();

return {
layout: gpuInfo.controllers.map(controller => ({
layout: gpuInfo.controllers.filter(isValidController).map(controller => ({
load: controller.utilizationGpu ?? 0,
memory: controller.utilizationMemory ?? 0,
})),
Expand All @@ -28,7 +34,7 @@ export default {
const gpuInfo = await si.graphics();

return {
layout: gpuInfo.controllers.map(controller => ({
layout: gpuInfo.controllers.filter(isValidController).map(controller => ({
brand: normalizeGpuBrand(controller.vendor),
model:
normalizeGpuName(controller.name) ??
Expand Down

0 comments on commit 9651122

Please sign in to comment.