vlad3848 has asked for the wisdom of the Perl Monks concerning the following question:
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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Perl Net::SNMP returns 1 instead of the desired outcome
by kcott (Archbishop) on Oct 25, 2013 at 08:03 UTC | |
Re: Perl Net::SNMP returns 1 instead of the desired outcome
by VinsWorldcom (Prior) on Oct 25, 2013 at 13:05 UTC | |
Re: Perl Net::SNMP returns 1 instead of the desired outcome
by Khen1950fx (Canon) on Oct 25, 2013 at 19:18 UTC |