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

I am picking up Net::SNMP and have a simple script that worked fine while VPN'd in to work from home. Then I come in this morning (having made zero changes) and now I get the error that the host isn't responding (but I can ping it). I checked my firewall, and it's not blocking the traffic. I've seen posts on the 'net where people had to modify *nix config files, but I'm on Windoze using ActivePerl. The latest version of Net::SNMP that was available is what I'm using (6.0). Any ideas? Code below:

#!c:/perl/bin/perl use strict; use warnings; use Net::SNMP; my $OID = ''; #my $OID = ''; my ($session, $error) = Net::SNMP->session( -hostname => '', -version => 'snmpv2c', -community => 'private' ); if (!defined $session) { printf "ERROR: %s.\n", $error; exit 1; } my $result = $session->get_request(-varbindlist => [ $OID ],); #my $result = $session->get_bulk_request(-varbindlist => [ $OID ],); if (!defined $result) { printf "ERROR: %s.\n", $session->error(); $session->close(); exit 1; } print "$result->{$OID}\n"; foreach my $key ( sort keys %$result ) { print "$key => $$result{$key}\n"; } $session->close();

Replies are listed 'Best First'.
Re: Net::SNMP Query Returns Error: No response from remote host
by Khen1950fx (Canon) on Jul 30, 2010 at 21:58 UTC
    Try adding debugging. For example:
    #!/usr/bin/perl use strict; use warnings; use Data::Dump::Streamer; use Net::SNMP qw(DEBUG_ALL SNMP_TRAP_PORT); my $OID = ''; my ( $session, $error ) = Net::SNMP->session( -hostname => shift || 'localhost', -community => shift || 'private', -version => 'snmpv2c', -port => SNMP_TRAP_PORT, -nonblocking => 1, -debug => DEBUG_ALL, ); if ( !defined $session ) { printf "ERROR: %s.\n", $error; exit 1; } my $result = $session->get_request( -varbindlist => [$OID], ); if ( !defined $result ) { printf "ERROR: %s.\n", $session->error(); $session->close(); exit 1; } $session->close(); exit 0;
      Khen -
      Thanks! I'll give that a try.