[openstack-dev] [ceilometer] the cpu util

Jaze Lee jazeltq at gmail.com
Wed Dec 20 08:14:33 UTC 2017

   We use ceilometer newton, and also master calculates cpu same as newton.
   It is in https://github.com/openstack/ceilometer/blob/master/ceilometer/compute/virt/libvirt/inspector.py#L183

   I test with a two vcpu vm, and find using this method as line 183
we can not get cpu util 100, always 50 or 52.

The test script is here(run on compute node, and there is only one vm)

cpu_time_begin=`virsh  domstats --cpu-total | grep cpu.time| awk -F
'=' '{print $2}'`
sleep 1
cpu_time_end=`virsh  domstats --cpu-total | grep cpu.time| awk -F '='
'{print $2}'`

cpu_util=$(((cpu_time_end - cpu_time_begin) * 100 / 10**9))
echo "cpu util is ", $cpu_util

The output will be 100 or 101, if we divide cpu_util with core number,
then we definitely get 50. But in the vm we watch with top and find
all core is 99%.

Can someone tell me why we only use cpu_time here? May be we should
add cpu.user and cpu.system? It is insane only get 50% when the vm is
totally 100%....

Thanks a lot guys...


More information about the OpenStack-dev mailing list