Speeding up SNMP queries

YAPC::Europe::2006



By

Jan Henning Thorsen

TOC

  1. Introduction
  2. A bit about SNMP and SNMP.pm
  3. The SNMP::Effective interface
  4. SNMP::Effective's callback method
  5. The inner workings

Introduction

A bit about SNMP and SNMP.pm

The SNMP::Effective interface

new()

 my $effective = SNMP::Effective->new(
                    MaxSessions   => $int,
                    MasterTimeout => $int,

                    ...

                ); 

add()

 $effective->add(
                    DestHost => [],
                    Arg      => {},
                    Callback => sub {},
                    get      => [],
                    walk     => [],
                    set      => [],
                ); 

execute()

 $effective->execute; 

The callback method input

Callback method example

 sub my_callback {
    
    ### init
    my $host  = shift;
    my $error = shift;

    ### check for error
    if($error) {
        warn “$host failed with this error: $error”;
        return;
    } 

Callback method example continue

    ### get data
    my $data = $host->data;

    ### loop data
    for my $oid (%$data) {
       print “$host returned oid $oid with this data:\n”;
       print join “\n\t”, map {
                          “$_ => $data->{$oid}{$_}”;
                          } keys %{ $data->{$oid} };
       print “\n”;
   }
} 

Sample output

10.2.10.3 returned oid 1.3.6.1.2.1.1.1 with this data:
1 => C12-MM4-CS, Hardware V4 VENDOR: BigBand; BOOTR:
(ser#0600012893, part#90000046000, rev#A2, opt#c02),
v6.0.1(14), Release6.0_Integration Built
2006_03_29_153010 

The inner workings

SNMP::Effective

SNMP::Effective::Dispatch

SNMP::Effective::Var

Any questions?