3a4 > # 2005-02-20, dwcarder: misc hacks to prettify output 64c65 < my ($session, $error) = Net::SNMP->session(-hostname=>$router, --- > my ($session, $error) = Net::SNMP->session( -hostname=>$router, 215,217c216,226 < print "# Processing interface IGMP joins...\n"; < while((my $key) = each(%mcast)) { < # ignore undef interfaces or interfaces with 0 joins --- > > print " Int joins leaves groups routes inoctets outoctets\n"; > foreach my $key (sort {numonly($mcast{$a}{'ifName'}) <=> numonly($mcast{$b}{'ifName'})} keys %mcast) { > > my $joins = 0; > my $leaves = 0; > my $groups = 0; > my $routes = 0; > my $inoctets = 0; > my $outoctets = 0; > 219c228 < print " $mcast{$key}{'ifName'}: $mcast{$key}{'igmpInterfaceJoins'}\n"; --- > $joins = $mcast{$key}{'igmpInterfaceJoins'}; 221d229 < } 223,225d230 < print "# Processing interface IGMP leaves...\n"; < while((my $key) = each(%mcast)) { < # ignore undef interfaces or interfaces with 0 leaves 227c232 < print " $mcast{$key}{'ifName'}: $mcast{$key}{'igmpInterfaceLeaves'}\n"; --- > $leaves = $mcast{$key}{'igmpInterfaceLeaves'}; 229d233 < } 231,233d234 < print "# Processing interfaces with IGMP membership...\n"; < while((my $key) = each(%mcast)) { < # ignore undef interfaces or interfaces with 0 groups 235c236 < print " $mcast{$key}{'ifName'}: $mcast{$key}{'igmpInterfaceGroups'}\n"; --- > $groups = $mcast{$key}{'igmpInterfaceGroups'}; 237d237 < } 239,241d238 < print "# Processing interface mroute totals...\n"; < while((my $key) = each(%mcast)) { < # ignore undef interfaces or interfaces with 0 groups 243c240 < print " $mcast{$key}{'ifName'}: $mcast{$key}{'ipMRouteInIfIndex'}\n"; --- > $routes = $mcast{$key}{'ipMRouteInIfIndex'}; 245d241 < } 247,249d242 < print "# Process ipMRouteInterfaceInMcastOctets...\n"; < while((my $key) = each(%mcast)) { < # ignore undef interfaces or interfaces with 0 groups 251c244 < print " $mcast{$key}{'ifName'}: $mcast{$key}{'ipMRouteInterfaceInMcastOctets'}\n"; --- > $inoctets = $mcast{$key}{'ipMRouteInterfaceInMcastOctets'}; 253d245 < } 255,257d246 < print "# Process ipMRouteInterfaceOutMcastOctets...\n"; < while((my $key) = each(%mcast)) { < # ignore undef interfaces or interfaces with 0 groups 259c248,252 < print " $mcast{$key}{'ifName'}: $mcast{$key}{'ipMRouteInterfaceOutMcastOctets'}\n"; --- > $outoctets = $mcast{$key}{'ipMRouteInterfaceOutMcastOctets'}; > } > > if ($joins||$leaves||$groups||$routes||$inoctets||$outoctets) { > printf("%7s %8d %8d %8d %8d %12u %12u \n", $mcast{$key}{'ifName'},$joins,$leaves,$groups,$routes,$inoctets,$outoctets); 260a254 > 305a300,308 > > > sub numonly { > my $val = shift; > $val =~ m/(\d+)/; > my $ret = $1; > if (!defined($ret)) { $ret = '0'; } > return ($ret); > }