SunilWang / node-os-utils

OS Utils - An operating system utility library.
https://www.npmjs.com/package/node-os-utils
MIT License
125 stars 19 forks source link

CPU Utilization not properly reported in K8s env #36

Open imochurad opened 1 year ago

imochurad commented 1 year ago

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?

fbruffaert commented 1 year ago

@imochurad have you made any progress since your post?