Icinga DB: introduce icinga:*:state#normalized_performance_data

This commit is contained in:
Alexander A. Klimov 2021-05-11 16:58:49 +02:00
parent ea5411a6e0
commit 9d1a112edf
2 changed files with 7 additions and 1 deletions

View File

@ -651,7 +651,7 @@ Icinga sets `LC_NUMERIC=C` to enforce this locale on plugin execution.
```
The UoMs are written as-is into the [core backends](14-features.md#core-backends)
(Icinga DB, IDO, API). I.e. 12.445000ms remain 12.445000ms.
(IDO, API). I.e. 12.445000ms remain 12.445000ms.
In contrast, the [metric backends](14-features.md#metrics)
(Graphite, InfluxDB, etc.) get perfdata (including warn, crit, min, max)
@ -660,6 +660,8 @@ normalized by Icinga. E.g. 12.445000ms become 0.012445 seconds.
Some plugins change the UoM for different sizing, e.g. returning the disk usage in MB and later GB
for the same performance data label. This is to ensure that graphs always look the same.
[Icinga DB](14-features.md#core-backends-icingadb) gets both the as-is and the normalized perfdata.
What metric backends get... | ... from which perfdata UoMs (case-insensitive if possible)
----------------------------|---------------------------------------
bytes (B) | B, KB, MB, ..., YB, KiB, MiB, ..., YiB

View File

@ -2182,6 +2182,10 @@ Dictionary::Ptr IcingaDB::SerializeState(const Checkable::Ptr& checkable)
if (!perfData.IsEmpty())
attrs->Set("performance_data", perfData);
String normedPerfData = PluginUtility::FormatPerfdata(cr->GetPerformanceData(), true);
if (!normedPerfData.IsEmpty())
attrs->Set("normalized_performance_data", normedPerfData);
if (!cr->GetCommand().IsEmpty())
attrs->Set("commandline", FormatCommandLine(cr->GetCommand()));
attrs->Set("execution_time", TimestampToMilliseconds(fmax(0.0, cr->CalculateExecutionTime())));