[one-users] Patch to monitor network traffic for KVM guests

Rangababu Chakravarthula rbabu at hexagrid.com
Wed May 11 15:11:01 PDT 2011


Hi Javier,

I am trying to apply this patch to opennebula 1.4 but even after I change
one_vmm_kvm.rb and onevm, i am not able to get the network statistics. It
also stopped reporting memory now.

I know this has been added as part of 2.0 but I see there are more changes
(Gangila integration)  etc. I just want to add this one particular feature
to 1.4.

Any help is appreciated

Ranga

On Mon, May 17, 2010 at 9:57 AM, Javier Fontan <jfontan at gmail.com> wrote:

> Hello,
>
> Thank's a lot for the patch. A new ticket is created to add it. It
> will be added to one-1.6 as we don't want to add more "features" to
> current 1.4 branch.
>
> http://dev.opennebula.org/issues/244
>
> Bye
>
> On Sun, May 16, 2010 at 10:22 PM, Rogier Mars <rogier at fortytwo.nl> wrote:
> > Hi,
> >
> > I've created a quick patch (see below) to the file one_vmm_kvm.rb to
> include
> > proper monitoring of network interface statistics for KVM.
> > This patch uses the libvirt dumpxml command and domifstat to get
> interface
> > statistics.
> >
> > I've attached the updated one_vmm_kvm.rb file, see the patch below.
> >
> > Best regards,
> >
> > Rogier
> >
> >
> > 42a43
> >> require 'rexml/document'
> > 61c62,65
> > <         :poll     => "virsh --connect #{LIBVIRT_URI} dominfo"
> > ---
> >>         :poll     => "virsh --connect #{LIBVIRT_URI} dominfo",
> >>         :netstats => "virsh --connect #{LIBVIRT_URI} domifstat",
> >>         :dumpxml  => "virsh --connect #{LIBVIRT_URI} dumpxml"
> >>
> > 146a151,162
> >>         exe2  = SSHCommand.run("#{LIBVIRT[:dumpxml]} #{deploy_id}",
> host,
> >>                               log_method(id))
> >>
> >>        doc = REXML::Document.new(exe2.stdout)
> >>        interfaces = []
> >>        doc.elements.each('domain/devices/interface/target') do |ele|
> >>           interfaces << ele.attributes["dev"]
> >>        end
> >>
> >>         exe3  = SSHCommand.run("#{LIBVIRT[:netstats]} #{deploy_id}
> >> #{interfaces}", host,
> >>                               log_method(id))
> >>
> > 182a199
> >>
> > 185a203,212
> >>         exe3.stdout.each_line {|line|
> >>             columns=line.split(" ").collect {|c| c.strip }
> >>             case columns[1]
> >>                 when 'rx_bytes'
> >>                     info << " #{POLL_ATTRIBUTE[:netrx]}="  <<
> >> (columns[2].to_i).to_s
> >>                 when 'tx_bytes'
> >>                     info << " #{POLL_ATTRIBUTE[:nettx]}="  <<
> >> (columns[2].to_i).to_s
> >>             end
> >> }
> >>
> >
> >
> >
> >
> > On May 12, 2010, at 1:23 AM, Rogier Mars wrote:
> >
> >> Hi,
> >>
> >> I just noticed this post and did some checking with libvirt. I am able
> to
> >> get the interface that is used in a KVM vm via the dumpxml command, and
> then
> >> get the network interface statistics via domifstat (see the example
> below).
> >> I think this could be included in the one_vmm_kvm.rb script. I'm not a
> ruby
> >> programmer, but I think this should be possible.
> >>
> >> Cheers,
> >>
> >> Rogier
> >>
> >>
> >> virsh # dumpxml one-60
> >> <domain type='kvm' id='11'>
> >>  <name>one-60</name>
> >>  <uuid>3e62f716-b9bc-4b3e-6af6-7121181a5487</uuid>
> >>  <memory>524288</memory>
> >>  <currentMemory>524288</currentMemory>
> >>  <vcpu>2</vcpu>
> >>  <os>
> >>   <type arch='x86_64' machine='pc'>hvm</type>
> >>   <boot dev='hd'/>
> >>  </os>
> >>  <features>
> >>   <acpi/>
> >>  </features>
> >>  <clock offset='utc'/>
> >>  <on_poweroff>destroy</on_poweroff>
> >>  <on_reboot>restart</on_reboot>
> >>  <on_crash>destroy</on_crash>
> >>  <devices>
> >>   <emulator>/usr/bin/kvm</emulator>
> >>   <disk type='file' device='disk'>
> >>     <source file='/srv/cloud/one/var/60/images/disk.0'/>
> >>     <target dev='hda' bus='ide'/>
> >>   </disk>
> >>   <interface type='bridge'>
> >>     <mac address='00:03:5d:bc:f9:64'/>
> >>     <source bridge='br1'/>
> >>     <target dev='vnet1'/>
> >>   </interface>
> >>  </devices>
> >> </domain>
> >>
> >> virsh # domifstat one-60 vnet1
> >> vnet1 rx_bytes 517120841
> >> vnet1 rx_packets 6065654
> >> vnet1 rx_errs 0
> >> vnet1 rx_drop 0
> >> vnet1 tx_bytes 189675090
> >> vnet1 tx_packets 1166682
> >> vnet1 tx_errs 0
> >> vnet1 tx_drop 0
> >>
> >> virsh #
> >>
> >>
> >> On Jan 7, 2010, at 10:52 AM, Javier Fontan wrote:
> >>
> >>> Hello,
> >>>
> >>>
> >>> Hello,
> >>>
> >>> Libvirt does not directly provide this information so it is always 0
> >>> for kvm drivers. Maybe the driver could be improved to get network
> >>> traffic by other means. Do you have any idea on how this could be
> >>> done?
> >>>
> >>> Bye
> >>>
> >>> On Wed, Dec 30, 2009 at 10:18 PM, Shi Jin <jinzishuai at gmail.com>
> wrote:
> >>>>
> >>>> Hi there,
> >>>>
> >>>> I noticed that the "onevm show -x" command returns 0 in the XML output
> >>>> <CPU>0</CPU>
> >>>> <NET_TX>0</NET_TX>
> >>>> <NET_RX>0</NET_RX>
> >>>> for all KVM virtual machine. I am not sure whether it is the same for
> >>>> Xen.
> >>>>
> >>>> Could you please comment on the possibility of monitor network traffic
> >>>> for individual VM in OpenNebula?
> >>>> I know that the "onehost show" command actually reports the traffic
> >>>> for each host but what is really interesting is to know exactly how
> >>>> much traffic used by each VM.
> >>>>
> >>>> Thank you very much and Happy New Year to All!
> >>>>
> >>>> --
> >>>> Shi Jin, Ph.D.
> >>>> _______________________________________________
> >>>> Users mailing list
> >>>> Users at lists.opennebula.org
> >>>> http://lists.opennebula.org/listinfo.cgi/users-opennebula.org
> >>>>
> >>>
> >>>
> >>>
> >>> --
> >>> Javier Fontan, Grid & Virtualization Technology Engineer/Researcher
> >>> DSA Research Group: http://dsa-research.org
> >>> Globus GridWay Metascheduler: http://www.GridWay.org
> >>> OpenNebula Virtual Infrastructure Engine: http://www.OpenNebula.org
> >>> _______________________________________________
> >>> Users mailing list
> >>> Users at lists.opennebula.org
> >>> http://lists.opennebula.org/listinfo.cgi/users-opennebula.org
> >>>
> >>
> >> _______________________________________________
> >> Users mailing list
> >> Users at lists.opennebula.org
> >> http://lists.opennebula.org/listinfo.cgi/users-opennebula.org
> >>
> >
> >
> >
>
>
>
> --
> Javier Fontan, Grid & Virtualization Technology Engineer/Researcher
> DSA Research Group: http://dsa-research.org
> Globus GridWay Metascheduler: http://www.GridWay.org
> OpenNebula Virtual Infrastructure Engine: http://www.OpenNebula.org
> _______________________________________________
> Users mailing list
> Users at lists.opennebula.org
> http://lists.opennebula.org/listinfo.cgi/users-opennebula.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opennebula.org/pipermail/users-opennebula.org/attachments/20110511/3d5fc7cb/attachment-0002.htm>


More information about the Users mailing list