Skip to content

Commit

Permalink
Merge pull request #10339 from Icinga/fix-perf-data-normalization
Browse files Browse the repository at this point in the history
PerfData: Don't discard min/max values even if crit/warn thresholds aren’t given
  • Loading branch information
julianbrost authored Feb 4, 2025
2 parents 0fe1632 + 56116d2 commit 6e545a5
Show file tree
Hide file tree
Showing 4 changed files with 203 additions and 185 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ Luca Lesinigo <[email protected]>
Lucas Bremgartner <[email protected]>
Lucas Fairchild-Madar <[email protected]>
Luiz Amaral <[email protected]>
Maciej Dems <[email protected]>
Magnus Bäck <[email protected]>
Maik Stuebner <[email protected]>
Malte Rabenseifner <[email protected]>
Expand Down
27 changes: 17 additions & 10 deletions lib/base/perfdatavalue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,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
Expand Down
Loading

0 comments on commit 6e545a5

Please sign in to comment.