Monitor Network Traffic per Domain

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Monitor Network Traffic per Domain

Michael Warner
Hey all,

I was wondering if theres any way I can monitor total bytes sent and
recieved by a single Domain without installing anything on the guestos
itself. I?ve been trying out a few different options but none seem to be
working out. I?m using bridged networking, each domain has a unique
public IP.

-Mike

_______________________________________________
Xen-users mailing list
[hidden email]
http://lists.xensource.com/xen-users
Reply | Threaded
Open this post in threaded view
|

RE: Monitor Network Traffic per Domain

Ian Pratt
 


> I was wondering if theres any way I can monitor total bytes
> sent and recieved by a single Domain without installing
> anything on the guestos itself. I´ve been trying out a few
> different options but none seem to be working out. I´m using
> bridged networking, each domain has a unique public IP.

You can see the totals per guest vif using either ifconfig or cat /proc/net/dev

Ian

_______________________________________________
Xen-users mailing list
[hidden email]
http://lists.xensource.com/xen-users
Reply | Threaded
Open this post in threaded view
|

Re: Monitor Network Traffic per Domain

Michael Warner

>  
>
>>I was wondering if theres any way I can monitor total bytes
>>sent and recieved by a single Domain without installing
>>anything on the guestos itself. I?ve been trying out a few
>>different options but none seem to be working out. I?m using
>>bridged networking, each domain has a unique public IP.
>>    
>>
>
>You can see the totals per guest vif using either ifconfig or cat /proc/net/dev
>
>Ian
>
This works partially, but I need a way to monitor total usage over time.
So any script that relies on statistics from each vif will get thrown
off if I ever restart a domain or start them in a different order.

-Mike

_______________________________________________
Xen-users mailing list
[hidden email]
http://lists.xensource.com/xen-users
Reply | Threaded
Open this post in threaded view
|

Re: Monitor Network Traffic per Domain

Carsten Tolkmit
Hi,

>>> I was wondering if theres any way I can monitor total bytes sent and
>>> recieved by a single Domain without installing anything on the
>>> guestos itself. I´ve been trying out a few different options but none
>>> seem to be working out. I´m using bridged networking, each domain has
>>> a unique public IP.
>>>  
>>
>>
>> You can see the totals per guest vif using either ifconfig or cat
>> /proc/net/dev
>>
>> Ian
>>
> This works partially, but I need a way to monitor total usage over time.
> So any script that relies on statistics from each vif will get thrown
> off if I ever restart a domain or start them in a different order.

yes - I had the same problem. So I came up with the following solution:

I installed the ifrename tool (ifrename package in debian) and I changed
the /etc/xen/scripts/vif-brige script in a way that it renames the vif
before adding it to the bridge with a name based on the last byte of the
mac address assigned to the virtual interface. My changes look like this
(unified diff):

----
v-server:/etc/xen/scripts# diff -U 3 vif-bridge,vanilla vif-bridge
--- vif-bridge,vanilla  2005-05-10 12:53:40.000000000 +0200
+++ vif-bridge  2005-05-10 13:06:03.000000000 +0200
@@ -34,7 +34,7 @@
  # Exit if anything goes wrong
  set -e

-echo "vif-bridge $*"
+echo "vif-bridge $*" | /usr/bin/tee -a /var/log/vif-bridge.log

  # Operation name.
  OP=$1
@@ -74,18 +74,25 @@
      exit
  fi

+export nvif=vif-mac-`echo ${mac} | /usr/bin/awk -F ':' '{ print $6 }'`
+
+if [ "$OP" == "up" ]; then
+    echo "request interface name ${nvif} instead of ${vif}"  |
/usr/bin/tee -a /var/log/vif-bridge.log
+    /sbin/ifrename -i ${vif} -n ${nvif}
+fi
+
  # Add/remove vif to/from bridge.
-brctl ${brcmd} ${bridge} ${vif}
-ifconfig ${vif} $OP
+brctl ${brcmd} ${bridge} ${nvif}
+ifconfig ${nvif} $OP

  if [ ${ip} ] ; then

      # If we've been given a list of IP networks, allow pkts with these
src addrs.
      for addr in ${ip} ; do
-        iptables ${iptcmd} FORWARD -m physdev --physdev-in ${vif} -s
${addr} -j ACCEPT
+        iptables ${iptcmd} FORWARD -m physdev --physdev-in ${nvif} -s
${addr} -j ACCEPT
      done

      # Always allow us to talk to a DHCP server anyhow.
-    iptables ${iptcmd} FORWARD -m physdev --physdev-in ${vif} -p udp
--sport 68 --dport 67 -j ACCEPT
+    iptables ${iptcmd} FORWARD -m physdev --physdev-in ${nvif} -p udp
--sport 68 --dport 67 -j ACCEPT
  fi
----

All you have to do is to assign mac addresses in the domains that differ
by last byte, and voila, you will get the same interface name every time
the domain is started.

But take care if you use tools that will try to compansate for counter
overflows, because if you stop and start a domain, the counters will get
reset.

I then use a snmpd running in Domain-0, so that my traffic collector can
collect traffic data the same way it does from our routers.

Best regards,
Carsten



_______________________________________________
Xen-users mailing list
[hidden email]
http://lists.xensource.com/xen-users
Reply | Threaded
Open this post in threaded view
|

Re: Monitor Network Traffic per Domain

Michael Warner
Thanks, that will work perfectly!

-Mike

Carsten Tolkmit wrote:

> Hi,
>
>>>> I was wondering if theres any way I can monitor total bytes sent
>>>> and recieved by a single Domain without installing anything on the
>>>> guestos itself. I?ve been trying out a few different options but
>>>> none seem to be working out. I?m using bridged networking, each
>>>> domain has a unique public IP.
>>>>  
>>>
>>>
>>>
>>> You can see the totals per guest vif using either ifconfig or cat
>>> /proc/net/dev
>>>
>>> Ian
>>>
>> This works partially, but I need a way to monitor total usage over
>> time. So any script that relies on statistics from each vif will get
>> thrown off if I ever restart a domain or start them in a different
>> order.
>
>
> yes - I had the same problem. So I came up with the following solution:
>
> I installed the ifrename tool (ifrename package in debian) and I
> changed the /etc/xen/scripts/vif-brige script in a way that it renames
> the vif before adding it to the bridge with a name based on the last
> byte of the mac address assigned to the virtual interface. My changes
> look like this (unified diff):
>
> ----
> v-server:/etc/xen/scripts# diff -U 3 vif-bridge,vanilla vif-bridge
> --- vif-bridge,vanilla  2005-05-10 12:53:40.000000000 +0200
> +++ vif-bridge  2005-05-10 13:06:03.000000000 +0200
> @@ -34,7 +34,7 @@
>  # Exit if anything goes wrong
>  set -e
>
> -echo "vif-bridge $*"
> +echo "vif-bridge $*" | /usr/bin/tee -a /var/log/vif-bridge.log
>
>  # Operation name.
>  OP=$1
> @@ -74,18 +74,25 @@
>      exit
>  fi
>
> +export nvif=vif-mac-`echo ${mac} | /usr/bin/awk -F ':' '{ print $6 }'`
> +
> +if [ "$OP" == "up" ]; then
> +    echo "request interface name ${nvif} instead of ${vif}"  |
> /usr/bin/tee -a /var/log/vif-bridge.log
> +    /sbin/ifrename -i ${vif} -n ${nvif}
> +fi
> +
>  # Add/remove vif to/from bridge.
> -brctl ${brcmd} ${bridge} ${vif}
> -ifconfig ${vif} $OP
> +brctl ${brcmd} ${bridge} ${nvif}
> +ifconfig ${nvif} $OP
>
>  if [ ${ip} ] ; then
>
>      # If we've been given a list of IP networks, allow pkts with
> these src addrs.
>      for addr in ${ip} ; do
> -        iptables ${iptcmd} FORWARD -m physdev --physdev-in ${vif} -s
> ${addr} -j ACCEPT
> +        iptables ${iptcmd} FORWARD -m physdev --physdev-in ${nvif} -s
> ${addr} -j ACCEPT
>      done
>
>      # Always allow us to talk to a DHCP server anyhow.
> -    iptables ${iptcmd} FORWARD -m physdev --physdev-in ${vif} -p udp
> --sport 68 --dport 67 -j ACCEPT
> +    iptables ${iptcmd} FORWARD -m physdev --physdev-in ${nvif} -p udp
> --sport 68 --dport 67 -j ACCEPT
>  fi
> ----
>
> All you have to do is to assign mac addresses in the domains that
> differ by last byte, and voila, you will get the same interface name
> every time the domain is started.
>
> But take care if you use tools that will try to compansate for counter
> overflows, because if you stop and start a domain, the counters will
> get reset.
>
> I then use a snmpd running in Domain-0, so that my traffic collector
> can collect traffic data the same way it does from our routers.
>
> Best regards,
> Carsten
>
>


_______________________________________________
Xen-users mailing list
[hidden email]
http://lists.xensource.com/xen-users
Reply | Threaded
Open this post in threaded view
|

RE: Monitor Network Traffic per Domain

Ian Pratt
In reply to this post by Michael Warner

> > This works partially, but I need a way to monitor total
> usage over time.
> > So any script that relies on statistics from each vif will
> get thrown
> > off if I ever restart a domain or start them in a different order.
>
> yes - I had the same problem. So I came up with the following
> solution:
>
> I installed the ifrename tool (ifrename package in debian)
> and I changed the /etc/xen/scripts/vif-brige script in a way
> that it renames the vif before adding it to the bridge with a
> name based on the last byte of the mac address assigned to
> the virtual interface. My changes look like this (unified diff):

As I recall, you can just set the name of the vif by setting the
"vifname=" parameter as part of the vif line in the config file.

Neither approach will meet your requirement of having the stats survive
a reboot of the domain.

Best,
Ian

 

_______________________________________________
Xen-users mailing list
[hidden email]
http://lists.xensource.com/xen-users
Reply | Threaded
Open this post in threaded view
|

Re: Monitor Network Traffic per Domain

Fernando Maior
On 5/22/05, Ian Pratt <[hidden email]> wrote:

>
> > > This works partially, but I need a way to monitor total
> > usage over time.
> > > So any script that relies on statistics from each vif will
> > get thrown
> > > off if I ever restart a domain or start them in a different order.
> >
> > yes - I had the same problem. So I came up with the following
> > solution:
> >
> > I installed the ifrename tool (ifrename package in debian)
> > and I changed the /etc/xen/scripts/vif-brige script in a way
> > that it renames the vif before adding it to the bridge with a
> > name based on the last byte of the mac address assigned to
> > the virtual interface. My changes look like this (unified diff):
>
> As I recall, you can just set the name of the vif by setting the
> "vifname=" parameter as part of the vif line in the config file.
>
> Neither approach will meet your requirement of having the stats survive
> a reboot of the domain.
>
> Best,
> Ian

Hello Ian,

I did not find any references about vifname in the documentation.
Also, when I changed my dom1 config file, and try creating it,
I receive:
Error: Invalid vif specifier:
mac=aa:00:00:00:01:00,bridge=xen-br0,vifname=vif1.0

The line in the config file is:
vif = [ 'mac=aa:00:00:00:01:00,bridge=xen-br0,vifname=vif1.0']

And I am using Xen 2.0.5 from source. How to use vifname?

Tks.
--
Bye,
Fernando Maior
LPIC/1 31908

_______________________________________________
Xen-users mailing list
[hidden email]
http://lists.xensource.com/xen-users
Reply | Threaded
Open this post in threaded view
|

RE: Monitor Network Traffic per Domain

Ian Pratt
In reply to this post by Michael Warner
 > I did not find any references about vifname in the documentation.
> Also, when I changed my dom1 config file, and try creating
> it, I receive:
> Error: Invalid vif specifier:
> mac=aa:00:00:00:01:00,bridge=xen-br0,vifname=vif1.0
>
> The line in the config file is:
> vif = [ 'mac=aa:00:00:00:01:00,bridge=xen-br0,vifname=vif1.0']
>
> And I am using Xen 2.0.5 from source. How to use vifname?

I can't remember when this was added. Try upgrading to 2.0.6.

Best,
Ian

_______________________________________________
Xen-users mailing list
[hidden email]
http://lists.xensource.com/xen-users
Reply | Threaded
Open this post in threaded view
|

Re: Monitor Network Traffic per Domain

Fernando Maior
On 5/23/05, Fernando Maior <[hidden email]> wrote:

> On 5/23/05, Ian Pratt <[hidden email]> wrote:
> >  > I did not find any references about vifname in the documentation.
> > > Also, when I changed my dom1 config file, and try creating
> > > it, I receive:
> > > Error: Invalid vif specifier:
> > > mac=aa:00:00:00:01:00,bridge=xen-br0,vifname=vif1.0
> > >
> > > The line in the config file is:
> > > vif = [ 'mac=aa:00:00:00:01:00,bridge=xen-br0,vifname=vif1.0']
> > >
> > > And I am using Xen 2.0.5 from source. How to use vifname?
> >
> > I can't remember when this was added. Try upgrading to 2.0.6.
> >
> > Best,
> > Ian
> >
>
> On my way! (tm James Tiberius Kirk) :)
>
> --
> Bye,
> Fernando Maior
> LPIC/1 31908
>

Ian,

I downloaded src.tgz, untar-gzipped, downloaded linux 2.6.11
bz2 file and put it into the xen-2.0 directory. Then, I issued
"make xen", "make tools" and "make kernels" (I do not want
docs).

Now, I am receiving lots of messages like:

patching file MAINTAINERS
Reversed (or previously applied) patch detected!  Assume -R? [n]
make[2]: *** [ref-linux-2.6.11/.valid-ref] Interrupt

That is coming for a lot of files, should I use <enter> and accept
the default answer or what?

Tks.
--
Bye,
Fernando Maior
LPIC/1 31908

_______________________________________________
Xen-users mailing list
[hidden email]
http://lists.xensource.com/xen-users