On 02/27/2013 08:25 PM, 张章 wrote:
Hi,all
I want to get a relatively accurate cpu usage of a domain. I have a few questions about
virDomainGetInfo: struct virDomainInfo{ unsigned char state : //the running state, one
of virDomainState unsigned long maxMem :// the maximum memory in KBytes allowed
unsigned long memory :// the memory in KBytes used by the domain unsigned short
nrVirtCpu :// the number of virtual CPUs for the domain unsigned long long cpuTime :
//the CPU time used in nanoseconds }
If a domain is assigned to 4 vcpus and my machine has 6 physical cores, then the cpuTime
in virDomainInfo should be the sum of cpu time of the 4 vcpus. When I want to calculate
the cpu usage, which of the following is more accurate? 1/4 * cpu time / total time
or 4/6 * cpu time / total time or just cpu time / total time
[Can you please convince your mailer to wrap long lines, and use proper
line breaks when quoting code, so that your mail is legible?]
At this point, I'd suggest the best way of knowing what times are
returned is checking the source code; but patches to make the
documentation more obvious for the next person would be appreciated.
If you want more statistics, which might provide you with more accuracy,
you might also be interested in looking at the virDomainGetCPUStats.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library
http://libvirt.org