diff --git a/www/class/config-generate-remote/Abstracts/AbstractHost.php b/www/class/config-generate-remote/Abstracts/AbstractHost.php index 9e776b090fa..482cbfecb79 100644 --- a/www/class/config-generate-remote/Abstracts/AbstractHost.php +++ b/www/class/config-generate-remote/Abstracts/AbstractHost.php @@ -31,6 +31,7 @@ use ConfigGenerateRemote\Relations\ContactHostRelation; use ConfigGenerateRemote\Relations\ContactGroupHostRelation; use ConfigGenerateRemote\Relations\HostTemplateRelation; +use ConfigGenerateRemote\Relations\HostPollerRelation; use ConfigGenerateRemote\Relations\MacroHost; abstract class AbstractHost extends AbstractObject @@ -104,6 +105,7 @@ abstract class AbstractHost extends AbstractObject protected $stmtHtpl = null; protected $stmtContact = null; protected $stmtCg = null; + protected $stmtPoller = null; /** * Get host extended information @@ -213,6 +215,29 @@ protected function getHostTemplates(array &$host): void } } + /** + * Get linked poller + * + * @param array $host + * @return void + */ + protected function getHostPoller(array $host): void + { + if (is_null($this->stmtPoller)) { + $this->stmtPoller = $this->backendInstance->db->prepare( + "SELECT nagios_server_id + FROM ns_host_relation + WHERE host_host_id = :host_id" + ); + } + $this->stmtPoller->bindParam(':host_id', $host['host_id'], PDO::PARAM_INT); + $this->stmtPoller->execute(); + $pollerId = $this->stmtPoller->fetchAll(PDO::FETCH_COLUMN); + + HostPollerRelation::getInstance($this->dependencyInjector) + ->addRelation($pollerId[0], $host['host_id']); + } + /** * Get linked contacts * diff --git a/www/class/config-generate-remote/Generate.php b/www/class/config-generate-remote/Generate.php index e995da22e65..348c701388b 100644 --- a/www/class/config-generate-remote/Generate.php +++ b/www/class/config-generate-remote/Generate.php @@ -358,6 +358,7 @@ private function resetObjects() Relations\HostGroupRelation::getInstance($this->dependencyInjector)->reset(); Relations\HostServiceRelation::getInstance($this->dependencyInjector)->reset(); Relations\HostTemplateRelation::getInstance($this->dependencyInjector)->reset(); + Relations\HostPollerRelation::getInstance($this->dependencyInjector)->reset(); Relations\MacroHost::getInstance($this->dependencyInjector)->reset(); Relations\NagiosServer::getInstance($this->dependencyInjector)->reset(); Relations\ServiceCategoriesRelation::getInstance($this->dependencyInjector)->reset(); diff --git a/www/class/config-generate-remote/Host.php b/www/class/config-generate-remote/Host.php index 3b680ae294c..eda729197c8 100644 --- a/www/class/config-generate-remote/Host.php +++ b/www/class/config-generate-remote/Host.php @@ -185,6 +185,7 @@ public function generateFromHostId(array &$host) $this->getHostTimezone($host); $this->getHostTemplates($host); + $this->getHostPoller($host); $this->getHostCommands($host); $this->getHostPeriods($host); diff --git a/www/class/config-generate-remote/Relations/HostPollerRelation.php b/www/class/config-generate-remote/Relations/HostPollerRelation.php new file mode 100644 index 00000000000..54c7b0f2835 --- /dev/null +++ b/www/class/config-generate-remote/Relations/HostPollerRelation.php @@ -0,0 +1,49 @@ + $pollerId, + 'host_host_id' => $hostId, + ]; + $this->generateObjectInFile($relation, $hostId . '.' . $serviceId); + } +}