From 5419d4428c86c488a43124f85e5407d7cbae6541 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 14 Apr 2024 15:17:47 +0200 Subject: Adding upstream version 1.11.1. Signed-off-by: Daniel Baumann --- library/Director/IcingaConfig/IcingaConfig.php | 31 ++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'library/Director/IcingaConfig/IcingaConfig.php') diff --git a/library/Director/IcingaConfig/IcingaConfig.php b/library/Director/IcingaConfig/IcingaConfig.php index 72edd7e..a79bf3c 100644 --- a/library/Director/IcingaConfig/IcingaConfig.php +++ b/library/Director/IcingaConfig/IcingaConfig.php @@ -25,6 +25,9 @@ class IcingaConfig protected $zoneMap = array(); + /** @var ?array Exists for caching reasons at rendering time */ + protected $nonGlobalZones = null; + protected $lastActivityChecksum; /** @var \Zend_Db_Adapter_Abstract */ @@ -349,6 +352,15 @@ class IcingaConfig return $this->zoneMap[$id]; } + public function listNonGlobalZones(): array + { + if ($this->nonGlobalZones === null) { + $this->nonGlobalZones = array_values($this->connection->enumNonglobalZones()); + } + + return $this->nonGlobalZones; + } + /** * @return self */ @@ -436,9 +448,9 @@ class IcingaConfig $start = microtime(true); MemoryLimit::raiseTo('1024M'); - ini_set('max_execution_time', 0); + ini_set('max_execution_time', '0'); // Workaround for https://bugs.php.net/bug.php?id=68606 or similar - ini_set('zend.enable_gc', 0); + ini_set('zend.enable_gc', '0'); if (! $this->connection->isPgsql() && $this->db->quote("1\0") !== '\'1\\0\'') { throw new RuntimeException( @@ -501,6 +513,7 @@ class IcingaConfig "\nconst DirectorStageDir = dirname(dirname(current_filename))\n" . $this->renderFlappingLogHelper() . $this->renderHostOverridableVars() + . $this->renderIfwFallbackTemplate() ); return $this; @@ -566,6 +579,20 @@ if (! globals.contains(DirectorOverrideTemplate)) { ); } + + protected function renderIfwFallbackTemplate(): string + { + return ' +// Make sure config validates for Icinga < 2.14 with IfW 1.11 configuration. This might look weird, +// but is intentional. get_object() does\'t work as expected at parse time. +if (! globals.System || ! System.get_template || ! get_template(CheckCommand, "ifw-api-check-command")) { + object CheckCommand "ifw-api" { + import "plugin-check-command" + } +} +'; + } + /** * @param string $checksum * -- cgit v1.2.3