Page 1 of 1

Gauge Bugs

Posted: Wed Oct 24, 2018 8:39 am
by gzaloprgm
Hi. I've found a couple of bugs regarding perfgraph gauges (and their dashlets):

BUG: If a perfdata variable value is 0, and no thresholds and min/max is defined, the gauge doesn't show. For instance, if a check returns
Val1=0 Val2=0;1;2 Val3=0;1;2;0;100

This is the result:
Image

The bug is in /usr/local/nagiosxi/html/includes/dashlets/gauges/gauges.inc.php line 353. There is a conditional to detect if any variable has no value, but its triggered incorrectly if the value is 0:

Code: Select all

        if (empty($perfdata_s[1])) continue; 
$perdata_s[1] is the value of the variable, empty("0") is true. A possible solution is to replace empty(...) with !isset(...)

BUG: If a variable name contains any of the characters that are escaped (for instance, :~\`!@$%\^&*()\/ ") the corresponding gauges are not shown.
The bug is caused in the same file (line 350 onwards)

Code: Select all

        $perfdata_name = pnp_convert_object_name($perfdata_name);
        if ($ds_label && $perfdata_name != $ds_label)
            continue;
pnp_convert_object_name sanitizes the mentioned characters (they get replaced with underscores) but the comparison $perfdata_name != $ds_label is wrong, since $ds_label was not sanitized.
A possible solution is to replace the if condition with

Code: Select all

if ($ds_label && $perfdata_name != $ds_label && $perfdata_name != pnp_convert_object_name($ds_label))
This can cause a side effect if multiple variable names map into the same sanitized name, since only the first matching variable will show. A more complex approach would surely be possible, for instance generating different identifiers (adding a numeric suffix) for those cases.

Thanks!
Gonzalo

Re: Gauge Bugs

Posted: Wed Oct 24, 2018 4:55 pm
by ssax
Thanks for reporting this.

I did notice that if you change it from:

Code: Select all

Val1=0 Val2=0;1;2 Val3=0;1;2;0;100
To:

Code: Select all

Val1=0; Val2=0;1;2 Val3=0;1;2;0;100
It does show properly, the reason I tried this was because:

Code: Select all

This is the expected format:

'label'=value[UOM];[warn];[crit];[min];[max]
warn, crit, min or max may be null (for example, if the threshold is not defined or min and max do not apply). Trailing unfilled semicolons can be dropped
So to me that reads that it still needs the ; but I know from other examples in the documentation that it doesn't require it.

Taken from here:

https://nagios-plugins.org/doc/guidelines.html#AEN200

I will be submitting this in a bug report so the developers can implement a fix.

Code: Select all

NEW TASK ID 13757 created - Nagios XI Bug Report: XI - Gauge Bugs