diff --git a/application/controllers/IndexController.php b/application/controllers/IndexController.php index 391b26eb..6a7c5770 100644 --- a/application/controllers/IndexController.php +++ b/application/controllers/IndexController.php @@ -3,6 +3,7 @@ namespace Icinga\Module\Director\Controllers; use Exception; +use Icinga\Module\Director\Objects\SyncRule; use Icinga\Module\Director\Web\Controller\ActionController; class IndexController extends ActionController @@ -29,9 +30,34 @@ class IndexController extends ActionController 'url' => $this->getRequest()->getUrl(), 'label' => $this->translate('Overview') ))->activate('overview'); + + $this->fetchSyncState(); } } + protected function fetchSyncState() + { + $syncs = SyncRule::loadAll($this->db()); + if (count($syncs) > 0) { + $state = 'ok'; + } else { + $state = null; + } + + foreach ($syncs as $sync) { + if ($sync->sync_state !== 'in-sync') { + if ($sync->sync_state === 'failing') { + $state = 'critical'; + break; + } else { + $state = 'warning'; + } + } + } + + $this->view->syncState = $state; + } + protected function hasDeploymentEndpoint() { try { diff --git a/application/views/scripts/index/index.phtml b/application/views/scripts/index/index.phtml index 7cf930fb..afec2dd1 100644 --- a/application/views/scripts/index/index.phtml +++ b/application/views/scripts/index/index.phtml @@ -102,7 +102,7 @@ $all = array( ), $this->translate('Do more with your data') => array( array('database', $this->translate('Import data sources'), 'director/list/importsource', $this->translate('Define and manage imports from various data sources')), - array('flapping', $this->translate('Synchronize'), 'director/list/importsource', $this->translate('Define how imported data should be synchronized with Icinga')), + array('flapping', $this->translate('Synchronize'), 'director/list/syncrule', $this->translate('Define how imported data should be synchronized with Icinga'), $this->syncState), array('sort-name-up', $this->translate('Provide data lists'), 'director/data/lists', $this->translate('Provide data lists to make life easier for your users')), array('edit', $this->translate('Define data fields'), 'director/data/fields', $this->translate('Data fields make sure that configuration fits your rules')), )