Page 1 of 1

Negate command with multiple results

Posted: Tue Nov 06, 2012 5:02 am
by gshergill
Hi Nagios Community,

I've realised the negate command can be used for monitoring fan speed (when it's below a certain value you want a critical error).

I'm using the munin plugin along with negate.

However, I seem to have ran into a little snag.

The munin plugin returns results for fans 1 through 6, but the negate command only displays fan 6's value.

I guess my question is, does negate only display a single result? Or does it only check a single result.
If it is checking all the values for fans 1 to 6 but only displays 6, that's ok. But if it only checks 6, that is of course a problem.

It may be worth nothing that fan 6 has the lowest of the values.

The obvious solution here is to create one service per a fan, but to be honest I'm not entirely sure on implementing that, considering I wish to implement a similar idea to temperature (which has 7 temperatures being displayed)

Thank you again.

Kind Regards,

Gary Shergill

EDIT: Adding fan10 back to the command (which has constant value 0) does not create a critical error, and it continues to display fan6 as OK. In addition, removing fan6 displays fan5.

EDIT: Current setup is warning value 747 and critical value 4000.
If value is between 0 and 747 - CRITICAL.
If value is between 747 and 4000 - OK
If value is above 4000 - CRITICAL

Fan values are;

Code: Select all

fan1: 3524.2 fan2: 3514.8 fan3: 3497.2 fan4: 3590.2 fan5: 2045.1 fan6: 1432.6 
Setting warning up from 747 to 4000 causes CRITICAL with all fans displayed, as expected.
Setting warning up from 747 to 2500 causes OK and displays fan4 + the value, not as expected.

It appears unless all 6 are above/below the critical/warning values, it will stay as OK.

Is this a limitation? Or not intended?

Re: Negate command with multiple results

Posted: Tue Nov 06, 2012 2:18 pm
by scottwilkerson
I'm not familiar with fan plugin you are referring to, but many plugins are written to bubble the critical to the top.

So if one is critical then the whole check is critical

Re: Negate command with multiple results

Posted: Wed Nov 07, 2012 4:31 am
by gshergill
Hi scottwilkerson,

This is check_munin_rrd.pl.

Without the "negate" command, if one value is past warning/critical then it throws the corresponding status.

It is just when I use "negate" that it requires all values above/below the threshold before the status is changed.

I'm not entirely sure what you mean by "bubble the critical to the top".

Thank you.

Kind Regards,

Gary Shergill

Re: Negate command with multiple results

Posted: Thu Nov 08, 2012 8:26 am
by scottwilkerson
Can you list the full command you are using including the negate?

I just can't wrap my head around what it is doing and whay the desired result is.

With the negate command it should change what ever the final result is of the check_munin_rrd.pl plugin.

ie, OK should become CRITICAL or CRITICAL would become OK

Re: Negate command with multiple results

Posted: Thu Nov 08, 2012 9:43 am
by gshergill
Hi scottwilkerson,

The negate command;

Code: Select all

define command {
       command_name                              negate_above_below
       command_line                             $USER1$/negate -o CRITICAL -w OK -c CRITICAL -u UNKNOWN $ARG1$
}
The service added is;

Code: Select all

define service {
        host_name                       hostname
        service_description             sensors_fans1
        use                             generic-service
        display_name                    sensors_fans1
        check_command                   negate_above_below!/usr/local/nagios/libexec/check_munin_rrd.pl -H $HOSTALIAS$ -d gltd.local -M sensors_fan -w 750 -c 4500 -i fan7 -i fan8 -i fan9
        notifications_enabled           0
        register                        1
        }
The check_munin_rrd service for sensors_fan creates the following output (STATUS: OK);

Code: Select all

fan1: 3543.0 fan2: 3479.0 fan3: 3515.0 fan4: 3618.2 fan5: 2056.8 fan6: 1515.2 
With the negate command (STATUS: OK);

Code: Select all

fan6 value 1515.2, is above warning treshold 750
The hope was this;

Shows all 6 fan values if all 6 are OK
-> OK means they are above the WARNING value, below the CRITICAL value
-> In this case, above 750, below 4500

If one value falls outside of this range, show CRITICAL
-> Change to STATUS: CRITICAL, and display the fan number and the value it has

What happens is;

Shows the lowest value above the WARNING range only with STATUS: OK
-> In this case, fan6 is the lowest

If one value falls outside the range, shows the next lowest value above WARNING, still with STATUS: OK

If all values fall outside the range, shows STATUS: CRITICAL
-> Displays all 6 fans and their values

Hope this makes it clear.

Thank you.

Kind Regards,

Gary Shergill

Re: Negate command with multiple results

Posted: Thu Nov 08, 2012 11:49 am
by scottwilkerson
this isn't going to be possible because of what check_munin_rrd.pl returns, I had a look at the code and it only outputs $response_text which is the

Code: Select all

fan1: 3543.0 fan2: 3479.0 fan3: 3515.0 fan4: 3618.2 fan5: 2056.8 fan6: 1515.2 
If the response of this plugin is OK
clip from check_munin_rrd.pl

Code: Select all

if ($status eq 1) {
       print "$problem_on_name value $problem_value, is above warning treshold $opt_w\n";
       $status = $ERRORS{"WARNING"};

} elsif ($status eq 2) {
       print "$problem_on_name value $problem_value,  is above critical treshold $opt_c\n";
       $status = $ERRORS{"CRITICAL"};

} else {
       print "$response_text  \n";
       $status = $ERRORS{"OK"};
}
So, adding the negate plugin won't be able to change this, you would need to change what check_munin_rrd.pl returns

Re: Negate command with multiple results

Posted: Thu Nov 08, 2012 11:58 am
by gshergill
Hi scottwilkerson,

Thanks for the reply, I really appreciate you checking the check_munin_rrd.pl plugin for me.

I'll have a look at editing some of this then and see what happens, maybe adding the response text for the WARNING will work (so will need a separate plugin with edit for fans).

Will get back to you if it works, otherwise I'll just add a new service definition for each fan.

Thank you again.

Kind Regards,

Gary Shergill

Re: Negate command with multiple results

Posted: Thu Nov 08, 2012 12:45 pm
by scottwilkerson
gshergill wrote:Will get back to you if it works, otherwise I'll just add a new service definition for each fan.
That was going to be my other suggestion...

Re: Negate command with multiple results

Posted: Mon Nov 12, 2012 4:48 am
by gshergill
Hi scottwilkerson,

I think I'll just define a different service per fan.

Thank you for the help.

Kind Regards,

Gary Shergill