Hello. I have a small script I'm writing that will simply query for the hostname of a Cisco switch. This is my code:
#!/usr/bin/perl use Net::SNMP; my $host = "192.168.0.49"; my $community = "eX0gyN37"; my ($snmp,$snmperror) = Net::SNMP->session( -hostname => $host, -community => $community ); # hostname OID (this line doesnt work) # my $OID = "1.3.6.1.4.1.9.2.1.3"; # number of interfaces OID (this line works) my $OID = "1.3.6.1.2.1.2.1.0"; my $result = $snmp->get_request ( $OID ) or die "FAIL: $! \n"; print $result->{$OID} . "\n";
As you can see, I'm also using an OID that will display the number of interfaces on the switch. When I run the script as is, it works, and the number "53" is output (and is correct). However, if I comment the working line, and uncomment the other line, the script fails with the message:

FAIL: Transport endpoint is not connected

I am sure that the nonworking OID is correct, as you can see from the following result on the command line.

$ snmpwalk -v2c -c eX0gyN37 192.168.0.49 1.3.6.1.2.1.2.1.0 IF-MIB::ifNumber.0 = INTEGER: 53 $ snmpwalk -v2c -c eX0gyN37 192.168.0.49 1.3.6.1.4.1.9.2.1.3 SNMPv2-SMI::enterprises.9.2.1.3.0 = STRING: "sw-studentcenter-basement +-1"
What am I doing wrong? Why does the script work for one OID and not the other? The one and only difference I can see immediately is that the non-working OID has a "STRING" result on the command line, as opposed to the working "INTEGER" OID. Any suggestions? Thanks!

In reply to SNMP Error using Net::SNMP - Transport endpoint is not connected by IPv6Freely

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.