#! @PREFIX@/bin/perl
#	$NetBSD: netstat2mrtg,v 1.3 2001/06/21 16:44:35 bouyer Exp $

$if = $ARGV[0];
open(NET, "netstat -I $if -bn|");
while ($line = <NET>)
{
	chop $line;
	if ($line =~ m|^.+<Link>[\s\t]+\S+[\s\t]+(\w+)[\s\t]+(\w+)$|)
	{
		print "$1\n";
		print "$2\n";
	}
	elsif ($line =~ m|^.+<Link>[\s\t]+(\w+)[\s\t]+(\w+)$|)
	{
		print "$1\n";
		print "$2\n";
	}
}
close(NET);

open(UP, "uptime|");
while($line = <UP>)
{
	chop $line;
	if ($line =~ m|^.*up\s+(.+),\s+\d+\suser.*|)
	{
		print "$1\n";
	}
}
close(UP);
print "$if\n";