#!/usr/bin/perl
# reads stats and uptime from OpenBSD netstat for mrtg
# based on a script from ron@rosie.18james.com,  2 Jan 2000
# philip at shuman dot org 2005-08-24

my $interface = "(de0) Internal Network";
my($in_pkts,$out_pkts) = (0,0);

open(FW, "netstat -ibn | grep de0 | grep \"<Link>\"|") || die "cannot open netstat\n";
while (<FW>) {
  $out_pkts = $1 if (/.+\s+(\d+)$/);
  $in_pkts = $1 if (/\s+(\d+)\s+\d+/);
}
print "$in_pkts\n",
      "$out_pkts\n";
my $uptime = `/usr/bin/uptime`;
$uptime =~ /^(..:....)  up ([^,]*), ([^,]*)/;
print "$2 $3 hours\n$interface\n";
