I've found a nice easy way to parse the date/time.  I wanted to avoid depending 
on SSH checks because they don't work very well against systems which I can't 
easily SSH into and expect a Unix-like environment (eg.  Windows, embedded 
systems), and while I don't have a problem with parsing strings in Perl I'd be 
much happier if I could avoid date parsing because it gets very complicated 
very quickly.

I'll record the solution I used here in case anyone else ever needs something 
similar.

I've written a bash script which gets the date using snmpget and the OID I 
described earlier.  Rather than try and parse this string, I simply run it 
through sed to replace commas with spaces.  Once this is done, the string can 
be passed into date(1)  to turn it into seconds since the epoch.  This 
certainly works with GNU date 5.97, don't know about other implementations.

Run the SNMP query and turn the date into seconds since the epoch twice - once 
against a known-good host once against one you're querying.  If there's any 
dramatic difference (say, more than a second or two) then something isn't 
properly in sync.  And because it only needs an SNMP agent which supports the 
HOST-RESOURCES mib running on the remote host, it should work against a wide 
range of systems.




-------------------- m2f --------------------

Read this topic online here:
http://community.zenoss.com/forums/viewtopic.php?p=16845#16845

-------------------- m2f --------------------



_______________________________________________
zenoss-users mailing list
[email protected]
http://lists.zenoss.org/mailman/listinfo/zenoss-users

Reply via email to