Monks
I'm trying to cvt a cmd line snmp call like this:

/usr/bin/snmpget -Oq 1.2.3.4 passwd interfaces.ifTable.ifEntry.ifOutOctets.6

to a Perl Net::SNMP cmd as part of a Perl script.
I tried the following, based on the example from the relevant CPAN module page:
#!/usr/bin/perl -w use strict; use Net::SNMP; my ($session, $error) = Net::SNMP->session( -hostname => shift || '1.2.3.4', -community => shift || 'passwd', -port => shift || 6 ); if (!defined($session)) { printf("Session ERROR: %s.\n", $error); exit 1; } #my $octets_out = '1.3.6.1.2.1.1.3.0'; my $octets_out = 'interfaces.ifTable.ifEntry.ifOutOctets'; my $result = $session->get_request( -varbindlist => [$octets_out] ); if (!defined($result)) { printf("get_req ERROR: %s.\n", $session->error); $session->close; exit 1; } printf("octets_out for host '%s' is %s\n", $session->hostname, $result->{$octets_out} ); $session->close;
and got the following result:

get_req ERROR: Expected OBJECT IDENTIFIER in dotted notation.

Can anybody help me out, bearing in mind that I've never used SNMP before?
(In both examples I've obscured the ip address + communitystring)
Thx
Chris

In reply to Net::SNMP get_request problem by chrism01

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.