mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-22 13:14:32 +02:00
Merge pull request #10432 from Icinga/perfdata-parse-counter-value
Fix PerfdataValue Counter Parsing
This commit is contained in:
commit
79e5462072
@ -270,6 +270,11 @@ PerfdataValue::Ptr PerfdataValue::Parse(const String& perfdata)
|
||||
if (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;
|
||||
|
||||
{
|
||||
@ -295,10 +300,6 @@ PerfdataValue::Ptr PerfdataValue::Parse(const String& perfdata)
|
||||
}
|
||||
}
|
||||
|
||||
if (unit == "c") {
|
||||
counter = true;
|
||||
}
|
||||
|
||||
warn = ParseWarnCritMinMaxToken(tokens, 1, "warning");
|
||||
crit = ParseWarnCritMinMaxToken(tokens, 2, "critical");
|
||||
min = ParseWarnCritMinMaxToken(tokens, 3, "minimum");
|
||||
|
@ -285,6 +285,19 @@ BOOST_AUTO_TEST_CASE(uom)
|
||||
|
||||
str = pv->Format();
|
||||
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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user