Perform synchronous SNMP GET requests
This section of the SNMP GET access example Perl script sets up the logic to run the synchronous SNMP GET requests. Use this part of the example script as a guide to writing code that makes use of some of the synchronous SNMP GET requests in client/server Perl scripts that retrieve SNMP information.
The SNMP GET access example Perl script sets up the logic and runs the synchronous SNMP GET requests as follows:
sub SyncTests {
print "$Ttype: call SnmpGetNext($nodeIP, NULL, ifDescr)\n"; 1
my ($vap) = $snmp->SnmpGetNext($nodeIP, "", "ifDescr") or
die "SnmpGetNext on ifDescr table for '$node' failed";
foreach my $varop (@{ $vap })
{
PrintVarOp($varop);
}
print "$Ttype: call SnmpGet($nodeIP, NULL, ifDescr,1)\n"; 2
$vap = $snmp->SnmpGet($nodeIP, "", "ifDescr",1) or
die "SnmpGetNext on ifDescr table for '$node' failed";
PrintVarOp($vap);
print "$Ttype: call SnmpGetBulk($nodeIP, NULL,\@oids,8,100)\n";
my @oids=('sysDescr', 'sysContact', 'sysUpTime', 'ipInReceives',
'ipOutRequests', 'ipOutDiscards', 'ipForwDatagrams',
'tcpCurrEstab', 'ifDescr');
($vap) = $snmp->SnmpGetBulk($nodeIP, "", \@oids, 8, 100); 3
foreach my $varop (@{ $vap })
{
PrintVarOp($varop);
}
}
The following list explains specific numbered items in the previously listed section of the SNMP GET access Perl script example:
- Performs an SNMP GETNEXT synchronous request (by calling the
SnmpGetNextmethod). - Performs an SNMP GET synchronous request (by calling the
SnmpGetmethod). - Performs an SNMP GETBULK synchronous request (by calling the
SnmpGetBulkmethod).