checkHealth(); return $this->count > 0; } public function getState() { return $this->directorState; } public function getCount() { if ($this->hasProblems()) { return $this->count; } else { return 0; } } public function getTitle() { return $this->message; } protected function checkHealth() { $db = $this->db(); if (! $db) { $this->directorState = self::STATE_PENDING; $this->count = 1; $this->message = $this->translate( 'No database has been configured for Icinga Director' ); return; } $kickstart = new KickstartHelper($db); if ($kickstart->isRequired()) { $this->directorState = self::STATE_PENDING; $this->count = 1; $this->message = $this->translate( 'No API user configured, you might run the kickstart helper' ); return; } $pendingChanges = $db->countActivitiesSinceLastDeployedConfig(); if ($pendingChanges > 0) { $this->directorState = self::STATE_WARNING; $this->count = $pendingChanges; $this->message = sprintf( $this->translate( '%s config changes happend since the last deployed configuration' ), $pendingChanges ); return; } } protected function translate($message) { return mt('director', $message); } protected function db() { $resourceName = Config::module('director')->get('db', 'resource'); if ($resourceName) { return Db::fromResourceName($resourceName); } else { return false; } } }