Try starting off with module Net::SNMP, to get single values from a remote IP, probably the method $session->get_request is your best bet.. it's pretty well documented in perldoc Net::SNMP.. However you probably have to put your community in the file.. if this is undesirable, you could use module Term::ReadKey to allow "safe" reading of the password from the command line..

As far as getting the IP addresses out of a file, if they are listed one IP Address per line with nothing else included in the file itself: just read the file, put the contents in an array, then loop your SNMP get operations for each item in the array roughly something like:
open IPFILE,'<',"/tmp/ipfile.txt"; my @ip_list = <IPFILE>; close IPFILE; foreach my $ip_in_list ( @ip_list ) { ... ($session, $error) = Net::SNMP->session( -hostname => $ip_in_list, ... => ..., .. all other options ...; ); $newval = $session->get_request( [-callback => sub {},] [-delay => $seconds,] [-contextengineid => $engine_id,] [-contextname => $name,] -varbindlist => \@oids, ); # now do something with the data found in $newval # use -callback to point to a subroutine where you put further operati +ons to be carried out on $newval }
The above is more or less straight from the doc, and your situation is probably more complicated than that, but maybe this helps get started?


In reply to Re^2: Reading IP from a file and SNMP by hsinclai
in thread Reading IP from a file and SNMP by theroninwins

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.