Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

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

I'm writing a script that will query a device via SNMP to check the
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

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


(SNMPWALK returns precisely "HOST-RESOURCES-MIB::hrSystemDate.0 =

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

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

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

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

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


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

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

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

my $systemdate = $hostdatestring->;

print $systemdate;

Site Timeline