summaryrefslogtreecommitdiff
path: root/net/mrtg/files/netstat2mrtg
blob: 9fdabae68a7c933e2f7812da7c1e9fdcdc78e60c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#! @PREFIX@/bin/perl

$if = $ARGV[0];
open(NET, "netstat -I $if -b|");
while ($line = <NET>)
{
	chop $line;
	if ($line =~ m|^.+<Link>[\s\t]+\S+[\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";