From eaa60a37fbb28cc062be1c8d874d16c0eb55e877 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 6 Jun 2025 12:45:01 +0200 Subject: [PATCH] IcingaHealth: Include icingadb version in metrics --- library/Icingadb/ProvidedHook/IcingaHealth.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/library/Icingadb/ProvidedHook/IcingaHealth.php b/library/Icingadb/ProvidedHook/IcingaHealth.php index 54e22c79..e0fd3412 100644 --- a/library/Icingadb/ProvidedHook/IcingaHealth.php +++ b/library/Icingadb/ProvidedHook/IcingaHealth.php @@ -5,6 +5,7 @@ namespace Icinga\Module\Icingadb\ProvidedHook; use Icinga\Application\Hook\HealthHook; +use Icinga\Module\Icingadb\Common\Backend; use Icinga\Module\Icingadb\Common\Database; use Icinga\Module\Icingadb\Model\Instance; use ipl\Web\Url; @@ -79,6 +80,7 @@ class IcingaHealth extends HealthHook 'icinga2_performance_data_enabled' => $instance->icinga2_performance_data_enabled, 'icinga2_start_time' => $instance->icinga2_start_time->getTimestamp(), 'icinga2_version' => $instance->icinga2_version, + 'icingadb_version' => $instance->icingadb_version ?? null, 'endpoint' => ['name' => $instance->endpoint->name] ]); } @@ -92,7 +94,7 @@ class IcingaHealth extends HealthHook protected function getInstance() { if ($this->instance === null) { - $this->instance = Instance::on($this->getDb()) + $query = Instance::on($this->getDb()) ->with('endpoint') ->columns([ 'heartbeat', @@ -106,8 +108,12 @@ class IcingaHealth extends HealthHook 'icinga2_start_time', 'icinga2_version', 'endpoint.name' - ]) - ->first(); + ]); + if (Backend::supportsDependencies()) { + $query->withColumns('icingadb_version'); + } + + $this->instance = $query->first(); } return $this->instance;