BYEONG-GI KIM
2016-Jan-04 13:33 UTC
Re: [libvirt-users] API for retrieving resource metrics from VMs?
Thank you for the reply! I used the term "disk usage" as what you mentioned first; the information which can be retrieved via 'df' command on linux system... I'll then have to consider different approach to do what I want. Anyway, thanks again for your great help. Best regards bgkim 2016-01-04 22:21 GMT+09:00 Michal Privoznik <mprivozn@redhat.com>:> 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 >
Vasiliy Tolstov
2016-Jan-04 16:59 UTC
Re: [libvirt-users] API for retrieving resource metrics from VMs?
2016-01-04 16:33 GMT+03:00 BYEONG-GI KIM <kimbyeonggi@gmail.com>:> hank you for the reply! > > I used the term "disk usage" as what you mentioned first; the information > which can be retrieved via 'df' command on linux system... > > I'll then have to consider different approach to do what I want. > > Anyway, thanks again for your great help. > > Best regardsYou can install under guest vm qemu-guest-agent and get info from it. -- Vasiliy Tolstov, e-mail: v.tolstov@selfip.ru
BYEONG-GI KIM
2016-Jan-05 00:21 UTC
Re: [libvirt-users] API for retrieving resource metrics from VMs?
Thank you for your reply. Actually, the reason I expect that function from libvirt API was I don't want to install agent-like software on VM, which means I was trying to get such information without agent for cloud environment monitoring. By the way, I have another question about libvirt-java binding API. Does the API fully support libvirt C API functionally? I've been trying to get VM's current memory/cpu usages and network I/O of individual NICs, but the coding is not easy since the description how to use each libvirt-java binding API in Javadoc is barely sufficient. For example, Domain.memoryStats(int number) seems returning the memory usage or something related to that information, but I really don't know what "number" should be given for the parameter... The return values were even not one result per VM. What does the value exactly mean? Thanks in advance. Best regards bgkim 2016-01-05 1:59 GMT+09:00 Vasiliy Tolstov <v.tolstov@selfip.ru>:> 2016-01-04 16:33 GMT+03:00 BYEONG-GI KIM <kimbyeonggi@gmail.com>: > > hank you for the reply! > > > > I used the term "disk usage" as what you mentioned first; the information > > which can be retrieved via 'df' command on linux system... > > > > I'll then have to consider different approach to do what I want. > > > > Anyway, thanks again for your great help. > > > > Best regards > > You can install under guest vm qemu-guest-agent and get info from it. > > -- > Vasiliy Tolstov, > e-mail: v.tolstov@selfip.ru >
Michal Privoznik
2016-Jan-05 07:58 UTC
Re: [libvirt-users] API for retrieving resource metrics from VMs?
On 04.01.2016 17:59, Vasiliy Tolstov wrote:> 2016-01-04 16:33 GMT+03:00 BYEONG-GI KIM <kimbyeonggi@gmail.com>: >> hank you for the reply! >> >> I used the term "disk usage" as what you mentioned first; the information >> which can be retrieved via 'df' command on linux system... >> >> I'll then have to consider different approach to do what I want. >> >> Anyway, thanks again for your great help. >> >> Best regards > > You can install under guest vm qemu-guest-agent and get info from it. >I am afraid qemu-guest-agent won't be much help here. I mean it has no API for disk usage statistics nor API for executing arbitrary commands. Michal
Laine Stump
2016-Jan-05 20:44 UTC
Re: [libvirt-users] API for retrieving resource metrics from VMs?
On 01/04/2016 11:59 AM, Vasiliy Tolstov wrote:> 2016-01-04 16:33 GMT+03:00 BYEONG-GI KIM <kimbyeonggi@gmail.com>: >> hank you for the reply! >> >> I used the term "disk usage" as what you mentioned first; the information >> which can be retrieved via 'df' command on linux system... >> >> I'll then have to consider different approach to do what I want. >> >> Anyway, thanks again for your great help. >> >> Best regards > You can install under guest vm qemu-guest-agent and get info from it. >Another alternative would be to use the libguestfs tools to examine the disk in read-only mode (be sure not to use read/write mode on an image that's currently in use by its guest!). This would *not* be efficient to do very frequently, but would be okay if done occasionally.