3

We are running virtual machines in kvm and i am trying to collect metrics and send it to influxdb + grafana for graphing.

I can see CPU stats using virsh but its in time in second spend, how do i convert this value in proper usage in % or human readable metrics?

[root@kvm01 ~]# virsh cpu-stats --total instance-0000047a
Total:
    cpu_time     160808730.755660547 seconds
    user_time       148000.880000000 seconds
    system_time   85012531.050000000 seconds
1
2

Calculating a CPU percentage is dependent on the time window you are looking at. So if you call virsh cpu-stats once, then call it again 10 seconds later, you would do need to do something like:

(cpu_time2 - cpu_time1) / (10 * vcpus)

That will tell you what percentage of the total time window the VM CPUs were running in.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.