Hello all,
I'm currently modifying our application to use the embedded Perl
module with net-snmp v5.4.2.1 and stumbled upon a problem with
NetSNMP::OID. The problem is very easy to reproduce by adding just two
lines to the code snippet taken from the NetSNMP::TrapReceiver
documentation:
#!/usr/bin/perl
use NetSNMP::OID; # FIRST LINE ADDED
sub my_receiver {
print "********** PERL RECEIVED A NOTIFICATION:\n";
# print the PDU info (a hash reference)
print "PDU INFO:\n";
foreach my $k(keys(%{$_[0]})) {
printf " %-30s %s\n", $k, $_[0]{$k};
}
# print the variable bindings:
print "VARBINDS:\n";
foreach my $x (@{$_[1]}) {
printf " %-30s type=%-2d value=%s\n", $x->[0], $x->[2],
$x->[1];
}
my $oid = new NetSNMP::OID('sysContact.0'); # SECOND LINE ADDED
}
NetSNMP::TrapReceiver::register("all", \&my_receiver) ||
warn "failed to register our perl trap handler\n";
print STDERR "Loaded the example perl snmptrapd handler\n";
Now if I configure snmptrapd to use this piece of code and generate a
trap using
> snmpinform -v 3 -l $LEVEL -u $USER -a MD5 -A $PASS -x DES \
-X $PASS $IPADDRESS '' QUANTE-CSS-MIB-V2::rmTrapDownloadCancel \
QUANTE-CSS-MIB-V2::eventCurrentNumber.0 u `date +%s` \
QUANTE-CSS-MIB-V2::actualIndex.1 i 1
for the first time, I get the following lines in the output
[UDP: [10.25.153.160]->[10.25.153.160]:35238]:
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (269834978) 31 days,
5:32:29.78 SNMPv2-MIB::snmpTrapOID.0 = OID:
QUANTE-CSS-MIB-V2::rmTrapDownloadCancel
QUANTE-CSS-MIB-V2::eventCurrentNumber.0 = Gauge32: 1237823308
QUANTE-CSS-MIB-V2::actualIndex.1 = INTEGER: 1
******** PERL RECEIVED A NOTIFICATION:
<snip>
VARBINDS:
DISMAN-EVENT-MIB::sysUpTimeInstance type=67 value=Timeticks: (269834978)
31 days, 5:32:29.78
SNMPv2-MIB::snmpTrapOID.0 type=6 value=OID:
QUANTE-CSS-MIB-V2::rmTrapDownloadCancel
QUANTE-CSS-MIB-V2::eventCurrentNumber.0 type=66 value=Gauge32:
1237823308
QUANTE-CSS-MIB-V2::actualIndex.1 type=2 value=INTEGER: 1
This looks fine, but when I call the command above a second time,
output changes in the following way:
[UDP: [10.25.153.160]->[10.25.153.160]:35238]:
sysUpTimeInstance 31:5:32:33.36 snmpTrapOID.0 rmTrapDownloadCancel
eventCurrentNumber.0 1237823311 actualIndex.1 1
********** PERL RECEIVED A NOTIFICATION:
<snip>
VARBINDS:
sysUpTimeInstance type=67 value=31:5:32:33.36
snmpTrapOID.0 type=6 value=rmTrapDownloadCancel
eventCurrentNumber.0 type=66 value=1237823311
actualIndex.1 type=2 value=1
Is this a bug in the constructor of NetSNMP::OID() (which internally
calls SNMP::init_snmp("perl")) or somewhere else? Did I miss
something? If this is not a bug, how can I avoid to get a different
output formatting (snmptrapd.conf already contains "outputOption S")?
Regards,
Michael.
------------------------------------------------------------------------------
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders