Re: sysUpTimeInstance vs sysUpTime.0

Peter Hicks <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
Mike Ayers wrote:

>> From: Peter Hicks [mailto:[email protected]] 
>> Sent: Thursday, May 07, 2009 5:53 AM
> 
>> DISMAN-EVENT-MIB defines sysUpTime.0 as sysUpTimeInstance, 
>> which appears to confuse SNMP.pm, returning a VarBind without
 >> an instance...
 >>
 >> [snip]
 >>
>> Is this intended behaviour?  How should I work around it in an 
>> application which assumes that requesting OID 'sysUpTime' and 
>> instance 0 will return the same OID and instance in the returned VarBind?
> 
> Use numerical OIDs - they will always match.

Ick, that's horrendously ugly and makes code very difficult to read.

What I did was to check for an instance in the returned VarBind, and if 
there's no instance, convert the OID to numeric format, lop off the last 
element (in this case, "0") and use that as the instance, then convert 
the OID back to text.

Works like a treat and I save my full-stop key and the sanity of anyone 
else looking at my code :-)


Peter

-- 
Peter Hicks | e: [email protected] | g: 0x5DA31330 | w: www.poggs.com

   A: Because it destroys the flow of the conversation
   Q: Why is top-posting bad?

------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image 
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
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.