On 11/28/2018 10:38 AM, Massimo Sgaravatto wrote:
Hi
I was wondering if nova allows to get the CPUtime and wallclocktime consumed by a project in a certain time period, without using ceilometer
Among the data returned by the command "openstack usage show" there is also a "CPU Hours" but, if I am not wrong, this is actually the WallClockTime. Did I get it right ?
It's neither. It's the calculated time that the VM has been "up" multiplied by the number of vCPUs the VM consumes. It's basically worthless as anything more than a simplistic indicator of rough resource consumption. You can see how the calculation is done by following the fairly convoluted code in the os-simple-tenant-usage API: This calculates the "hours used": https://github.com/openstack/nova/blob/62245235bc15da6abcdfd3df1c24bd856d69f... And here is where that is multiplied by the VM's vCPUs: https://github.com/openstack/nova/blob/62245235bc15da6abcdfd3df1c24bd856d69f...
If so, it is also possible to get the CPUTime ?
If you are referring to getting the amount of time a *physical host CPU* has spent performing tasks for a particular VM, the closest you can get to this would be the "server diagnostics" API: https://github.com/openstack/nova/blob/master/nova/api/openstack/compute/vie... That said, the server diagnostics API is a very thin shim over a virt-driver-specific interface: https://github.com/openstack/nova/blob/62245235bc15da6abcdfd3df1c24bd856d69f... The libvirt driver's get_server_diagnostics() (host-specific) and get_instance_diagnostics() (VM-specific) implementation is here: https://github.com/openstack/nova/blob/62245235bc15da6abcdfd3df1c24bd856d69f... You might want to look at that code and implement a simple collectd/statsd/fluentd/telegraf collector to grab those stats directly from the libvirt daemon on the compute nodes themselves. Best, -jay