[rrd-users] Re: increase performance

Mike Wright Mike at auckland-services.freeserve.co.uk
Thu Aug 23 23:35:15 MEST 2001


At 00:03 23/08/01 +0200, Alex van den Bogaerdt wrote:

>So, doing an snmpwalk on all interfaces and then processing the result
>on the monitoring box (for instance, using 10 out of 20 values) is not
>efficient at all, except that the monitoring box can do its work a bit
>quicker.

OK, things are getting confusing here. Lets say you want to get ifInOctets
for 10 of the 20 interfaces on a single device. There's more than one way
to do it, here's 3 possible ways, least efficient method first.


First Method. 

my @in_octets = &snmpwalk ($device,"ifInOctets");

This will return the ifInOctets for every interface on the device and will
send 1 packet per interface on the device (plus 1 extra packet). You will
end up with data for 20 interfaces when you only wanted to get data for 10
so you discard half your data, no problem. But it's slow because the
snmpwalk must wait for a reply for each of the 20 requests before it sends
the next one. If the average round trip time to the device is 100ms then it
will take 20 x 100ms = 2 seconds to complete.


Second Method.

my @interfaces = (1,2,3,4,5,6,7,8,9,10);
for my $if (@interfaces) {
  my ($in) = &snmpget ($device,"ifInOctets.$if");
  push @in_octets, $in;
}

This will send 10 packets and only take half the time of the first method.
(100ms x 10 = 1 second).


Third Method.

my @interfaces = (1,2,3,4,5,6,7,8,9,10);
my @mibs;
for my $if (@interfaces) {
  push @mibs, "ifInOctets.$if";
}
my @in_octets = &snmpget ($device, at mibs);

This will retrieve all the mibs in a single request, taking just 100ms.
Using SNMPv2's "getbulk" would work in a similar way, returning multiple
table rows in one response but unfortunately not all devices support SNMPv2.

>I agree on the backticks, however you seem to both agree and disagree
>with me on starting perl.

Sorry, it was late when I wrote that. What I meant was it is a bit overhead
starting perl for each target you log, but if you are only doing it once in
5 minutes then it's negligible.

>> Also, you don't mention how you are getting the data into RRDtool. Do you
>> run `rrdtool update` in back ticks too? This will also have an even bigger
>> overhead. You should be using the "RRDs" module.
>
>Nah,  I usually do it quick and dirty:
>
>snmpget host public 2.2.1.10.2 2.2.1.16.2 | \
>   awk 'BEGIN{i=o="U"};/ifIn/{i=$3};/ifOut/{o=$3};END{print "N:"i":"o} | \
>   xargs rrdupdate my.rrd
>
>Variants on this are also possible: the print command becomes something
>like {print "update router1.rrd N:"i":"o} and several of these quickies
>go into one script.  This script can then be run as follows:
>
>collector | rrdtool -

Ahh, quick and dirty - just how I like it. ;-) Fair enough. Using this pipe
method means you only have to start rrdtool once which is cool.

A few years ago I had a script that used to start a new rrdtool for each
rrd I updated and I used to wonder why it was so slow. Then I realised I
was starting about 1000 rrdtools every minute. Woops. 8-)

Cheers,

Mike Wright,
Network Engineer, Reuters.



--
Unsubscribe mailto:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-users-request at list.ee.ethz.ch?subject=help
Archive     http://www.ee.ethz.ch/~slist/rrd-users
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi



More information about the rrd-users mailing list