[libvirt-users] API for retrieving resource metrics from VMs?

Michal Privoznik mprivozn at redhat.com
Mon Jan 4 13:21:55 UTC 2016


On 04.01.2016 01:19, BYEONG-GI KIM wrote:
> Hello. I'm a new getting started to learn the libvirt API.
> 
> I've tried to find APIs which retrieve resource metrics such as cpu, disk,
> memory, and network I/O usages, but I could find few related thing; I was
> intended to use libvirt-Java binding first, it seems I'd be better to use
> the others like Python binding or C API though. The Java binding API is
> likely to provide very limited API list comparing with the above APIs so
> far.
> 
> So, I'd like to know which APIs can retrieve that resources from VMs. I
> don't care about the language, but I really want to know whether such APIs
> even exists or not.
> 
> As far as I know, cpu, memory, and network I/O seems being provided, but
> I'm not sure disk usage per VMs can be obtained via libvirt API.

I'm not sure what do you mean by 'disk usage'. You mean like 'how many
bytes are used/free on a disk'? If so, I'm not sure libvirt can help. I
mean it's dependent on guest configuration and you should use 'df' ran
from within guest to retrieve that info. It falls out of libvirt's scope.

If you, however, mean disk I/O - this can be obtained via
virDomainBlockStatsFlags() API.

Michal




More information about the libvirt-users mailing list