[openstack-dev] [ceilometer] the cpu util

Jaze Lee jazeltq at gmail.com
Wed Dec 20 15:06:09 UTC 2017


2017-12-20 22:29 GMT+08:00 gordon chung <gord at live.ca>:
>
>
> 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
The latter one. :)


>
> 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.

Yes, i notice it. But when there will be vcpu.*.time? Which libvirt version?
We use libvirt 3.2.0 and it does not have vcpu.*.time, so it will go
to fall back.

The fall back is so coarse, do you think we should have it?


>
>
> [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
> __________________________________________________________________________
> OpenStack Development Mailing List (not for usage questions)
> Unsubscribe: OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev



-- 
谦谦君子



More information about the OpenStack-dev mailing list