Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Hello Monks,

I am writing a script that will check date/time on a network device. I am using Net::SNMP module to walk the OID for the current time on the device and then will compare it against current time on a server..However, whenever i walk the switch for the time, the return value comes back as 1 instead of the actual value. I can manually walk the switch, or use system call to invoke snmpwalk, but since i need to do this on a couple of thousand of devices i am really trying to stick with SNMP module. Any ideas of what i am doing wrong?

# /usr/bin/perl use warnings; use strict; use Net::SNMP; use Data::Dumper; my $oid= '1.3.6.1.4.1.1588.2.1.1.1.1.1'; my $host="host1.testdoman.com"; my $community='test'; my ($session, $error) = Net::SNMP->session( -hostname => $host, -community =>$community, -nonblocking => 1, ); my $result = $session->get_request(-varbindlist => [ $oid ],); if (!defined $result) { $error = $session->error(); print "GET_REQUEST ERROR: $error\n"; $session->close(); exit(1); } print Dumper $result; $session->close; exit(0);

Just to illustrate what output i am expecting. The following code invokes snmpwalk utility and produces the desired output:

# /usr/bin/perl use warnings; use strict; my $community='test'; my $host= "host1.testdoman.com"; my $Time = `snmpwalk -v1 -c $community $host 1.3.6.1.4.1.1588.2.1.1.1 +.1.1`; print $Time;

SNMPv2-SMI::enterprises.1588.2.1.1.1.1.1.0 = STRING: "Fri Oct 25 07:23:33 2013 "

However, when i try to use the Net:SNMP module it produces output $VAR1 = 1;

Any help would be appreciated!!

Thanks in advance


In reply to Perl Net::SNMP returns 1 instead of the desired outcome by vlad3848

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-04-19 07:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found