Container Stats Inaccurate


#1

I use this code:

let cpu = Math.round(process.cpuUsage().system / 1024 / 1024 * 10) / 10;
let cpupercent = Math.round((cpu) / 1000) / 10;

 // contributors: my bro
let ram = Math.round(process.memoryUsage().heapUsed / 1024 / 1024 * 10) / 10;
let rampercent = Math.round((ram / 512) * 1000) / 10;

But when it’s displayed in my Discord Bot it’s not anywhere close to when I click container stats.


#2

Hey @Fyrlex as Gareth noted in the other thread where you asked about this, what you’re using here will only report on what the current process is doing, not the container’s stats overall. Also as I mentioned there, the container stats pane uses some sliding window logic to render averages; you won’t achieve exactly the same information as what you see in the stats pane.