[Nagiosplug-devel] Best practice for thresholding

Richard Edward Horner rich at richhorner.com
Mon Jun 22 20:21:13 CEST 2009


Understood. Well, while I don't expect my opinion to count for a whole
lot, especially since I'm not developing Perl plugins, my thought on
patches is that they're always good to have on hand because then ppl
can choose whether or not they want to apply them and this whole open
source thing is about choice...I think :)

Rich(ard)

On Mon, Jun 22, 2009 at 6:14 PM, John Vincent<nagiosplug-devel at lusis.org> wrote:
> I've done something similar but in this case the plugin I'm using is
> already using the Nagios::Plugin perl module from CPAN. I guess I'm
> trying to determine what Ton or anyone else would consider a best
> practice in this case. Do I submit a patch to Threshold.pm for
> handling this scenario or do I do all the annoying work on the
> existing module?
>
>
> On Mon, Jun 22, 2009 at 1:33 PM, Richard Edward
> Horner<rich at richhorner.com> wrote:
>> I don't write plugins in Perl because I write all of them in BASH but
>> I wrote a single check_value() function that conforms to the threshold
>> and ranges spec and then I include it in all my scripts. If you're
>> working from a Perl module, I suppose you could write a similar
>> function and include it in the module and then just call it from every
>> script. Here's my relevant BASH code if you want to rewrite it in
>> Perl. I'm using 999999999 to represent infinity. You can find more
>> Nagios BASH code at:
>>
>> http://rhosts.net/nagios/
>>
>> function check_value {
>>        # if the range starts with an @, alert if value is inside the range,
>> otherwise alert if value is outside of range
>>        INSIDE=`echo "$1" | grep -c '^@'`
>>        RANGE=`echo "$1" | sed 's/^@//'`
>>
>>        # start is anything left of the colon or 0
>>        # end is anything right of the colon or the whole string if there's
>> no colon or infinity if there is a colon and nothing to the right of
>> it
>>
>>        # is there a colon?
>>        PARTS=`echo "$RANGE" | awk -F : '{ print NF }'`
>>        if [ $PARTS -gt 1 ] ; then
>>                START=${RANGE%%:*}
>>                END=${RANGE##*:}
>>        else
>>                START=0
>>                END=$RANGE
>>        fi
>>
>>        # 4. to specify negative infinity, use "~"
>>        if [ "$START" == "~" ] ; then
>>                START=-999999999
>>        fi
>>
>>        if [ -z "$END" ] ; then
>>                END=999999999
>>        fi
>>
>>        if [ $START -gt $END ] ; then
>>                echo "In threshold START:END, START must be less than or equal to END"
>>                range_help
>>        fi
>>
>>        # if the range starts with an @, alert if value is inside the range,
>> otherwise alert if value is outside of range
>>        # all ranges are inclusive of endpoints so we use less than or equal
>> on the inside and just less than on the outside
>>        if [ "$INSIDE" -gt 0 ] ; then
>>                if [ "$START" -le "$2" -a "$2" -le "$END" ] ; then
>>                        return 1
>>                fi
>>        else
>>                if [ "$2" -lt "$START" -o "$END" -lt "$2" ] ; then
>>                        return 1
>>                fi
>>        fi
>>
>>        return 0
>> }
>>
>> # check conditions - yes this is ugly, blame BASH. If you want to
>> blame me, please provide a cleaner way that is as fast or faster
>> check_value "$CRITICAL" "$VALUE"
>> if [ $? -gt 0 ] ; then
>>        STATE=$STATE_CRITICAL
>> else
>>        check_value "$WARNING" "$VALUE"
>>        if [ $? -gt 0 ] ; then
>>                STATE=$STATE_WARNING
>>        else
>>                STATE=$STATE_OK
>>        fi
>> fi
>>
>> Rich(ard)
>>
>> On Mon, Jun 22, 2009 at 5:22 PM, John Vincent<nagiosplug-devel at lusis.org> wrote:
>>> So I've been attempting to use check_memcached and in the process was
>>> cleaning up some invalid perfdata output. I also noticed that the
>>> thresholding is somewhat broken. This plugin, like many database
>>> plugins, has a hit ratio metric. Hit ratio metrics make the most sense
>>> when approcahed from a "warning/critical below X%" (at least in my
>>> mind). So if my hit ratio drops below 75%, I want a warning and if it
>>> goes below 50% I want a critical.
>>>
>>> What's the best way to handle this with Nagios::Plugin? Should the
>>> logic be done in the script or should it be done in the module itself?
>>>
>>> John E. Vincent
>>>
>>> ------------------------------------------------------------------------------
>>> Are you an open source citizen? Join us for the Open Source Bridge conference!
>>> Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
>>> Need another reason to go? 24-hour hacker lounge. Register today!
>>> http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
>>> _______________________________________________________
>>> Nagios Plugin Development Mailing List Nagiosplug-devel at lists.sourceforge.net
>>> Unsubscribe at https://lists.sourceforge.net/lists/listinfo/nagiosplug-devel
>>> ::: Please include plugins version (-v) and OS when reporting any issue.
>>> ::: Messages without supporting info will risk being sent to /dev/null
>>>
>>
>>
>>
>> --
>> Richard Edward Horner
>> Engineer / Composer / Electric Guitar Virtuoso
>> richhorner.com | rhosts.net | sabayonlinux.org
>>
>
> ------------------------------------------------------------------------------
> Are you an open source citizen? Join us for the Open Source Bridge conference!
> Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
> Need another reason to go? 24-hour hacker lounge. Register today!
> http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
> _______________________________________________________
> Nagios Plugin Development Mailing List Nagiosplug-devel at lists.sourceforge.net
> Unsubscribe at https://lists.sourceforge.net/lists/listinfo/nagiosplug-devel
> ::: Please include plugins version (-v) and OS when reporting any issue.
> ::: Messages without supporting info will risk being sent to /dev/null



-- 
Richard Edward Horner
Engineer / Composer / Electric Guitar Virtuoso
richhorner.com | rhosts.net | sabayonlinux.org




More information about the Devel mailing list