<div dir="ltr">Thanks a lot for the useful information !<div><br></div><div>Cheers, Massimo</div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Nov 28, 2018 at 10:20 PM Sean Mooney <<a href="mailto:smooney@redhat.com">smooney@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Wed, 2018-11-28 at 12:14 -0500, Jay Pipes wrote:<br>
> On 11/28/2018 10:38 AM, Massimo Sgaravatto wrote:<br>
> > Hi<br>
> > <br>
> > I was wondering if nova allows to get the CPUtime and wallclocktime <br>
> > consumed by a project in a certain time period, without using ceilometer<br>
> > <br>
> > Among the data returned by the command "openstack usage show" there is <br>
> > also a "CPU Hours" but, if I am not wrong, this is actually the <br>
> > WallClockTime. Did I get it right ?<br>
> <br>
> It's neither. It's the calculated time that the VM has been "up" <br>
> multiplied by the number of vCPUs the VM consumes.<br>
> <br>
> It's basically worthless as anything more than a simplistic indicator of <br>
> rough resource consumption.<br>
> <br>
> You can see how the calculation is done by following the fairly <br>
> convoluted code in the os-simple-tenant-usage API:<br>
> <br>
> This calculates the "hours used":<br>
> <br>
> <a href="https://github.com/openstack/nova/blob/62245235bc15da6abcdfd3df1c24bd856d69fbb4/nova/api/openstack/compute/simple_tena" rel="noreferrer" target="_blank">https://github.com/openstack/nova/blob/62245235bc15da6abcdfd3df1c24bd856d69fbb4/nova/api/openstack/compute/simple_tena</a><br>
> nt_usage.py#L51-L82<br>
> <br>
> And here is where that is multiplied by the VM's vCPUs:<br>
> <br>
> <a href="https://github.com/openstack/nova/blob/62245235bc15da6abcdfd3df1c24bd856d69fbb4/nova/api/openstack/compute/simple_tena" rel="noreferrer" target="_blank">https://github.com/openstack/nova/blob/62245235bc15da6abcdfd3df1c24bd856d69fbb4/nova/api/openstack/compute/simple_tena</a><br>
> nt_usage.py#L213<br>
> <br>
> > If so, it is also possible to get the CPUTime ?<br>
> <br>
> If you are referring to getting the amount of time a *physical host CPU* <br>
> has spent performing tasks for a particular VM, the closest you can get <br>
> to this would be the "server diagnostics" API:<br>
> <br>
> <a href="https://github.com/openstack/nova/blob/master/nova/api/openstack/compute/views/server_diagnostics.py" rel="noreferrer" target="_blank">https://github.com/openstack/nova/blob/master/nova/api/openstack/compute/views/server_diagnostics.py</a><br>
> <br>
> That said, the server diagnostics API is a very thin shim over a <br>
> virt-driver-specific interface:<br>
> <br>
> <a href="https://github.com/openstack/nova/blob/62245235bc15da6abcdfd3df1c24bd856d69fbb4/nova/compute/manager.py#L4698" rel="noreferrer" target="_blank">https://github.com/openstack/nova/blob/62245235bc15da6abcdfd3df1c24bd856d69fbb4/nova/compute/manager.py#L4698</a><br>
> <br>
> The libvirt driver's get_server_diagnostics() (host-specific) and <br>
> get_instance_diagnostics() (VM-specific) implementation is here:<br>
> <br>
> <a href="https://github.com/openstack/nova/blob/62245235bc15da6abcdfd3df1c24bd856d69fbb4/nova/virt/libvirt/driver.py#L8543-L867" rel="noreferrer" target="_blank">https://github.com/openstack/nova/blob/62245235bc15da6abcdfd3df1c24bd856d69fbb4/nova/virt/libvirt/driver.py#L8543-L867</a><br>
> 8<br>
> <br>
> You might want to look at that code and implement a simple <br>
> collectd/statsd/fluentd/telegraf collector to grab those stats directly <br>
if you go the collectd route the libvirt plugin was modifed about 2 years ago to be able to use the domain uuid<br>
instaed the domain instance name when reporting stats and since we set the domain uuid to the nova uuid it makes it<br>
really easy to map back to the instance later. so ihink the colloectd libvirt plugin may be able to give you this info<br>
already and you can then just export that ot influxdb or gnnoci use later. the other monitoring solution can proably do<br>
the same but nova does not really track vm cpu usage that closely.<br>
> from the libvirt daemon on the compute nodes themselves.<br>
> <br>
> Best,<br>
> -jay<br>
> <br>
<br>
</blockquote></div>