Corrupt VarBinds from SNMP.pm
Peter Hicks <[email protected]>
| Newsgroups | gmane.network.net-snmp.user |
|---|---|
| Message-ID | <[email protected]> |
Hello
I'm using SNMP.pm 5.0401 from Debian's release of 5.4.1 which is
5.4.1~dfsg-7.1.
Running the following code:
#!/usr/bin/perl -w
use strict;
use warnings;
use SNMP;
my $sess = new SNMP::Session( DestHost => 'localhost', Community => 'public', Version => 2 );
my @vbl;
push @vbl, [ 'sysUpTime', 0 ];
push @vbl, [ 'sysName', 0 ];
push @vbl, [ 'sysLocation', 0 ];
push @vbl, [ 'sysContact', 0 ];
my $varlist = new SNMP::VarList(@vbl);
$sess->get($varlist);
print "ERROR WAS: ".$sess->{'ErrorStr'}."\n";
foreach my $vb (@$varlist) {
print "0:".$vb->[0]."\n";
print "1:".$vb->[1]."\n";
print "2:".$vb->[2]."\n";
print "3:".$vb->[3]."\n";
}
...produces strange results:
ERROR WAS:
0:sysUpTimeInstance
1:
2:20887615
3:TICKS
0:sysName.0
1:
2:ysName.0nstance<HEX>
3:OCTETSTR
0:sysLocation.0
1:
2:ysLocation.0
3:OCTETSTR
0:sysContact.0
1:
2:ysContact.0nce<HEX>
3:OCTETSTR
<HEX> in this case is some random high-ASCII unprintable characters.
I can't figure out why this is happening. Using snmpget:
pwh@devil:/tmp$ snmpget localhost -c public -v 2c sysUpTime.0 sysName.0 sysLocation.0 sysContact.0
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (20896259) 2 days, 10:02:42.59
SNMPv2-MIB::sysName.0 = STRING: devil.noc.example.com
SNMPv2-MIB::sysLocation.0 = STRING: Datacentre 4
SNMPv2-MIB::sysContact.0 = STRING: Operations <[email protected]>
Just getting sysUpTime in perl works fine, it's only when I try to get the
other OIDs that things go wrong.
Can anyone help me troubleshoot?
Peter
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users