Skip Menu |

This queue is for tickets about the SNMP CPAN distribution.

Report information
The Basics
Id: 103119
Status: new
Priority: 0/
Queue: SNMP

Owner: Nobody in particular
Requestors: seanb99 [...]

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)

Subject: Options parameter not working with gettable
Date: Wed, 25 Mar 2015 18:13:52 +0000
To: bug-SNMP [...]
From: Sean <seanb99 [...]>
Hi, I'm running: SNMP 5.05 Red Hat Enterprise Linux Server release 6.5 (Santiago) Perl v5.10.1 (*) built for x86_64-linux-thread-multi Running gettable with <OPTIONS> I get the following error: Odd number of elements in anonymous hash at /usr/lib64/perl5/vendor_perl/ line 684. E.g. using the following to get the storage table (where the arguments are hosts): #!/usr/bin/perl use SNMP; use Data::Dumper; foreach (@ARGV) { my $session = new SNMP::Session ('DestHost' => $_, 'Community' => 'public', 'Version' => 1); my $result = $session->gettable('hrStorageTable', { 'columns' => ['hrStorageDescr', 'hrStorageType'] } ); print Dumper($result); } Gives the following output (truncated): $ ./ hostname Odd number of elements in anonymous hash at /usr/lib64/perl5/vendor_perl/ line 684. $VAR1 = { '6' => { 'hrStorageSize' => '65528', 'hrStorageAllocationUnits' => '65536', 'hrStorageUsed' => '22584', 'hrStorageAllocationFailures' => '0', 'hrStorageDescr' => 'Physical Memory', 'hrStorageIndex' => '6', 'hrStorageType' => 'hrStorageRam' }, This returns all fields, so is ignoring the <OPTIONS> parameter. Running without the <OPTIONS> parameter, I don't get the error. Looking at line 684 in, it looks like this is because it's expecting an array instead of a hash, although the documentation states that <OPTIONS> should be a hash. Looking at the current version on CPAN, this is line 670. My suggested fix is as follows: $ diff 669,670c669,670 < my ($this, $root_oid, @options) = @_; < $state->{'options'} = {@options}; --- Show quoted text
> my ($this, $root_oid, $options) = @_; > $state->{'options'} = $options;
This fix gives the expected results - i.e. it honours the 'columns' option when set. Not sure if this is right fix, but it works for me. Sean.

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to