Here is a patch for
./perl/SNMP/SNMP.xs
It will fix the following issue:
We use asynchronous polling with the Perl binding of
netsnmp. The callback response contains the value and
type but the oid field is empty.
Without our patch:
bless( [
'', # oid is missing !!!
'',
'122492066',
'TICKS'
], 'SNMP::Varbind' ),
With our patch:
bless( [
'.1.3.6.1.2.1.1.3', # oid is there !!!
'0',
'122519957',
'TICKS'
], 'SNMP::Varbind' ),
The problem occurs under the following circumstances:
- Solaris
- net-snmp version 5.2.1, 5.2.2, 5.3.1
- perl 5.8.7
- option: use_numeric=1
- asynchronous polling with callback
The small programm following will demonstrate the
problem. The output without/with our patch is shown below.
We would be happy if this patch will be approved
officially and included into future releases.
# testprogram to show problem
# pollasync.pl
use SNMP;
use Data::Dumper;
$SNMP::auto_init_mib = 0;
$SNMP::use_numeric = 1;
$SNMP::use_long_names = 0;
$SNMP::verbose = 0;
$SNMP::debugging = 0;
$sess = new SNMP::Session(
DestHost => "193.1.2.3",
Community => "public",
Timeout => 100000,
Version => 1,
Retries => 2
);
#print Dumper($sess);
my $varlist=new
SNMP::VarList([".1.3.6.1.2.1.1.3.0"],[".1.3.6.1.2.1.1.1.0"]);
$sess->get($varlist, [\&poller, $sess]);
SNMP::MainLoop();
@var=$sess->get($varlist);
print "\n\nsync:\n";
print Dumper(@var);
exit;
sub poller {
if (!defined($_[1])) { die "request timed
out[$_[0]->{ErrorStr}]\n"; }
print "\n\nasnyc:\n";
print $_[1][0]->tag, " = ", $_[1][0]->val, "\n";
print Dumper($_[1]);
SNMP::finish();
}
# end of program
Below the output of the program without/with our patch:
# program output without our patch:
asnyc:
= 122492066
$VAR1 = bless( [
bless( [
'',
'',
'122492066',
'TICKS'
], 'SNMP::Varbind' ),
bless( [
'',
'',
'Cisco Internetwork Operating
System Software
IOS (tm) C2600 Software (C2600-I-M), Version 12.0(7)T,
RELEASE SOFTWARE (fc2)
Copyright (c) 1986-1999 by cisco Systems, Inc.
Compiled Tue 07-Dec-99 02:12 by phanguye',
'OCTETSTR'
], 'SNMP::Varbind' )
], 'SNMP::VarList' );
sync:
$VAR1 = '122492067';
$VAR2 = 'Cisco Internetwork Operating System Software
IOS (tm) C2600 Software (C2600-I-M), Version 12.0(7)T,
RELEASE SOFTWARE (fc2)
Copyright (c) 1986-1999 by cisco Systems, Inc.
Compiled Tue 07-Dec-99 02:12 by phanguye';
# program output with our patch:
asnyc:
.1.3.6.1.2.1.1.3 = 122519957
$VAR1 = bless( [
bless( [
'.1.3.6.1.2.1.1.3',
'0',
'122519957',
'TICKS'
], 'SNMP::Varbind' ),
bless( [
'.1.3.6.1.2.1.1.1',
'0',
'Cisco Internetwork Operating
System Software
IOS (tm) C2600 Software (C2600-I-M), Version 12.0(7)T,
RELEASE SOFTWARE (fc2)
Copyright (c) 1986-1999 by cisco Systems, Inc.
Compiled Tue 07-Dec-99 02:12 by phanguye',
'OCTETSTR'
], 'SNMP::Varbind' )
], 'SNMP::VarList' );
sync:
$VAR1 = '122519958';
$VAR2 = 'Cisco Internetwork Operating System Software
IOS (tm) C2600 Software (C2600-I-M), Version 12.0(7)T,
RELEASE SOFTWARE (fc2)
Copyright (c) 1986-1999 by cisco Systems, Inc.
Compiled Tue 07-Dec-99 02:12 by phanguye';
# end of text
patch for ./perl/SNMP/SNMP.xs appropriate for netsnmp 5.2.1, 5.2.2, 5.3.1
Logged In: YES
user_id=76242
Thanks very much for the patch. This actually fixes a
very long outstanding bug that I just haven't had the time
to look into! Applied to 5.2 and up!