Hi All,

On engine core, The usage CPU percentage is calculated by %sys + %usr

class VdsBrokerObjectsBuilder
function updateVDSStatisticsData
vds.setCpuSys(AssignDoubleValue(xmlRpcStruct, VdsProperties.cpu_sys));
        vds.setCpuUser(AssignDoubleValue(xmlRpcStruct, VdsProperties.cpu_user));
        if (vds.getCpuSys() != null && vds.getCpuUser() != null) {
            vds.setUsageCpuPercent((int) (vds.getCpuSys() + vds.getCpuUser()));
        }

On vdsm, The %sys, %usr and %idle is calculated like below workflow,

class API
function getStats
decStats = self._cif._hostStats.get()
class clientIF
function __init__
                   self._hostStats = sampling.HostStatsThread(log=log)
        self._hostStats.start()
class HostStatsThread
function get
                   hs0, hs1 = self._samples[0], self._samples[-1]
                   ...
                   jiffies = (hs1.totcpu.user - hs0.totcpu.user) % (2 ** 32)
        stats['cpuUser'] = jiffies / interval / self._ncpus
        jiffies = (hs1.totcpu.sys - hs0.totcpu.sys) % (2 ** 32)
        stats['cpuSys'] = jiffies / interval / self._ncpus
        stats['cpuIdle'] = max(0.0, 100.0 - stats['cpuUser'] - stats['cpuSys'])
class HostSample
function __init__
                   self.totcpu = TotalCpuSample()
class TotalCpuSample
function __init__
         self.user, userNice, self.sys, self.idle = \
            map(int, file('/proc/stat').readline().split()[1:5])
        self.user += userNice

Question1: Why stats['cpuIdle'] do not use the sampling data totcpu.idle for 
calculating?

Question2: There is another data named iowait in /proc/stat, do we need to 
consider add this into usage CPU percentage for calculating?

Best Regards,
Jason Liao

_______________________________________________
Engine-devel mailing list
Engine-devel@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-devel

Reply via email to