[Nagiosplug-devel] Incorrect MIB type?

Andreas Ericsson ae at op5.se
Wed Mar 25 11:29:33 CET 2009


Ton Voon wrote:
> Hi!
> 
> I received this email offlist about the nagiosmib. However, I'm not fluent with 
> SNMP MIBs, so does anyone else have an opinion if this is a safe change to make?
> 

>> Also from the description for the nHostNotifyNum OBJECT-TYPE ...
>>
>> "This identifies the current notification number for the service or host.
>>        The notification number increases by one (1) each time a new notification
>>        is sent out for a host or service (except for acknowledgements). The
>>        notification number is reset to 0 when the host or service recovers
>>        (after the recovery notification has gone out). Acknowledgements do not
>>        cause the notification number to increase."
>>
>> ... it's clear that Integer32 (signed integer) isn't the right type for 
>> nHostNotifyNum, and it should be an unsigned type, Gauge32. Or perhaps 
>> Unsigned32, but Gauge32 has the benefit of specifying the behaviour in the 
>> vanishly unlikely case of overflowing 32 bits (doesn't wrap).


It depends. Nagios uses unsigned long to determine the notification id. Using
Gauge32 is broken, since Nagios doesn't handle wrap-arounds (and with 4.3
billion ID's, I doubt anyone will get the same ID twice so close to each
other they'll react to it).

One problem is that unsigned long is different bitwidth on 64-bit and 32-bit
systems, but it should be safe to ignore that and just mask off the bottom
32 bits.

Making it Unsigned32 and masking with (id & 0xffffffff) is almost certainly
the correct way to go about it. If the processes surrounding mib updates is
overly tricky, it should be safe to leave it as-is and just use
(id & 0x7fffffff). That means we have to live with "only" having 2.1 billion
notification id's before overflowing though. I don't think it will matter
either way for any practical purposes though.

-- 
Andreas Ericsson                   andreas.ericsson at op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

Considering the successes of the wars on alcohol, poverty, drugs and
terror, I think we should give some serious thought to declaring war
on peace.




More information about the Devel mailing list