File: capturetest.pl

package info (click to toggle)
libsnmp-session-perl 1.14~git20221124T101957-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,104 kB
  • sloc: perl: 11,920; ansic: 25; makefile: 15
file content (60 lines) | stat: -rw-r--r-- 905 bytes parent folder | download | duplicates (10)
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";
}