net::snmp



I'm having bother with the net::snmp module.

I'm writing a script that will query a device via SNMP to check the
system
time (it;s a nagios check to make sure that devices are polling NTP
properly and not falling out of sync).

Unfortunately, the get request is returning in format I don't recognise
(possibly because of characters.

I'm doing a "get_request" for HOST-RESOURCES-MIB::hrSystemDate.0
(1.3.6.1.2.1.25.6.3.1.5.1).

A snmpwalk indicates I should be getting returned is something like:

2006-11-4,18:23:55.8

(SNMPWALK returns precisely "HOST-RESOURCES-MIB::hrSystemDate.0 =
STRING:2006-11-4,18:23:55.8"

What the get_request is giving me is "0x07d4010705181e00"

Can anyone shed any light on where I'm going wrong?

My code is:

use strict;
use Net::SNMP;

#
# Gather hostname and community string from call parameter
#

my $hostname = $ARGV[0]; # target host to be checked
my $community = $ARGV[1]; # SNMP Community string for exchange

#
# Define the current date
#

my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime
time;

#
# OID of System Time: HOST-RESOURCES-MIB::hrSystemDate.0

my $snmpstring = '1.3.6.1.2.1.25.6.3.1.5.1';
#my $snmpstring = '1.3.6.1.2.1.25.1';
#my $datestring = $snmpstring . ".2";

my ($session, $error) = Net::SNMP->session( -hostname => $hostname,
-community =>
$community,
-timeout => 5);

my $hostdatestring = $session->get_request("$snmpstring");

$session->close;

#
# Error out and set warning status in nagios if no result back from
SNMP
#

if (!defined($hostdatestring)) {
printf("ERROR: No result - $session->error, $error");
$session->close;
exit 1;
}

#print "datestring -> $datestring\n";

my $systemdate = $hostdatestring->{$snmpstring};

print $systemdate;

.



Relevant Pages

  • RE: Snmp daemon doesnt work but loaded ...
    ... Snmp daemon doesn't work but loaded ... ... i'd like to use and learn more about SNMP protocole. ... very commonly an invalid community string. ... lot for nagios, it works great. ...
    (Fedora)
  • RE: DNS and SMTP
    ... If you know the READ community string, all you can do is read SNMP OIDs ... to facilitate one-on-one interaction with one of our expert instructors. ... Attend a course taught by an expert instructor with years of in-the-field ...
    (Security-Basics)
  • RE: Routes that are susceptible to SNMP
    ... read-write by using "private" as a community string? ... By "how dangerous this is," do you mean the fact that snmp is available to ... > This list is provided by the SecurityFocus Security ...
    (Pen-Test)
  • SUMMARY: SNMP question
    ... Thank you all for the quick and very informative responses. ... What you sort of did was prevent any public read access of any SNMP ... community string by default, this is an easy thing for a cracker to check. ... query the SNMP daemon, but the risk is much lower. ...
    (Tru64-UNIX-Managers)
  • [Full-disclosure] Exploring the UNKNOWN: Scanning the Internet via SNMP!
    ... Scanning the Internet via SNMP! ... write community string is identified or cracked. ... Dynamic DNS credentials disclosure on ZyXEL Prestige routers via ...
    (Full-Disclosure)