http://www.perlmonks.org?node_id=390857

theroninwins has asked for the wisdom of the Perl Monks concerning the following question:

Ok here is a question that really drives me insane... I am really getting aggressiv over the last 3 days... I need the file

VarList.pm

since I need SNMP to work correctly.
It is all there.
Now on the net they say it is part of SNMP4.2 well that doesn't install under Windows XP (yes I have to work with XP for this) and CPAN also says that it is part of net-snmp (former ucd-snmp) but here the prob is that that first didn't install because it required the ucd-snmp which since i didn't need it in 1999 I didn't have and when i got it and it got installed it was NOT part of it. So now I searched again and found out that it is may be part of SNMP-Simple on CPAN but ... hey wrong again nothing there. By this time I have found script for everything in the world concerning snmp but not that file. The funny thing is though that every script I have uses it but you can't get that file... great isn't it. I am really feeling hell on this.
This all happend in 3 days on which I searched for 7 hours per days.
I also tried SNMP::Multi and no it is not part of it :-).

Replies are listed 'Best First'.
Re: Where can I get SNMP::VarList
by davorg (Chancellor) on Sep 14, 2004 at 15:31 UTC

    Looks like SNMP::VarList isn't a separate file, but is a package that is contained within SNMP.pm from the SNMP distribution.

    If you explain what problems you're having installing the package on WinXP, then someone her might be able to help you.

    --
    <http://www.dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

      Here is the problem that i think could be the fault.
      When i try to install the snmp 4.2 package it asks me where my ucd-snmp include files are, and it suggests that they are on \usr\local\include and then it asks me where the ucd-snmp libs are suggesting they are on \usr\lib. I changed those paths to what is right but the output is :
      Where are the ucd-snmp include files? [\usr\local\include] c:/usr/incl +ude Where is the ucd-snmp library installed? [\usr\lib] c:/usr/lib WARNING: MAN3PODS takes a hash reference not a string/number. Please inform the author. Note (probably harmless): No library found for -llibsnmp Note (probably harmless): No library found for oldnames.lib Note (probably harmless): No library found for kernel32.lib Note (probably harmless): No library found for user32.lib Note (probably harmless): No library found for gdi32.lib Note (probably harmless): No library found for winspool.lib Note (probably harmless): No library found for comdlg32.lib Note (probably harmless): No library found for advapi32.lib Note (probably harmless): No library found for shell32.lib Note (probably harmless): No library found for ole32.lib Note (probably harmless): No library found for oleaut32.lib Note (probably harmless): No library found for netapi32.lib Note (probably harmless): No library found for uuid.lib Note (probably harmless): No library found for wsock32.lib Note (probably harmless): No library found for mpr.lib Note (probably harmless): No library found for winmm.lib Note (probably harmless): No library found for version.lib Note (probably harmless): No library found for odbc32.lib Note (probably harmless): No library found for odbccp32.lib Note (probably harmless): No library found for msvcrt.lib Can't use string ("SNMP") as a HASH ref while "strict refs" in use at +C:/Perl/li b/ExtUtils/MM_Unix.pm line 503.

      well I never installed ucd-snmp because it is now called net-snmp and that installs nicely, but aas you can see above it doesn't really work although net-snmp still calls it folders ucd-snmp.
      Any idea what it might be??
Re: Where can I get SNMP::VarList
by Kzin (Acolyte) on Sep 14, 2004 at 16:38 UTC
    Something that worked for me when I became frustrated with CPAN was actually doing a fresh install. My problem was that I actually deleted a file and (due to user error on my behalf for sure) it would not reinstall it on its own.

    I took the opportunity to get the latest version of Perl and the latest NET packages that I needed, and this cleared up my issue.

    I dont know if this could help you but it is an option. (Note that I am fairly new to Perl, so I am sure there may be a less dramatic way of clearing this up)
      ...it would not reinstall it on its own
      You must be in Russia, where software boss you! You must boss software.
Re: Where can I get SNMP::VarList
by theroninwins (Friar) on Sep 17, 2004 at 09:39 UTC
    Ok I decided that I just have to work with Var_bind_list.
    #!/usr/bin/perl -w use Net::SNMP qw(oid_lex_sort oid_base_match SNMP_VERSION_1 DEBUG_ALL) +; use strict; use Getopt::Std; use warnings; use diagnostics; use XML::Simple; use Data::Dumper; use vars qw($ip $name @serials @parts $response $response2 @final1 @fi +nal2); #open xml file my $xmlfile = $ARGV[0]; my $ref = eval { XMLin($xmlfile) }; #erase or creat the ipfile and the namefile open ERASER, ">ipfile.txt"; close ERASER; open ERASER, ">namefile.txt"; close ERASER; #see if open worked if ($@) { print "XML Read ERROR"; } else { #go to IPAddress tag and read infos into file foreach my $itemip (@{$ref->{Layer2Details}->{Device}}) { my @ipliste = $itemip->{IPAddress}; my @sorted = @ipliste; open OUTIP, ">>ipfile.txt"; print OUTIP @sorted, "\n"; close OUTIP; } #go to DeviceName tag and read infos into file foreach my $itemname (@{$ref->{Layer2Details}->{Device}}) { my @nameliste = $itemname->{DeviceName}; my @sortedname = @nameliste; open OUTNAME, ">>namefile.txt"; print OUTNAME @sortedname, "\n"; close OUTNAME; } } #open ipfile open IPFILE, "ipfile2.txt" or die "Can't get IPs - $!\n"; open NAMES, "namefile2.txt" or die "Can't get IPs - $!\n"; open ERASER, ">finallist.txt"; close ERASER; + #Sets knots und community my $community = 'public'; my $ifSer = '.1.3.6.1.2.1.47.1.1.1.1.11'; my $ifPart = '.1.3.6.1.2.1.47.1.1.1.1.13'; while ( $ip = <IPFILE>, $name = <NAMES> ) { chomp $ip; chomp $name; $name =~ s/\.bc\.de\.bic$//; print "Got: $ip\n"; + #open session my ( $s, $e ) = Net::SNMP->session( -hostname => $ip, -community => $community, -port => 161 ); if (!defined($s)) { print ("Falsch nix is!"); my @args = ( -varbindlist => [$ifSer] ); my @args2 = ( -varbindlist => [$ifPart] ); if ($s->version == SNMP_VERSION_1) { while (defined($s->get_next_request(@args))) { $_ = (keys(%{$s->var_bind_list}))[0]; if (!oid_base_match($ifSer, $_)) { last; } $response=($s->var_bind_list->{$_}); @final1 = $response; @args = (-varbindlist => [$_]); #print @final1; } while (defined($s->get_next_request(@args2))) { $_ = (keys(%{$s->var_bind_list}))[0]; if (!oid_base_match($ifPart, $_)) { last; } $response2 = ($s->var_bind_list->{$_}); @final2 = $response2; @args2 = (-varbindlist => [$_]); } } else { push(@args, -maxrepetitions => 25); outer: while (defined($s->get_bulk_request(@args))) { my @oids = oid_lex_sort(keys(%{$s->var_bind_list})); foreach (@oids) { if (!oid_base_match($ifSer, $_)) { last outer; } #print("%s => %s\n", $_, $s->var_bind_list->{$_}); # Make sure we have not hit the end of the MIB if ($s->var_bind_list->{$_} eq 'endOfMibView') { l +ast outer; } } # Get the last OBJECT IDENTIFIER in the returned list @args = (-maxrepetitions => 25, -varbindlist => [pop(@oid +s)]); } } #@final2 = grep { $_ ne "" } $response2; open OUTPUT, ">>finallist.txt"; for my $i (0 .. $#final1) { print "$ip;$name;$final1[$i];$final2[ +$i]\n" } close OUTPUT; # Let the user know about any errors #if ($s->error() ne '') { # _exit($s->error()); #} # Close the session $s->close(); } exit 0;
    Problem:
    Why doesn't the print at the end work?
    @final1 and @final2 only print when i print them in their block (in the source commented out #print final1).
    any idea????