My Environment:
I downloaded and installed net-snmp5.4.2.1-1.win32.exe from sourceforge (needed a binary for windows that would work on Perl v5.8.9). I followed the README instruction to install the Perl modules:
ppm remove NETSNMP
cd (install folder)\Perl
ppm install NetSNMP.ppd
Test the install:
net-snmp-perl-test.pl
Result:
Testing translateObj
********************
Test passed. Result: .1.3.6.1.2.1.1.1
I test that my perl module is installed correctly:
perl -MSNMP -e 1
Issue:
Right now I am just writing some basic code to get the number of interfaces, and then print that number. I am getting nothing returned when I call $session->get. Here is my code. I am passing in the ip and the community string.
use SNMP;
$ENV{'MIBS'} = 'ALL';
&SNMP::initMib();
$session = new SNMP::Session(DestHost => $ARGV[0], Community =>$A
+RGV[1]);
$numInts = $session->get('1.3.6.1.2.1.2.1.0');
print "Number of Interfaces: $numInts\n";
When I run my code, I get:
Number of Interfaces:
I have tried a bunch of other things, but can't get it to return any values. If I just go to my commandline and type:
snmpget -v1 -c <community string> <ip> 1.3.6.1.2.1.2.1.0
I get results back as expected.....
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.