Gauge Bugs
Posted: Wed Oct 24, 2018 8:39 am
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:

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:
$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)
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
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
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:

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; 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;
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))Thanks!
Gonzalo