[Nagiosplug-devel] bug? in perl Plugin::Range.pm
Ton Voon
ton.voon at altinity.com
Fri Feb 9 10:33:17 CET 2007
On 8 Feb 2007, at 23:21, Gavin Carr wrote:
> On Thu, Feb 08, 2007 at 09:27:43AM +0000, Ton Voon wrote:
>>
>> On 8 Feb 2007, at 07:32, Norman J Harman Jr. wrote:
>>
>>> $VERSION = "0.15";
>>>
>>> I'm fairly certain that the first if/else in check_range should be
>>> swapped.
>>>
>>> Correct code:
>>>
>>> sub check_range {
>>> ...
>>> if ($self->end_infinity == 0 && $self->start_infinity == 0) {
>>> if ($self->start <= $value && $value <= $self->end) {
>>> return $true;
>>> } else {
>>> return $false;
>>> ...
>>>
>>
>> Good news: the code is right. Bad news: the design is wrong.
>>
>> According to the developer guidelines (http://
>> nagiosplug.sourceforge.net/developer-guidelines.html), a range of
>> 5:10 will alert on 12, but not 7. This goes against "conventional"
>> thinking, where you would expect a range to alert inside.
>> Nagios::Plugin has been coded in accordance with the design.
>
> Blech - this is so broken, isn't it?
Yes. I can't even blame anyone about it as I helped set the design :(
>> There is a discussion re: new style range setting, to try and fix
>> this, but the thread has stalled (http://thread.gmane.org/
>> gmane.network.nagios.plugins.devel/4461). I plan on tackling this
>> when the other RFC re: plugins config files is completed.
>
> How are you thinking of doing this on the backend Ton? Do we want a
> flag on N::P::Range to designate whether a range is inclusive or
> exclusive, and support in N::P::Threshold for that?
>
> That might allow plugins to explicitly designate which way they want
> their ranges to be interpreted. I've got current plugins in the wild
> with inclusive ranges that I can't migrate to N::P::Range because of
> this.
I'm thinking there should be some "hidden" functions that calculate
ranges in the reverse order. This will need to be done in the C apis
too, as we move to a new threshold specification, since we have to
support the current syntax.
Thinking about it, there's two levels of public APIs: current and
deprecated. Feel free to add in one for calculating the ranges in the
inverted order, but mark as deprecated (though we may use internally).
Ton
http://www.altinity.com
T: +44 (0)870 787 9243
F: +44 (0)845 280 1725
Skype: tonvoon
More information about the Devel
mailing list