I am trying write a script that will poll cisco gear for information regarding it's CDP neighbors.
I had pretty much completed the project using telnet to get the information I wanted when I realized it would be quicker and less intrusive to gather this info with SNMP.
I tracked down the appropriate oid and am using the Net::SNMP get_table method. It seems to be working, but I am getting output that looks like this:
HASH(0x82753ec)
What do I need to do to extract some meaningful information from this?
I have read the docs on the Net::SNMP module and am feeling very obtuse right now. I would love to see some actual examples of the get_table method if anyone has any existing code that uses it.
This is the pretty bare bones code I am using to test this method.
#!/usr/bin/perl -w
use Net::SNMP;
# requires a hostname and a community string as its arguments
($session,$error) = Net::SNMP->session(Hostname => $ARG[0], Community
+=> $ARGV[1]);
die "session error: $error" unless ($session);
#1.3.6.1.4.1.9.9.23.1.2.1.1 is the OID that the CDP info starts at
$result = $session->get_table("1.3.6.1.4.1.9.9.23.1.2.1.1");
die "request error: ".$session->error unless (defined $result);
print "$result \n";
$session->close;
Thanks in advance on any light you can shine on this. I do believe that my eyes will start bleeding if I stare at any more docs.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.