[ops] [nova] How to get CPUtime and wallclokctime consumed by a project (without using ceilometer) ?

Jay Pipes jaypipes at gmail.com
Wed Nov 28 17:14:42 UTC 2018

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":


And here is where that is multiplied by the VM's vCPUs:


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


That said, the server diagnostics API is a very thin shim over a 
virt-driver-specific interface:


The libvirt driver's get_server_diagnostics() (host-specific) and 
get_instance_diagnostics() (VM-specific) implementation is here:


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.


More information about the openstack-discuss mailing list