Icinga / icinga2

The core of our monitoring platform with a powerful configuration language and REST API.
https://icinga.com/docs/icinga2/latest
GNU General Public License v2.0
2k stars 574 forks source link

Perfdata counter (c suffix) is ignored #9540

Open ledvinap opened 1 year ago

ledvinap commented 1 year ago

Describe the bug

Parsing code does ignore perfdata value with counter type (c suffix)

DupUoMs maps c to unit = "", base = 1 (https://github.com/Icinga/icinga2/blob/master/lib/base/perfdatavalue.cpp#L33, https://github.com/Icinga/icinga2/blob/master/lib/base/perfdatavalue.cpp#L33). Then code tests for unit == "c" - but unit is already empty string (https://github.com/Icinga/icinga2/blob/master/lib/base/perfdatavalue.cpp#L294-L296)

Code before UOM change did work (https://github.com/Icinga/icinga2/commit/720a88c29a489cec91815af49755413202802d7a#diff-93211109a65aef5eddad6a78b4e380d7f08626422b7bc69e37720f37bbab62a5L93-L95)

Expected behavior

counter argument to PerfdataValue constructor is set for unit == "c"

Your Environment

master branch, since 3 Apr 2020

Fix is trivial, just move if (unit == "c") { before unit mapping

ledvinap commented 1 year ago

Maybe this will fix note in https://github.com/Icinga/icinga2/blob/db321b9fcb659b19fbf2488da0050edd0fd92d53/doc/06-distributed-monitoring.md#windows-agent-and-nsclient-

julianbrost commented 1 year ago

Can also be tested/reproduced quite easily in the console:

Icinga 2 (version: v2.12.9)
Type $help to view available commands.
<1> => parse_performance_data("test=42c").counter
true
Icinga 2 (version: v2.13.5)
Type $help to view available commands.
<1> => parse_performance_data("test=42c").counter
false