[openstack-dev] [ceilometer] the cpu util

gordon chung gord at live.ca
Wed Dec 20 14:29:27 UTC 2017



On 2017-12-20 03:14 AM, Jaze Lee wrote:
> Hello,
>     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)
> #!/bin/bash
> 
> 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%....
> 

does adding cpu.user and cpu.system make sense or are you just adding 
random numbers in hopes it gets you to right number? :P

i'm not a libvirt/qemu dev but it seems cpu.system is already part of 
cpu.time[1]

if you look further into the code, you should see that the agent tries 
to first use vcpu.*.time to build more accurate cpu.time value. if you 
look at patch[3], it should give you more information as to why and what 
requirements you need.


[1] 
https://stackoverflow.com/questions/40468370/what-does-cpu-time-represent-exactly-in-libvirt
[2] 
https://github.com/openstack/ceilometer/blob/master/ceilometer/compute/virt/libvirt/inspector.py#L175-L176
[3] 
https://github.com/openstack/ceilometer/commit/a4ec0911a3ed4137a1c832fbd7c8fee80c7d4601

cheers,

-- 
gord


More information about the OpenStack-dev mailing list