From 22e774b41fb012ced14fa86e7fd30b7efcc2c08b Mon Sep 17 00:00:00 2001 From: Kroese Date: Tue, 26 Nov 2024 16:52:02 +0100 Subject: [PATCH] fix: Get resource usage without root --- source/modules/system.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/modules/system.ts b/source/modules/system.ts index d38fede..9d80552 100644 --- a/source/modules/system.ts +++ b/source/modules/system.ts @@ -99,7 +99,7 @@ export async function getDiskUsage( // Returns a list of all processes and their memory usage async function getProcessesMemory() { // Get a snapshot of system CPU and memory usage - const ps = await $`ps -Ao pid,pss --no-header` + const ps = await $`docker exec --privileged -it $HOSTNAME ps -Ao pid,pss --no-header` // Format snapshot data const processes = ps.stdout.split('\n').map((line) => { @@ -188,7 +188,7 @@ export async function getMemoryUsage(umbreld: Umbreld): Promise<{ // Returns a list of all processes and their cpu usage async function getProcessesCpu() { // Get a snapshot of system CPU and memory usage - const top = await $`top --batch-mode --iterations 1` + const top = await $`docker exec --privileged -it $HOSTNAME top --batch-mode --iterations 1` // Get lines const lines = top.stdout.split('\n').map((line) => line.trim().split(/\s+/))