From 5450a00c7850f6a2f8d5fe23b3fc00d821cbdfb9 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Fri, 25 Aug 2017 08:50:38 +0200 Subject: [PATCH] IcingaService: handle use_agent=n by explicitly... ...rendering command_endpoint = null fixes #921 fixes #1013 --- library/Director/Objects/IcingaHost.php | 2 +- library/Director/Objects/IcingaService.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/library/Director/Objects/IcingaHost.php b/library/Director/Objects/IcingaHost.php index c884f2b1..7771f3c3 100644 --- a/library/Director/Objects/IcingaHost.php +++ b/library/Director/Objects/IcingaHost.php @@ -125,7 +125,7 @@ class IcingaHost extends IcingaObject $hostVars = array(); - if ($connection !== null) { + if ($connection instanceof Db) { foreach ($connection->fetchDistinctHostVars() as $var) { if ($filter->match(PropertiesFilter::$CUSTOM_PROPERTY, $var->varname, $var)) { if ($var->datatype) { diff --git a/library/Director/Objects/IcingaService.php b/library/Director/Objects/IcingaService.php index 34d0eccd..d9f27e0b 100644 --- a/library/Director/Objects/IcingaService.php +++ b/library/Director/Objects/IcingaService.php @@ -346,13 +346,13 @@ class IcingaService extends IcingaObject return $output; } - // In case use_agent isn't defined, do nothing - // TODO: what if we inherit use_agent and override it with 'n'? - if ($this->use_agent !== 'y') { + if ($this->use_agent === 'y') { + return $output . c::renderKeyValue('command_endpoint', 'host_name'); + } elseif ($this->use_agent === 'n') { + return $output . c::renderKeyValue('command_endpoint', c::renderPhpValue(null)); + } else { return $output; } - - return $output . c::renderKeyValue('command_endpoint', 'host_name'); } /**