node-os-utils icon indicating copy to clipboard operation
node-os-utils copied to clipboard

CPU Utilization not properly reported in K8s env

Open imochurad opened this issue 2 years ago • 1 comments

My application is containerized and runs in a K8S pod, here is the snippet:

var osu = require('node-os-utils')
var cpu = osu.cpu

let cpuUtilization: number = -1;

setInterval(async function () {
  cpu.usage()
    .then((cpuPercentage: number) => {
      cpuUtilization = cpuPercentage;
      logger.info(`Updating cpu utilization to cpuUtil=${cpuUtilization}`);
    });
}, 10 * 1000); // invoke every 10 seconds

Unfortunately, the library doesn't return correct value for POD utilization, the values never go over 35%, whereas on grafana dashboard Pods CPU utilization is reported to reach 100% with the CPU throttling taking place.

Is this a known issue?

imochurad avatar May 01 '23 20:05 imochurad

@imochurad have you made any progress since your post?

fbruffaert avatar Jun 22 '23 18:06 fbruffaert