[Nut-upsdev] snmp-ups hacking

Niklas Edmundsson nikke at acc.umu.se
Sat Jan 21 23:03:04 UTC 2006


Hi all!

I'm wondering if there's anyone doing any hacking on the snmp-ups 
driver at the moment.

I've started looking at implementing 3phase-support, and this 
uncovered some rather unpleasant stuff in the snmp-ups driver that I 
really need to fix in order to get things sane.

Those of you that's allergic to SNMP might want to stop reading now, 
this is rather icky ;)

Currently, the snmp-ups driver works this way: All SNMP values are 
obtained by ultimately calling snmp_pdu_create(SNMP_MSG_GETNEXT), 
which means that if you enter an incomplete Object ID (OID) the SNMP 
library will "help" you and recurse down the tree until it finds 
something suitable. Obviously, the library might recurse too far and 
return something completely different. In order to protect from this, 
the function oid_compare() is present to filter out those cases. To 
make things worse, it seems to recurse onto next item if you provide 
it with a complete OID.

As you might have guessed, this is not exactly foolproof. For example, 
instead of returning the number of output phases in our APC Silcon UPS 
it recurses a bit and decides that I should get the phase rotation 
flag instead. Not exactly helpful.

My fix for this would be to use SNMP_MSG_GET instead and fix the OID 
table to include the correct OID:s instead. This would remove all 
recursion, thus removing the oid_compare()-kludge and resulting in a 
more stable behaviour.

The problem is that I only have an APC UPS to talk SNMP to, so I can't 
fix/verify the OID:s for the other supported SNMP (in)variants. 
However, I think that fixing this might be a large step towards 
getting this driver out of the "experimental" department.

Have I missed something that makes fixing this a bad idea?


/Nikke - got the hang of snmpwalk, snmpget and snmptranslate in the end
-- 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  Niklas Edmundsson, Admin @ {acc,hpc2n}.umu.se      |     nikke at acc.umu.se
---------------------------------------------------------------------------
  Fight the Greenhouse Effect:  PLANT TREES!!!
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=



More information about the Nut-upsdev mailing list