[mrtg] Re: Use of MRTG+RRD for LAN traffic analysis with one secondinterval

Volk,Gregory B greg.volk at edwardjones.com
Tue Oct 11 13:06:31 MEST 2005


> 
> But some of my collegues were claiming that MRTG+RRD can 
> allow me to do 
> the traffic analysis with one second intervals.
> 

RRDtool, the back-end database piece of MRTG, can take
data as frequently as one sample per second. However, MRTG,
being a front-end data collection mechanism for RRDtool is 
limited to no faster than a five minute poll cycle.
Occasionally I have had the need to poll certain OIDs at
five or ten second intervals. To do this, I wrote a quick
perl script that makes the SNMP call via the SNMP_util module
and then uses the RRDs shared lib to load the RRD files 
with the data. After some number of poll cycles, I use Dave
Plonk's RRGrapher (http://net.doit.wisc.edu/~plonka/RRGrapher/)
utility to plot the data from the RRD files that the perl
script populated.

Here is an example of the perl script:


/*BEING PERL SCRIPT*/
#!/bin/perl -w
#
#
use strict;

use lib "/opt/mrtg/lib/mrtg2/ /opt/rrdtl/lib/perl";

use SNMP_util;
use RRDs;

my ($rrdfile,$host,$community,$router,$gauge1,$counter1,$counter2,
        $counter3);

my $ipgwBbStFctws = ".1.3.6.1.4.1.303.3.3.7.3.1.3.30.0";
my $ipgwEntStPktsDelays = ".1.3.6.1.4.1.303.3.3.7.3.1.1.8.0";
my $ipgwBbStSgwBytesSent = ".1.3.6.1.4.1.303.3.3.7.3.1.3.6.0";
my $ipgwBbStSgwPkts = ".1.3.6.1.4.1.303.3.3.7.3.1.3.7.0";

$community = "public";
$router = "testrouter";

while (1) {

  $rrdfile = "/opt/EJnrrdtl/rrd/testrouter.rrd";
  $host = join "@", $community, $router;
  ($gauge1) = &snmpget("$host",$ipgwBbStFctws);
  ($counter1) = &snmpget("$host",$ipgwEntStPktsDelays);
  ($counter2) = &snmpget("$host",$ipgwBbStSgwBytesSent);
  ($counter3) = &snmpget("$host",$ipgwBbStSgwPkts);
  print "$gauge1 $counter1 $counter2 $counter3\n";
  RRDs::update("$rrdfile","N:$gauge1:$counter1:$counter2:$counter3");
  sleep(10);
}
/*END PERL SCRIPT*/


This particular script polls the data, then sleeps for ten
seconds, then loops back through. You'll need to create the
RRD file first using the 'rrdtool create' command.

This method of short-cycle data collection works pretty well, 
but is obviously not scalable or manageable past a few variables.

--
Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Archive     http://lists.ee.ethz.ch/mrtg
FAQ         http://faq.mrtg.org    Homepage     http://www.mrtg.org
WebAdmin    http://lists.ee.ethz.ch/lsg2.cgi



More information about the mrtg mailing list