Skip to content

CPU utilization metrics seems to be inconsistent #3471

@kioie

Description

@kioie
ISSUE TYPE
  • Bug Report
COMPONENT NAME
CPU utilization
CLOUDSTACK VERSION
4.11+
CONFIGURATION
OS / ENVIRONMENT
SUMMARY

CPU utilization metrics seems to be inconsistent with the actual CPU usage in the VM. The error seems to be generated from this getVMStat method in the LibvirtComputingResource class

 /* get cpu utilization */
            VmStats oldStats = null;

            final Calendar now = Calendar.getInstance();

            oldStats = _vmStats.get(vmName);

            long elapsedTime = 0;
            if (oldStats != null) {
                elapsedTime = now.getTimeInMillis() - oldStats._timestamp.getTimeInMillis();
                double utilization = (info.cpuTime - oldStats._usedTime) / ((double)elapsedTime * 1000000);

                final NodeInfo node = conn.nodeInfo();
                utilization = utilization / node.cpus;
                if (utilization > 0) {
                    stats.setCPUUtilization(utilization * 100);
                }
            }

STEPS TO REPRODUCE
Run stress test on the VM with 100% cpu utilization then confirm VM Metric on the statistics tab 

Screen Shot 2019-07-05 at 10 13 41 AM

Screen Shot 2019-07-05 at 10 13 21 AM

EXPECTED RESULTS
CPU utilization should be equally as high
ACTUAL RESULTS
CPU utilization is inconsistent i.e 8.4% (as shown)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions