[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Xen-users] How to tell which tapX interface belongs to which domain...


  • To: "Christian Horn" <chorn@xxxxxxxxxxxx>
  • From: "James Harper" <james.harper@xxxxxxxxxxxxxxxx>
  • Date: Tue, 9 Oct 2007 15:35:47 +1000
  • Cc: xen-users@xxxxxxxxxxxxxxxxxxx
  • Delivery-date: Mon, 08 Oct 2007 22:37:35 -0700
  • List-id: Xen user discussion <xen-users.lists.xensource.com>
  • Thread-index: AcgKNZ9AH8GcPlaGREmZGqnA0zVthwAABnug
  • Thread-topic: [Xen-users] How to tell which tapX interface belongs to which domain...

> On Tue, Oct 09, 2007 at 12:00:29PM +1000, James Harper wrote:
> >
> > I noticed that when I do a 'brctl show', the tap interface is on the
> > line before the vif interface, so I made use of that. Hopefully it's
> > always true!
> 
> Also seen that, but how do you conclude from that to which domU the
> tap-device belongs?
> 

You can get that from xenstore.

My scripts are (excuse the line feeds):

1. Generic interface script (parameter is interface name):

"
#!/bin/sh

cat /proc/net/dev | egrep "^[ ]*$1:" | sed 's/[ ]*[^:][^:]*://' | while
read rxbytes rxpackets rxerrs rxdrop rxfifo rxframe rxcompressed
rxmulticast txbytes txpackets txerrs txdrop txfifo txcolls txcarrier
txcompressed
do
  echo $rxbytes
  echo $txbytes
  uptime | cut -c14- | sed 's/,  .*//'
  hostname
done
"

2. DomU interface script (parameters are domain name and interface
index)

"
#!/bin/sh

domname=$1
vifindex=$2

/usr/sbin/xenstore-list /local/domain | while read domid
do
  name=`/usr/sbin/xenstore-read /local/domain/$domid/name`

  if [ "$name" = "$domname" ]
  then
    type=`/usr/sbin/xenstore-read
/local/domain/0/backend/vif/$domid/$vifindex/type 2>/dev/null`
    if [ "$type" = "ioemu" ]
    then
      if=`/usr/sbin/brctl show | sed 's/.*[      ]//' | egrep -B 1
"^vif$domid.$vifindex" | head -1`
    else
      if=vif$domid.$vifindex
    fi
    /usr/local/bin/if_traffic $if
    exit
  fi
done
"

The only problem I can see with the second script, is that I don't think
you can rely on the 'ioemu' text being present in that key, on another
machine it is blank. It probably comes from the config script...

James

_______________________________________________
Xen-users mailing list
Xen-users@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-users


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.