diff --git a/application/controllers/IndexController.php b/application/controllers/IndexController.php index 7ee6f963..9e0ac311 100644 --- a/application/controllers/IndexController.php +++ b/application/controllers/IndexController.php @@ -4,6 +4,7 @@ namespace Icinga\Module\Director\Controllers; use Exception; use Icinga\Module\Director\Objects\DirectorJob; +use Icinga\Module\Director\Objects\ImportSource; use Icinga\Module\Director\Objects\SyncRule; use Icinga\Module\Director\Web\Controller\ActionController; @@ -33,6 +34,7 @@ class IndexController extends ActionController ))->activate('overview'); $this->fetchSyncState() + ->fetchImportState() ->fetchJobState(); } } @@ -62,6 +64,31 @@ class IndexController extends ActionController return $this; } + protected function fetchImportState() + { + $srcs = ImportSource::loadAll($this->db()); + if (count($srcs) > 0) { + $state = 'ok'; + } else { + $state = null; + } + + foreach ($srcs as $src) { + if ($src->import_state !== 'in-sync') { + if ($src->import_state === 'failing') { + $state = 'critical'; + break; + } else { + $state = 'warning'; + } + } + } + + $this->view->importState = $state; + + return $this; + } + protected function fetchJobState() { $jobs = DirectorJob::loadAll($this->db()); diff --git a/application/views/scripts/index/index.phtml b/application/views/scripts/index/index.phtml index 86d3892c..8b49452b 100644 --- a/application/views/scripts/index/index.phtml +++ b/application/views/scripts/index/index.phtml @@ -101,7 +101,7 @@ $all = array( array('globe', $this->translate('Zones'), 'director/zones', statSummary($this, 'zone')), ), $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('database', $this->translate('Import data sources'), 'director/list/importsource', $this->translate('Define and manage imports from various data sources'), $this->importState), array('flapping', $this->translate('Synchronize'), 'director/list/syncrule', $this->translate('Define how imported data should be synchronized with Icinga'), $this->syncState), array('clock', $this->translate('Jobs'), 'director/jobs', $this->translate('Schedule and automate Import, Syncronization, Config Deployment, Housekeeping and more'), $this->jobState), array('sort-name-up', $this->translate('Provide data lists'), 'director/data/lists', $this->translate('Provide data lists to make life easier for your users')),