hi folks,

i'm not sure if this is a comp.perl.lang.misc question or net-snmp SNMP.pm question ...

the first thing i don't understand is why the first $val, the one for 140.107.18.5, has the contents of %esx screwed into it ... this doesn't make sense to me. the output of Data::Dumper for the second $val, the one for 140.107.22.5, now that makes sense to me.

and the second thing i don't understand is why Perl bombs with 'Use of freed value in iteration' ... i don't see where i'm modifying the contents of %esx in my loop.

though, perhaps, if i understood the first one, i might then understand the second one.


vishnu> cat test #!/opt/vdops/bin/perl

use strict;
use warnings;
use Data::Dumper;
use SNMP;

my $obj = "sysDescr";
my $read = "public";
my ($sess, $val, $vb);

my %esx = (     "140.107.22.5" => "b2-esx",
                "140.107.16.5" => "a1-esx",
                "140.107.18.5" => "a2-esx",
                "140.107.20.5" => "a3-esx",
           );

for my $addr (keys %esx) {
  print "Processing $addr\n";
  $sess = new SNMP::Session (     Community     =>  $read,
                                  DestHost      =>  $addr,
                             );
  $vb = new SNMP::Varbind([$obj]);
  $val = $sess->bulkwalk('0', '10000', $vb);
  print Dumper($val);
}
vishnu>./test
Processing 140.107.18.5
$VAR1 = [
          '140.107.18.5',
          '140.107.22.5',
          '140.107.20.5',
          '140.107.16.5',
          bless( [
                   bless( [
                            'sysDescr',
                            '0',
                            'Cisco Systems, Inc. WS-C4006
Cisco Catalyst Operating System Software, Version 7.6(7)
Copyright (c) 1995-2004 by Cisco Systems, Inc.
',
                            'OCTETSTR'
                          ], 'SNMP::Varbind' )
                 ], 'SNMP::VarList' )
        ];
Processing 140.107.22.5
$VAR1 = [
          bless( [
                   bless( [
                            'sysDescr',
                            '0',
                            'Cisco Systems, Inc. WS-C4006
Cisco Catalyst Operating System Software, Version 7.6(7)
Copyright (c) 1995-2004 by Cisco Systems, Inc.
',
                            'OCTETSTR'
                          ], 'SNMP::Varbind' )
                 ], 'SNMP::VarList' )
        ];
Use of freed value in iteration at ./test line 25.
vishnu>


Notes: -line 25 is the "print Dumper($val);" line

-if i remove line 25, then the script bombs with:
"Use of freed value in iteration at ./test line 24."

-naturally, this isn't my real code. in my real code, i'm performing a bulkwalk on ifName ... but that produces lots of output, so i'm offering this simplified version.

-perl 5.8.5, net-snmp-5.0.9


insights appreciated.


--sk

stuart kendrick
fhcrc



-------------------------------------------------------
This SF.Net email is sponsored by OSTG. Have you noticed the changes on
Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now,
one more big change to announce. We are now OSTG- Open Source Technology
Group. Come see the changes on the new OSTG site. www.ostg.com
_______________________________________________
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

Reply via email to