Read "The interface" below, or check out my proceeding from YAPC::Europe::2006: speeding up snmp queries..
This method returns a SNMP::Effective object
(refered to as $snmp_effective
later in
this document) . Arguments to the constructor can be:
MaxSessions => int # maximum number of simultainious SNMP session MasterTimeout => int # maximum number of seconds before killing execute
All other arguments are passed on to
SNMP::Effective::Var::new,
which from a users views is the same as calling $snmp_effective->add(
[args] )
.
Arguments to this method can be:
DestHost => [] # an array-ref that contains a list of hosts, in this format: # xxx.xxx.xxx.xxx or a hostname Arg => {} # arguments passed on to SNMP::Session Callback => sub {} # the callback method whick handles the received data get => [] # an array-ref that contains a list of OIDs to get walk => [] # an array-ref that contains a list of OIDs “trees” to get set => [] # an array-ref that contains a list of OIDs to set
This can be called with many different combinations, such as:
DestHost / any other argument: This will make changes pr. DestHost. You can then change Arg, Callback, or add OIDs on host-basis.
get / walk / set: The OID list submitted to add() will be added to all DestHosts, if it's no DestHost is spesified.
Arg / Callback: This can be used to alter all hosts SNMP-arguments or callback method.
This method starts setting / getting data. It
will run as long as necessarily, or until MasterTimeout
is reached. Every time the some data is set / retrieved, it will
call the callback-method, defined pr. host.
When SNMP is done collecting data from a host, it
calls a callback method, provided by the Callback
=> sub{}
argument. Here is an example on a callback method:
my my_callback { my $host = shift; my $error = shift; if($error) { warn “$host failed with this error: $error”; return; } my $data = $host->data; PRINT_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"; } }
Example 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
By setting $SNMP::Effective::DEBUG
you will get a debugging information printed to STDERR. There are no
strict debugging levels (yet), but setting it to “100”
will output a lot of information.
SNMP module: http://search.cpan.org/~gsm/SNMP-4.2.0/SNMP.pm