mirror of https://github.com/Icinga/icinga2.git
Fix missing values in PerfData normalization
This commit is contained in:
parent
91789b2888
commit
2bb5cc62e2
1
AUTHORS
1
AUTHORS
|
@ -163,6 +163,7 @@ Luca Lesinigo <luca@lm-net.it>
|
|||
Lucas Bremgartner <breml@users.noreply.github.com>
|
||||
Lucas Fairchild-Madar <lucas.madar@gmail.com>
|
||||
Luiz Amaral <luiz.amaral@innogames.com>
|
||||
Maciej Dems <maciej.dems@p.lodz.pl>
|
||||
Magnus Bäck <magnus@noun.se>
|
||||
Maik Stuebner <maik@stuebner.info>
|
||||
Malte Rabenseifner <mail@malte-rabenseifner.de>
|
||||
|
|
|
@ -363,20 +363,27 @@ String PerfdataValue::Format() const
|
|||
|
||||
result << unit;
|
||||
|
||||
std::string interm(";");
|
||||
if (!GetWarn().IsEmpty()) {
|
||||
result << ";" << Convert::ToString(GetWarn());
|
||||
result << interm << Convert::ToString(GetWarn());
|
||||
interm.clear();
|
||||
}
|
||||
|
||||
if (!GetCrit().IsEmpty()) {
|
||||
result << ";" << Convert::ToString(GetCrit());
|
||||
interm += ";";
|
||||
if (!GetCrit().IsEmpty()) {
|
||||
result << interm << Convert::ToString(GetCrit());
|
||||
interm.clear();
|
||||
}
|
||||
|
||||
if (!GetMin().IsEmpty()) {
|
||||
result << ";" << Convert::ToString(GetMin());
|
||||
interm += ";";
|
||||
if (!GetMin().IsEmpty()) {
|
||||
result << interm << Convert::ToString(GetMin());
|
||||
interm.clear();
|
||||
}
|
||||
|
||||
if (!GetMax().IsEmpty()) {
|
||||
result << ";" << Convert::ToString(GetMax());
|
||||
}
|
||||
}
|
||||
}
|
||||
interm += ";";
|
||||
if (!GetMax().IsEmpty()) {
|
||||
result << interm << Convert::ToString(GetMax());
|
||||
}
|
||||
|
||||
return result.str();
|
||||
|
|
|
@ -196,11 +196,12 @@ add_boost_test(base
|
|||
icinga_perfdata/normalize
|
||||
icinga_perfdata/uom
|
||||
icinga_perfdata/warncritminmax
|
||||
icinga_perfdata/ignore_invalid_warn_crit_min_max
|
||||
icinga_perfdata/ignore_warn_crit_ranges
|
||||
icinga_perfdata/invalid
|
||||
icinga_perfdata/multi
|
||||
icinga_perfdata/scientificnotation
|
||||
icinga_perfdata/parse_edgecases
|
||||
icinga_perfdata/empty_warn_crit_min_max
|
||||
methods_pluginnotificationtask/truncate_long_output
|
||||
remote_configpackageutility/ValidateName
|
||||
remote_url/id_and_path
|
||||
|
|
|
@ -303,7 +303,7 @@ BOOST_AUTO_TEST_CASE(warncritminmax)
|
|||
BOOST_CHECK_EQUAL(pv->Format(), "test=123456B;1000;2000;3000;4000");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ignore_invalid_warn_crit_min_max)
|
||||
BOOST_AUTO_TEST_CASE(ignore_warn_crit_ranges)
|
||||
{
|
||||
PerfdataValue::Ptr pv = PerfdataValue::Parse("test=123456;1000:2000;0:3000;3000;4000");
|
||||
BOOST_CHECK(pv);
|
||||
|
@ -313,7 +313,16 @@ BOOST_AUTO_TEST_CASE(ignore_invalid_warn_crit_min_max)
|
|||
BOOST_CHECK_EQUAL(pv->GetMin(), 3000);
|
||||
BOOST_CHECK_EQUAL(pv->GetMax(), 4000);
|
||||
|
||||
BOOST_CHECK_EQUAL(pv->Format(), "test=123456");
|
||||
BOOST_CHECK_EQUAL(pv->Format(), "test=123456;;;3000;4000");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(empty_warn_crit_min_max)
|
||||
{
|
||||
Array::Ptr pd = PluginUtility::SplitPerfdata("testA=5;;7;1;9 testB=5;7;;1;9 testC=5;;;1;9 testD=2m;;;1 testE=5;;7;;");
|
||||
BOOST_CHECK_EQUAL(pd->GetLength(), 5);
|
||||
|
||||
String str = PluginUtility::FormatPerfdata(pd, true);
|
||||
BOOST_CHECK_EQUAL(str, "testA=5;;7;1;9 testB=5;7;;1;9 testC=5;;;1;9 testD=120s;;;60 testE=5;;7");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(invalid)
|
||||
|
|
Loading…
Reference in New Issue