1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
#!/usr/bin/perl
# Test of the ability to capture and display SNMP traffic.
# usage
# capturetest host <maxrep> <list of variables>
#
# Example:
# capturetest myrouter:::::2 25 ifDescr ifInOctets
use strict;
use FindBin;
use lib "/opt/mrtg-2.9.22dev/lib/mrtg2";
use SNMP_util;
use BER;
&main;
sub main
{
my $router_connect = shift @ARGV;
my $maxrepeaters = shift @ARGV;
my @req_vars = @ARGV;
my @buffer;
my @result = snmpwalk($router_connect,
{
capture_buffer =>\@buffer,
return_array_refs => 1,
default_max_repetitions => $maxrepeaters
},
@req_vars
);
print "Result is ", (join "\n\n",(map ((join ' ', @{$_}),@result))), "\n";
print "Capture buffer contains ", (scalar @buffer), " entries.\n";
for my $entry (@buffer)
{
print "\n";
print pretty_print($entry), "\n";
}
print "\n";
}
|