auth = $auth; $this->dbResourceName = $dbResourceName; $this->add('main', [ 'label' => $this->translate('Overview'), 'url' => 'director' ]); if ($this->auth->hasPermission(Permission::ADMIN)) { $this->add('health', [ 'label' => $this->translate('Health'), 'url' => 'director/health' ])->add('daemon', [ 'label' => $this->translate('Daemon'), 'url' => 'director/daemon' ]); } } public function render() { if ($this->auth->hasPermission(Permission::ADMIN)) { if ($this->getActiveName() !== 'health') { $state = $this->getHealthState(); if ($state->isProblem()) { $this->get('health')->setTagParams([ 'class' => 'state-' . strtolower($state->getName()) ]); } } if ($this->getActiveName() !== 'daemon') { try { $daemon = new BackgroundDaemonState(Db::fromResourceName($this->dbResourceName)); if ($daemon->isRunning()) { $state = 'ok'; } else { $state = 'critical'; } } catch (\Exception $e) { $state = 'unknown'; } if ($state !== 'ok') { $this->get('daemon')->setTagParams([ 'class' => 'state-' . $state ]); } } } return parent::render(); } /** * @return \Icinga\Module\Director\CheckPlugin\PluginState */ protected function getHealthState() { $health = new Health(); $health->setDbResourceName($this->dbResourceName); $output = new HealthCheckPluginOutput($health); return $output->getState(); } }