Hi all, I'm trying to write a data collector for a large number of layer 2 devices, and I'm running into some strange problems with SNMP::bulkwalk.
Using the following code snippet: <SNIP> sub poll_devices { my ($devices) = @_; # ref to a hash of hashes /w IPs as primary keys my %results; my $num_devices = scalar keys %$devices; my $this_device = 0; my $vars = new SNMP::VarList( ['.1.3.6.1.2.1.2.2.1.2'], # ifDescr ['.1.3.6.1.2.1.2.2.1.8'], # ifOperStatus ['.1.3.6.1.2.1.17.4.3.1.1'], # TpFdbAddress ['.1.3.6.1.2.1.17.4.3.1.2'], # TpFdbPort ['.1.3.6.1.2.1.17.1.4.1.2']); # BasePortIfIndex # Parse our devices and poll all repeater oids using 1 bulkwalk per host for my $dev (keys %$devices) { my $cid = $devices->{$dev}{'cid'}; # ROCID my $rep = $devices->{$dev}{'rep'}; # num repeaters (ifNumber+1) my $sess = new SNMP::Session( 'DestHost' => $dev, 'Community' => $cid, 'Version' => 2, 'UseNumeric' => 1, 'UseEnums' => 0, 'UseSprintValue' => 0 ); my $request = $sess->bulkwalk(0, $rep, $vars, [ sub { # Anon sub my ($dev, $res, $this_dev, $num_dev, $value) = @_; # Stick our returned data into our hash reference for my $varlist (@$value) { for my $var (@$varlist) { my ($oid, $ifc, $result) = @$var; $res->{$dev}{$oid}{$ifc} = $result; } } # Count our queries, if this is the last device, quit SNMP::finish() if ++$$this_dev >= $num_dev; }, # Our variables passed to the anonymous subroutine $dev, \%results, \$this_device, $num_devices ] ); } SNMP::MainLoop(); # Execute queued bulkwalks return \%results; } </SNIP> The first oddity that I ran into was when I included more than one host in the %devices hash. Doing so caused the return value of the poll_devices subroutine to be null if I attempted to pass anything other than a scalar (never seen anything like that before). Using a hashref seems to work okay, though. The second oddity is when I try to poll more than ~25 devices using the poll_devices sub. When I do that, I get a segfault shortly after the subroutine returns (although I have time to do a little data shuffling beforehand, possibly the segfault is something percolating up from a process that the bulkwalk forked off). Both of these issues pop up using net-snmp version 5.2.1 and version 5.1.2 (both compiled from source on a RH FC3 box). Anyways, am I just doing something blatantly stupid in the above code, or is there something more sinister in the works? TIA, -Eric ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_ide95&alloc_id396&op=click _______________________________________________ Net-snmp-users mailing list Net-snmp-users@lists.sourceforge.net Please see the following page to unsubscribe or change other options: https://lists.sourceforge.net/lists/listinfo/net-snmp-users