Using DateAndTime from Perl SNMP.pm

Kevin Broadey <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
I’m new to Net-SNMP, and I’m currently writing a Perl traphandler using NetSNMP::TrapReceiver.pm and SNMP.pm on an Ubuntu 14.04 LTS platform.

I’ve created a MIB Module definition with a variable that has DateAndTime syntax, and I’ve put it in the right place to be picked up by Net-SNMP.  Running snmptrapd -Le -f to get the daemon to spit its diagnostic output to a terminal, and then using snmptrap to inject a test trap message, I can see that the snmp diagnostics pick up both the name and type of my variable - I see "systemStsDateAndTime.0 2014-11-26,12:22:33.4,+1:0” in the output.  So I believe I’ve got the low-level stuff right.

The problem comes when I try to use my MIB in my /usr/share/snmp/traphandler/traphandler.pl file (which I load through a “do perl” statement in my /etc/snmp/snmptrapd.conf file).  I use SNMP::loadModules to load the MIB file, so my perl script is able to translate the numeric OIDs into labels, and it knows all my variables types, but when I try to load or extract a DateAndTime value nothing is converting the octet string to anything more Perl-like such as a string or a localtime/gmtime value.  I’m having to use pack/unpack with a format string of “nC6aC2” to grab the fields as an array, which seems to be a bit low-level.

So have I missed something and there’s an easier way of using DateAndTime values than pack/unpack?

Thanks for your help!
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.