[mrtg] Packets Per Second Monitoring

Matthew Petach mpetach at yahoo.com
Sun Jan 24 07:04:03 CET 2010




>
>From: Matt Baer <matt at baerconsult.com>
>To: mrtg <mrtg at lists.oetiker.ch>
>Sent: Fri, January 22, 2010 11:42:54 PM
>Subject: [mrtg] Packets Per Second Monitoring
>
>
>Is there known way of monitoring packets per second or perhaps a template?
>
>

Here's a script that I use for generating per-interface packet targets on our
systems here; it's pretty ugly, and I'm sure others have more graceful
ways of doing it, but it should give you an idea of how you can generate
your own configs with packet counters, discards, etc...

Matt


mpetach at netops2:~/mrtg> cat cfgmaker-new.pl
#!/usr/local/bin/perl -wT
BEGIN { 
   push @INC, "/home/mrtg/lib"; 
   push @INC, "/home/mrtg/lib/mrtg2"; 
   $ENV{'PATH'} = "/bin";
}
use strict;
require "SNMP_util.pm";
use Getopt::Long qw(GetOptions);
use BER;
use MyLib;

my (%config, @index, %ifname, %ifalias, %ifspeed);

######################################################################
$| = 1;
my ($self) = $0 =~ m%([-\.\w+]+$)%;
my ($version) = q$Id: cfgmaker-new.pl,v 1.65 2010/01/24 05:56:39 mpetach Exp $;
my ($minfsize) = 1000;
my ($ftype)    = "ascii";

########## Deal with options and arguments.
my (@options) = ('help|h', 'debug|d:i', 'out|o:s', '2');
Getopt::Long::config ('bundling', 'no_ignore_case', 'no_getopt_compat');
GetOptions (\%config, @options) or exit 1;
if ($config{help} or ($#ARGV != 1)) {
   &usage;
   exit;
}
my ($rtr) = $ARGV[0] =~ /^([-_\.\w]+)$/;
my ($community) = $ARGV[1] =~ /^([-_\.\w]+)$/;
my ($DEBUG) = $config{"debug"} || 0;
init_debug($DEBUG);
my ($preoptions) = $config{"2"} ? ":::::2" : "";
my ($DESTDIR) = $config{"out"} ? $config{"out"} =~ /^([-_\.\/\w]+)$/ : "/home/mrtg/cfg";
&debug ("DEBUG = $DEBUG, DESTDIR = $DESTDIR, preoptions = $preoptions",1);
my (%target);

########## First, look at sysDescr and figure out what to crawl.
&debug ("========== router = $rtr, community = $community",1);
my ($sysdescr) = SNMP_util::snmpget("$community\@${rtr}$preoptions", "sysDescr");
if ((! defined $sysdescr) or ($sysdescr eq "")) {
   die "!!! Trying to poll $rtr failed! !!!";
}
my ($rtrtype, $options, @oidlists) = &sysdescr2oids($sysdescr);
&debug ("rtrtype = $rtrtype, options = $options, sysdescr = $sysdescr", 1);

########## Start the config.
my ($destfile) = "$DESTDIR/$rtr.cfg";
my ($tmpfile) = "$destfile." . time;
open CONFIG, ">$tmpfile" or die "cannot open $tmpfile: $!";
my ($old_fh) = select;
select CONFIG;
$| = 1;
&print_head;

# see if we can get CPU usage too  --MNP 2007.08.24
&prnt_CPU($rtrtype, $options, $rtr, $community);
# see if we can get Memory usage too  --MNP 2009.04.02
&prnt_MEM($rtrtype, $options, $rtr, $community);

foreach (@oidlists) {
   my (@index, %ifname, %ifalias, %ifspeed);
   my ($ifInOctets, $ifOutOctets, $ifName, $ifAlias, $ifSpeed) = split "\t";
   &debug ("ifInOctets = $ifInOctets, ifOutOctets = $ifOutOctets, ifName = $ifName, ifAlias = $ifAlias, ifSpeed = $ifSpeed", 2);
   # Then, crawl octets.  No octets = not worth polling.
   foreach my $pair (SNMP_util::snmpwalk("$community\@${rtr}$options", $ifInOctets)) {
      my ($key, $value) = ($pair =~ /^([^:]+):(.*)$/);
      &debug ("$ifInOctets\{$key\} exists", 3);
      push @index, $key;
   }

   # Crawl and store everything else useful for the interface.
   foreach my $pair (SNMP_util::snmpwalk("$community\@${rtr}$options", $ifName)) {
      my ($key, $value) = ($pair =~ /^([^:]+):(.*)$/);
      &debug ("$ifName\{$key\} = $value", 3);
      # swap / for _ and remove spaces from interface names
      $value =~ s/\//_/g;
      # special for lame force10 CPUs
      $value =~ s/cpu /cpu\-/gi;
      $value =~ s/interface\: /interface\-/gi;
      $value =~ s/ //g;
      $ifname{$key} = $value;
   }
   foreach my $pair (SNMP_util::snmpwalk("$community\@${rtr}$options", $ifAlias)) {
      my ($key, $value) = ($pair =~ /^([^:]+):(.*)$/);
      &debug ("$ifAlias\{$key\} = $value", 3);
      $ifalias{$key} = $value;
   }
   if ($ifSpeed =~ /^\d+$/) {     # Rig ifSpeed if it's only numbers.
      foreach my $key (@index) {
         $ifspeed{$key} = $ifSpeed;
      }
   } else {
      foreach my $pair (SNMP_util::snmpwalk("$community\@${rtr}$options", $ifSpeed)) {
         my ($key, $value) = ($pair =~ /^([^:]+):(.*)$/);
         &debug ("$ifSpeed\{$key\} = $value", 3);
         # if we're using ifHighSpeed, don't forget to multiply by 1M:
         $value *= 1000000 if ($ifSpeed =~ m/ifHighSpeed/oi);

         # make sure it's an integer
         $value = int($value);
         &debug ("after int'ing and HighSpeed: $ifSpeed\{$key\} = $value", 3);
         $ifspeed{$key} = $value;
         # avoid interfaces with 0 speed
         if ((! $value) or ($value eq 0)) {
           $value = 7000;
           &debug ("Fixing ifspeed of 0; now $ifSpeed\{$key\} = $value", 3);
           $ifspeed{$key} = $value;
         }
      }
   }
   foreach my $i (@index) {
      next if ($ifname{$i} eq "Nu0");
      if (($target{$ifname{$i}}) and ($ifname{$i} =~ /-vpn/oi) ) {
         debug("Duplicate VPN target: $ifname{$i}, appending instance id $i",1);
         $ifname{$i} = $ifname{$i}."-".$i;
      }
      if ($target{$ifname{$i}}) {
         debug("Duplicate target: $ifname{$i}, instance $i, skipping.");
         next;
      }
      $target{$ifname{$i}} = 1;
      # because Netscreens suck donkey rocks  --MNP  2008.11.03
      $ifalias{$i} = "ifAlias OID not found" if (!defined $ifalias{$i});
      $ifalias{$i} = "ifAlias not set" if ($ifalias{$i} eq "");
      &prnt_oct($rtrtype, $ifInOctets, $ifOutOctets, $options, $rtr, $community, $i, $ifname{$i}, $ifspeed{$i}, $ifalias{$i});
      # Testing out monitoring discards  --MNP  2009.05.06
      &prnt_discards($rtr, $community, $i, $ifname{$i}, $ifspeed{$i}, $ifalias{$i});

      if ((! &badCatPktInt($ifname{$i},$ifalias{$i})) and ($rtrtype eq "catpkts")) {
         &prnt_pkt($rtr, $community, $i, $ifname{$i}, $ifspeed{$i}, $ifalias{$i});
      }
      if (($ifname{$i} !~ /vl\w*\d+/i) and ($ifname{$i} !~ /lo\d+/i) and ($rtrtype eq "f10pkts")) {
         &prnt_pkt($rtr, $community, $i, $ifname{$i}, $ifspeed{$i}, $ifalias{$i});
      }
   }
}


close CONFIG;
select $old_fh;
check_in ($tmpfile, $destfile, $minfsize, $ftype);

######################################################################
# Subroutines
######################################################################
sub usage {
   print <<EOM;
$self version $version

Usage: $self [OPTIONS] router community
Options:
  -h, --help            Print this message.
  -d, --debug           Turn on debugging.  Optional integer value for level.
  -o, --out             Change output directory.  Default /home/mrtg/cfg.
  -2                    Send initial sysdescr query via SNMP v2c.
EOM
}

sub sysdescr2oids {
   my ($descr) = @_;
   # return $rtrtype, $options, @oidlists
   # where @oidlists = $ifInOctets, $ifOutOctets, $ifName, $ifAlias, $ifSpeeda
   $descr =~ s/\n/ /g;
   if (($descr =~ /NetScreen/) or ($descr =~ /SSG-140/)) {
      return "NetScreen", ":::::2",
             "ifInOctets\tifOutOctets\tifDescr\tifAlias\tifSpeed",
             "enterprises.3224.4.1.1.1.35\tenterprises.3224.4.1.1.1.36\tenterprises.3224.4.1.1.1.4\tenterprises.3224.4.1.1.1.4\t1000000000";
   } elsif ($descr =~ /Cisco .+ C(2950|2924) Software/) {
      return "catpkts", "", "ifInOctets\tifOutOctets\tifName\tifAlias\tifSpeed";
   } elsif ($descr =~ /Juniper Networks.* internet router/si) {
      return "junos", ":::::2", "ifHCInOctets\tifHCOutOctets\tifName\tifAlias\tifHighSpeed";
   } elsif ($descr =~ /Cisco .+ C3\d\d\d(XL)? Software/i) {
      return "catpkts", ":::::2", "ifHCInOctets\tifHCOutOctets\tifName\tifAlias\tifHighSpeed";
   } elsif ($descr =~ /Cisco .+ Catalyst 4.00 L3 Switch Software/) {
      return "catpkts", ":::::2", "ifHCInOctets\tifHCOutOctets\tifName\tifAlias\tifHighSpeed";
   } elsif ($descr =~ /Cisco Internetwork Operating System Software/) {
      return "catpkts", ":::::2", "ifHCInOctets\tifHCOutOctets\tifName\tifAlias\tifHighSpeed";
   } elsif ($descr =~ /Force10 S50/) {
      return "f10pkts", ":::::2", "ifHCInOctets\tifHCOutOctets\tifName\tifAlias\tifHighSpeed";
   }
   return "generic", "", "ifInOctets\tifOutOctets\tifName\tifAlias\tifSpeed";
}

sub print_head {
   my ($rtr) = $rtr;
   print<<EOM;
EnableIPv6: no
Options[_]: growright,bits
WorkDir: /home/mrtg/data/$rtr
Interval: 5
WithPeak[_]: ymw

EOM
}


sub prnt_CPU {
   my ($rtrtype, $options, $rtr, $community) = @_;
   my ($cpu_oid1,$cpu_oid2) = ("","");
   my ($router_name) = lc ($rtr);
   my ($target_name) = $router_name . "_cpu";
      &debug("in prnt_CPU: $rtrtype, $options, $rtr, $community",1);
   my ($router_connect) = "$community\@${router_name}$options";
   if ($rtrtype eq "catpkts") {
      $cpu_oid1 = "enterprises.9.9.109.1.1.1.1.8.1";
      $cpu_oid2 = "enterprises.9.9.109.1.1.1.1.7.1";
   } elsif ($rtrtype eq "NetScreen") {
      $cpu_oid1 = "1.3.6.1.4.1.3224.16.1.2.0";
      $cpu_oid2 = "1.3.6.1.4.1.3224.16.1.3.0";
   } elsif ($rtrtype eq "junos") {
      $cpu_oid1 = "enterprises.2636.3.1.13.1.8.9.1.0.0";
      $cpu_oid2 = "enterprises.2636.3.1.13.1.8.9.1.0.0";
   } else {
      &debug("NO CPU OID defined for $rtrtype: $rtr",0);
      return;
   }
   print<<EOM;
Target[$target_name]:${cpu_oid1}&${cpu_oid2}:$router_connect
Title[$target_name]:${router_name}_cpmCPUTotalRev
YLegend[$target_name]:PercentageCPUload
ShortLegend[$target_name]:%
Legend1[$target_name]:CPU1Min.1%
Legend2[$target_name]:CPU5Min.1%
Legend3[$target_name]:MaxObservedCPU1Minload.1
Legend4[$target_name]:MaxObservedCPU5Minload.1
LegendI[$target_name]:&nbsp;CPULoad1Min.1:
LegendO[$target_name]:&nbsp;CPULoad5Min.1:
WithPeak[$target_name]:ywm
MaxBytes[$target_name]:100
AbsMax[$target_name]:200
Options[$target_name]:growright,gauge,nopercent
PageTop[$target_name]: <H1>${router_name} CPU</H1>
 <TABLE>
   <TR><TD>System:</TD>     <TD>${router_name}</TD></TR>
   <TR><TD>CPU OID 1:</TD>  <TD>${cpu_oid1}</TD></TR>
   <TR><TD>CPU OID 2:</TD>  <TD>${cpu_oid2}</TD></TR>
 </TABLE>

EOM
}


sub prnt_MEM {
   my ($rtrtype, $options, $rtr, $community) = @_;
   my ($mem_oid1,$mem_oid2,$mem_tot_oid,$memtot) = ("","","","");
   my ($router_name) = lc ($rtr);
   my ($target_name) = $router_name . "_mem";
      &debug("in prnt_MEM: $rtrtype, $options, $rtr, $community",1);
   my ($router_connect) = "$community\@${router_name}$options";
   if ($rtrtype eq "catpkts") {
      # $mem_oid1 = "enterprises.9.9.109.1.1.1.1.8.1";
      $mem_oid1 = "1.3.6.1.4.1.9.9.48.1.1.1.5.1";
      # $mem_oid2 = "enterprises.9.9.109.1.1.1.1.7.1";
      $mem_oid2 = "1.3.6.1.4.1.9.9.48.1.1.1.5.1";
      $mem_tot_oid = "enterprises.9.3.6.6.0";
      $memtot = SNMP_util::snmpget("$community\@${rtr}$preoptions", $mem_tot_oid);
      &mem_tot_stanza($mem_oid1,$mem_oid2,$mem_tot_oid,$memtot,$rtr,$community,$options);
      #&debug("NO MEM OID defined for $rtrtype: $rtr",0);
      # return;
   } elsif ($rtrtype eq "NetScreen") {
      # $mem_oid1 = "1.3.6.1.4.1.3224.16.1.2.0";
      # $mem_oid2 = "1.3.6.1.4.1.3224.16.1.3.0";
      &debug("NO MEM OID defined for $rtrtype: $rtr",0);
      return;
   } elsif ($rtrtype eq "junos") {
      $mem_oid1 = "1.3.6.1.4.1.2636.3.1.13.1.11.9.1.0.0";
      $mem_oid2 = "1.3.6.1.4.1.2636.3.1.13.1.11.9.1.0.0";
      &mem_perc_stanza($mem_oid1,$mem_oid2,$rtr,$community,$options);
   } else {
      &debug("NO MEM OID defined for $rtrtype: $rtr",0);
      return;
   }
}



sub mem_perc_stanza {
   my($mem_oid1,$mem_oid2,$rtr,$community,$options) = @_ if @_;
   my ($router_name) = lc ($rtr);
   my ($target_name) = $router_name . "_mem";
      &debug("in mem_perc_stanza: $mem_oid1, $options, $rtr, $community",1);
   my ($router_connect) = "$community\@${router_name}$options";
   print<<EOM;
Target[$target_name]:${mem_oid1}&${mem_oid2}:$router_connect
Title[$target_name]:${router_name}_MEMUtil
YLegend[$target_name]:MemoryUtil
ShortLegend[$target_name]:%
Legend1[$target_name]:MEM.1%
Legend2[$target_name]:MEM.1%
Legend3[$target_name]:MaxObservedMEM.1
Legend4[$target_name]:MaxObservedMEM.1
LegendI[$target_name]:&nbsp;MEM.1:
LegendO[$target_name]:&nbsp;MEM.1:
WithPeak[$target_name]:ywm
MaxBytes[$target_name]:100
AbsMax[$target_name]:200
Options[$target_name]:growright,gauge,nopercent
PageTop[$target_name]: <H1>${router_name} Memory</H1>
 <TABLE>
   <TR><TD>System:</TD>     <TD>${router_name}</TD></TR>
   <TR><TD>MEM OID 1:</TD>  <TD>${mem_oid1}</TD></TR>
   <TR><TD>MEM OID 2:</TD>  <TD>${mem_oid2}</TD></TR>
 </TABLE>

EOM
}



sub mem_tot_stanza {
   my($mem_oid1,$mem_oid2,$mem_tot_oid,$memtotal,$rtr,$community,$options) = @_ if @_;
   my ($router_name) = lc ($rtr);
   my ($target_name) = $router_name . "_mem";
      &debug("in mem_tot_stanza: $memtotal, $options, $rtr, $community",1);
   my ($router_connect) = "$community\@${router_name}$options";
   my ($memstr) = unitslide($memtotal);
   print<<EOM;
Target[$target_name]:${mem_oid1}&${mem_oid2}:$router_connect
Title[$target_name]:${router_name}_MEMUtil
YLegend[$target_name]:MemoryUtil
ShortLegend[$target_name]:Bytes
Legend1[$target_name]:MEM.1
Legend2[$target_name]:MEM.1
Legend3[$target_name]:MaxObservedMEM.1
Legend4[$target_name]:MaxObservedMEM.1
LegendI[$target_name]:&nbsp;MEM.1:
LegendO[$target_name]:&nbsp;MEM.1:
WithPeak[$target_name]:ywm
MaxBytes[$target_name]:$memtotal
AbsMax[$target_name]:$memtotal
Options[$target_name]:growright,gauge
PageTop[$target_name]: <H1>${router_name} Memory</H1>
 <TABLE>
   <TR><TD>System:</TD>     <TD>${router_name}</TD></TR>
   <TR><TD>MEM OID 1:</TD>  <TD>${mem_oid1}</TD></TR>
   <TR><TD>MEM OID 2:</TD>  <TD>${mem_oid2}</TD></TR>
   <TR><TD>TOT MEM OID:</TD>  <TD>${mem_tot_oid}</TD></TR>
   <TR><TD>TOTAL MEMORY</TD>  <TD>${memstr}</TD></TR>
 </TABLE>

EOM
}




sub prnt_oct {
   my ($rtrtype, $ifInOctets, $ifOutOctets, $options,
       $rtr, $community, $i, $ifname, $ifspeed, $ifalias) = @_;
   my ($lcname) = lc ($ifname);
   # because Netscreens suck donkey rocks  --MNP  2008.11.03
   $ifalias = "ifAlias OID not found" if ((!defined $ifalias) or ($ifalias eq ""));
   # Just because Force10 s50s SUCK so bad...
   $ifspeed = 800000 if ((!defined $ifspeed) or ($ifspeed < 8));
   &debug ("prnt_oct $rtrtype, $ifInOctets, $ifOutOctets, $options, $rtr, $community, $i, $ifname, $ifspeed, $ifalias",2);
   my ($speed) = unitslide($ifspeed); $ifspeed /= 8;
   # make sure it's an integer!!
   $ifspeed = int($ifspeed);
   &debug (" ifspeed is now $ifspeed",2);
   print<<EOM;
Target[${rtr}_$lcname]: $ifInOctets.${i}&$ifOutOctets.${i}:$community\@${rtr}$options
MaxBytes[${rtr}_$lcname]: $ifspeed
AbsMax[${rtr}_$lcname]: $ifspeed
Title[${rtr}_$lcname]: ${rtr} $ifname $ifalias
PageTop[${rtr}_$lcname]: <H1>${rtr} $ifname $ifalias</H1>
 <TABLE>
   <TR><TD>System:</TD>     <TD>${rtr}</TD></TR>
   <TR><TD>ifName:</TD>     <TD>$ifname</TD></TR>
   <TR><TD>ifAlias:</TD>     <TD>$ifalias</TD></TR>
   <TR><TD>Max Speed:</TD>  <TD>$speed</TD></TR>
 </TABLE>

EOM
}


sub prnt_discards {
   my ($rtr, $community, $i, $ifname, $ifspeed, $ifalias) = @_;
   my ($lcname) = lc ($ifname);
   # Skip interfaces that don't seem to have discard counters
   return(0) if ( skipInt($lcname,$ifalias,"discards") eq 1 );
   # Just because Force10 s50s SUCK so bad...
   $ifspeed = 800000 if ((!defined $ifspeed) or ($ifspeed < 8));
   &debug ("prnt_discards $rtr, $community, $i, $ifname, $ifspeed, $ifalias",2);
   my ($speed) = unitslide($ifspeed); $ifspeed /= 8;
   # make sure it's an integer!!
   $ifspeed = int($ifspeed);
   &debug (" ifspeed is now $ifspeed",2);
   # Ugh.  I multiply the values by 300 so when it later divides by 300,
   # it maps more or less correctly to a "per-interval" measurement.
   print<<EOM;

Target[${rtr}_$lcname-discards]: ifInDiscards.${i}&ifOutDiscards.${i}:$community\@${rtr}:::::2 * 300
MaxBytes[${rtr}_$lcname-discards]: $ifspeed
AbsMax[${rtr}_$lcname-discards]: $ifspeed
Title[${rtr}_$lcname-discards]: ${rtr} $ifname $ifalias discards
Options[${rtr}_$lcname-discards]: growright
ShortLegend[${rtr}_$lcname-discards]: pkts
YLegend[${rtr}_$lcname-discards]: Discards per interval
Legend1[${rtr}_$lcname-discards]: Incoming Discards
Legend2[${rtr}_$lcname-discards]: Outgoing Discards
Legend3[${rtr}_$lcname-discards]: Maximal 5 Minute Incoming Discards
Legend4[${rtr}_$lcname-discards]: Maximal 5 Minute Outgoing Discards
PageTop[${rtr}_$lcname-discards]: <H1>${rtr} $ifname $ifalias Discards</H1>
 <TABLE>
   <TR><TD>System:</TD>     <TD>${rtr}</TD></TR>
   <TR><TD>ifName:</TD>     <TD>$ifname</TD></TR>
   <TR><TD>ifAlias:</TD>     <TD>$ifalias</TD></TR>
   <TR><TD>Max Speed:</TD>  <TD>$speed</TD></TR>
 </TABLE>
EOM
}


sub prnt_pkt {
   my ($rtr, $community, $i, $ifname, $ifspeed, $ifalias) = @_;
   my ($lcname) = lc ($ifname);
   # Just because Force10 s50s SUCK so bad...
   $ifspeed = 800000 if ((!defined $ifspeed) or ($ifspeed < 8));
   &debug ("prnt_pkt $rtr, $community, $i, $ifname, $ifspeed, $ifalias",2);
   my ($speed) = unitslide($ifspeed); $ifspeed /= 8;
   # make sure it's an integer!!
   $ifspeed = int($ifspeed);
   &debug (" ifspeed is now $ifspeed",2);
   print<<EOM;

Target[${rtr}_$lcname-ucastpkts]: ifHCInUcastPkts.${i}&ifHCOutUcastPkts.${i}:$community\@${rtr}:::::2
MaxBytes[${rtr}_$lcname-ucastpkts]: $ifspeed
AbsMax[${rtr}_$lcname-ucastpkts]: $ifspeed
Title[${rtr}_$lcname-ucastpkts]: ${rtr} $ifname $ifalias ucastpkts
Options[${rtr}_$lcname-ucastpkts]: growright
ShortLegend[${rtr}_$lcname-ucastpkts]: pkts
YLegend[${rtr}_$lcname-ucastpkts]: Pkts per Second
Legend1[${rtr}_$lcname-ucastpkts]: Incoming Packets per Second
Legend2[${rtr}_$lcname-ucastpkts]: Outgoing Packets per Second
Legend3[${rtr}_$lcname-ucastpkts]: Maximal 5 Minute Incoming Packets
Legend4[${rtr}_$lcname-ucastpkts]: Maximal 5 Minute Outgoing Packets
PageTop[${rtr}_$lcname-ucastpkts]: <H1>${rtr} $ifname $ifalias</H1>
 <TABLE>
   <TR><TD>System:</TD>     <TD>${rtr}</TD></TR>
   <TR><TD>ifName:</TD>     <TD>$ifname</TD></TR>
   <TR><TD>ifAlias:</TD>     <TD>$ifalias</TD></TR>
   <TR><TD>Max Speed:</TD>  <TD>$speed</TD></TR>
 </TABLE>

Target[${rtr}_$lcname-mcastpkts]: ifHCInMulticastPkts.${i}&ifHCOutMulticastPkts.${i}:$community\@${rtr}:::::2
MaxBytes[${rtr}_$lcname-mcastpkts]: $ifspeed
AbsMax[${rtr}_$lcname-mcastpkts]: $ifspeed
Title[${rtr}_$lcname-mcastpkts]: ${rtr} $ifname $ifalias mcastpkts
Options[${rtr}_$lcname-mcastpkts]: growright
ShortLegend[${rtr}_$lcname-mcastpkts]: pkts
YLegend[${rtr}_$lcname-mcastpkts]: Pkts per Second
Legend1[${rtr}_$lcname-mcastpkts]: Incoming Packets per Second
Legend2[${rtr}_$lcname-mcastpkts]: Outgoing Packets per Second
Legend3[${rtr}_$lcname-mcastpkts]: Maximal 5 Minute Incoming Packets
Legend4[${rtr}_$lcname-mcastpkts]: Maximal 5 Minute Outgoing Packets
PageTop[${rtr}_$lcname-mcastpkts]: <H1>${rtr} $ifname $ifalias</H1>
 <TABLE>
   <TR><TD>System:</TD>     <TD>${rtr}</TD></TR>
   <TR><TD>ifName:</TD>     <TD>$ifname</TD></TR>
   <TR><TD>ifAlias:</TD>     <TD>$ifalias</TD></TR>
   <TR><TD>Max Speed:</TD>  <TD>$speed</TD></TR>
 </TABLE>

Target[${rtr}_$lcname-bcastpkts]: ifHCInBroadcastPkts.${i}&ifHCOutBroadcastPkts.${i}:$community\@${rtr}:::::2
MaxBytes[${rtr}_$lcname-bcastpkts]: $ifspeed
AbsMax[${rtr}_$lcname-bcastpkts]: $ifspeed
Title[${rtr}_$lcname-bcastpkts]: ${rtr} $ifname $ifalias bcastpkts
Options[${rtr}_$lcname-bcastpkts]: growright
ShortLegend[${rtr}_$lcname-bcastpkts]: pkts
YLegend[${rtr}_$lcname-bcastpkts]: Pkts per Second
Legend1[${rtr}_$lcname-bcastpkts]: Incoming Packets per Second
Legend2[${rtr}_$lcname-bcastpkts]: Outgoing Packets per Second
Legend3[${rtr}_$lcname-bcastpkts]: Maximal 5 Minute Incoming Packets
Legend4[${rtr}_$lcname-bcastpkts]: Maximal 5 Minute Outgoing Packets
PageTop[${rtr}_$lcname-bcastpkts]: <H1>${rtr} $ifname $ifalias</H1>
 <TABLE>
   <TR><TD>System:</TD>     <TD>${rtr}</TD></TR>
   <TR><TD>ifName:</TD>     <TD>$ifname</TD></TR>
   <TR><TD>ifAlias:</TD>     <TD>$ifalias</TD></TR>
   <TR><TD>Max Speed:</TD>  <TD>$speed</TD></TR>
 </TABLE>

EOM
}

# &debug is picked up from MyLIb now


# returns TRUE (1) if interface should be skipped when doing catpkts
# packet counters; FALSE (0) otherwise
sub badCatPktInt {
   my($intname,$intalias) = @_ if @_;
   # because Netscreens suck donkey rocks  --MNP  2008.11.03
   $intalias = "this vendor does not support ifAlias OID" if ((!defined $intalias) or ($intalias eq ""));
   &debug("in badCatPktInt, intname: $intname intalias: $intalias",1);
# these seem to be inconsistent; commenting back out for now until
# i can figure out the rhyme and reason behind them.
   return(1) if ($intname =~ /vl\d+/i); 
#  unrouted vlans are vlan-###, routed vlans are vl### on ciscos
   return(1) if ($intname =~ /vlan-\d+/i); 
   return(1) if ($intname =~ /lo\d+/i); 
   return(1) if ($intname =~ /eo\d+/i); 
   return(0);
}

# returns TRUE (1) if interface should be skipped 
# FALSE (0) otherwise
sub skipInt {
   my($intname,$intalias,$type) = @_ if @_;
   # because Netscreens suck donkey rocks  --MNP  2008.11.03
   $intalias = "this vendor does not support ifAlias OID" if ((!defined $intalias) or ($intalias eq ""));
   &debug("in skipInt, type: $type intname: $intname intalias: $intalias",1);
  if ($type =~ /pkt/oi ) {
     # these seem to be inconsistent; commenting back out for now until
     # i can figure out the rhyme and reason behind them.
     return(1) if ($intname =~ /vl\d+/i);
   #  unrouted vlans are vlan-###, routed vlans are vl### on ciscos
     return(1) if ($intname =~ /lo\d+/i);
     return(1) if ($intname =~ /eo\d+/i);
  }
  if ($type =~ /discard/oi ) {
      return(1) if ($intname =~ /vlan-\d+/i);
      return(1) if ($intname =~ /\-vpn/oi);
  }
  return(0);
}

mpetach at netops2:~/mrtg>


      



More information about the mrtg mailing list