From 9d1a112edfcb6ad744f535d99561d74c67137a40 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 11 May 2021 16:58:49 +0200 Subject: [PATCH] Icinga DB: introduce icinga:*:state#normalized_performance_data --- doc/05-service-monitoring.md | 4 +++- lib/icingadb/icingadb-objects.cpp | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/05-service-monitoring.md b/doc/05-service-monitoring.md index 68180c32a..f37630913 100644 --- a/doc/05-service-monitoring.md +++ b/doc/05-service-monitoring.md @@ -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 diff --git a/lib/icingadb/icingadb-objects.cpp b/lib/icingadb/icingadb-objects.cpp index 94e9a5a20..f017b1038 100644 --- a/lib/icingadb/icingadb-objects.cpp +++ b/lib/icingadb/icingadb-objects.cpp @@ -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())));