mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-23 13:45:04 +02:00
Fix PerfdataValue Counter Parsing
Ensure that the counter unit of measurement, "c", is parsed correctly for performance data values again. A prior refactoring in 720a88c29a489cec91815af49755413202802d7a changed the parsing logic, resulting in an incorrect behavior for counter units. By passing the raw input into the l_CsUoMs map first, the "c" UoM is removed. Moving the explicit counter check before passing the raw unit into the map resolves this issue. Fixes #9540.
This commit is contained in:
parent
33824c2acc
commit
7e65a60a5d
@ -270,6 +270,11 @@ PerfdataValue::Ptr PerfdataValue::Parse(const String& perfdata)
|
|||||||
if (pos != String::NPos)
|
if (pos != String::NPos)
|
||||||
unit = tokens[0].SubStr(pos, String::NPos);
|
unit = tokens[0].SubStr(pos, String::NPos);
|
||||||
|
|
||||||
|
// UoM.Out is an empty string for "c". So set counter before parsing.
|
||||||
|
if (unit == "c") {
|
||||||
|
counter = true;
|
||||||
|
}
|
||||||
|
|
||||||
double base;
|
double base;
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -295,10 +300,6 @@ PerfdataValue::Ptr PerfdataValue::Parse(const String& perfdata)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unit == "c") {
|
|
||||||
counter = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
warn = ParseWarnCritMinMaxToken(tokens, 1, "warning");
|
warn = ParseWarnCritMinMaxToken(tokens, 1, "warning");
|
||||||
crit = ParseWarnCritMinMaxToken(tokens, 2, "critical");
|
crit = ParseWarnCritMinMaxToken(tokens, 2, "critical");
|
||||||
min = ParseWarnCritMinMaxToken(tokens, 3, "minimum");
|
min = ParseWarnCritMinMaxToken(tokens, 3, "minimum");
|
||||||
|
@ -285,6 +285,19 @@ BOOST_AUTO_TEST_CASE(uom)
|
|||||||
|
|
||||||
str = pv->Format();
|
str = pv->Format();
|
||||||
BOOST_CHECK_EQUAL(str, "test=1W");
|
BOOST_CHECK_EQUAL(str, "test=1W");
|
||||||
|
|
||||||
|
pv = PerfdataValue::Parse("test=42c");
|
||||||
|
BOOST_CHECK(pv);
|
||||||
|
BOOST_CHECK_EQUAL(pv->GetValue(), 42);
|
||||||
|
BOOST_CHECK(pv->GetCounter());
|
||||||
|
BOOST_CHECK_EQUAL(pv->GetUnit(), "");
|
||||||
|
BOOST_CHECK_EQUAL(pv->GetCrit(), Empty);
|
||||||
|
BOOST_CHECK_EQUAL(pv->GetWarn(), Empty);
|
||||||
|
BOOST_CHECK_EQUAL(pv->GetMin(), Empty);
|
||||||
|
BOOST_CHECK_EQUAL(pv->GetMax(), Empty);
|
||||||
|
|
||||||
|
str = pv->Format();
|
||||||
|
BOOST_CHECK_EQUAL(str, "test=42c");
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(warncritminmax)
|
BOOST_AUTO_TEST_CASE(warncritminmax)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user