[Engine-devel] Consider iowait add into usage CPU percentage
Liao, Chuan (Jason Liao, HPservers-Core-OE-PSC)
chuan.liao at hp.com
Tue Mar 11 06:02:23 UTC 2014
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ovirt.org/pipermail/engine-devel/attachments/20140311/f72adce9/attachment.html>
More information about the Engine-devel
mailing list