#!/usr/bin/perl -w
# This script collects data from /proc/net/dev and return the numbers of bytes
# transmit and received for an interface. You need to pass one argument, the
# interface that need to be returned.
   
my $eth=defined($ARGV[0])?$ARGV[0]:"eth0";
open INPUT, "/proc/net/dev" || die "couldn't open /proc/net/dev";
while (<INPUT>)
{
    if (m/^ *$eth: *(.*)$/g)
    {
	my @values = split(/ +/,$1);
	print $values[0]." ".$values[8];
	last;
    }
}
close INPUT;

