From 7bf888a554183a29a2d8b812d5d29d97e4af5826 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 3 Mar 2014 18:16:07 +0100 Subject: [PATCH] Vagrant: Add monitoring module config --- .../icingaweb/modules/monitoring/backends.ini | 19 +++++ .../modules/monitoring/instances.ini | 2 + .../etc/icingaweb/modules/monitoring/menu.ini | 76 +++++++++++++++++++ .vagrant-puppet/manifests/default.pp | 42 ++++++++++ application/controllers/ConfigController.php | 6 +- .../controllers/DashboardController.php | 22 ++++-- library/Icinga/Util/String.php | 2 +- 7 files changed, 157 insertions(+), 12 deletions(-) create mode 100644 .vagrant-puppet/files/etc/icingaweb/modules/monitoring/backends.ini create mode 100644 .vagrant-puppet/files/etc/icingaweb/modules/monitoring/instances.ini create mode 100644 .vagrant-puppet/files/etc/icingaweb/modules/monitoring/menu.ini diff --git a/.vagrant-puppet/files/etc/icingaweb/modules/monitoring/backends.ini b/.vagrant-puppet/files/etc/icingaweb/modules/monitoring/backends.ini new file mode 100644 index 000000000..6805f2e8b --- /dev/null +++ b/.vagrant-puppet/files/etc/icingaweb/modules/monitoring/backends.ini @@ -0,0 +1,19 @@ +[localdb] + +type = ido +resource = "ido" + +[locallive] +disabled = "1" +type = livestatus +resource = livestatus + +[localfile] +disabled = "1" +type = statusdat +resource = statusdat + +;[localfailsafe] +;enabled=false +;type = combo +;backends = localdb, locallive, localfile diff --git a/.vagrant-puppet/files/etc/icingaweb/modules/monitoring/instances.ini b/.vagrant-puppet/files/etc/icingaweb/modules/monitoring/instances.ini new file mode 100644 index 000000000..2f54e11e3 --- /dev/null +++ b/.vagrant-puppet/files/etc/icingaweb/modules/monitoring/instances.ini @@ -0,0 +1,2 @@ +[icinga] +path = "/usr/local/icinga-mysql/var/rw/icinga.cmd" diff --git a/.vagrant-puppet/files/etc/icingaweb/modules/monitoring/menu.ini b/.vagrant-puppet/files/etc/icingaweb/modules/monitoring/menu.ini new file mode 100644 index 000000000..6c69af7ea --- /dev/null +++ b/.vagrant-puppet/files/etc/icingaweb/modules/monitoring/menu.ini @@ -0,0 +1,76 @@ + +[Problems] +priority = 20 +icon = "img/icons/error.png" + +[Problems.Unhandled Hosts] +icon = "img/icons/host.png" +priority = 50 +url = "monitoring/list/hosts?host_problem=1&host_handled=0" + +[Problems.Unhandled Services] +icon = "img/icons/service.png" +priority = 50 +url = "monitoring/list/services?service_problem=1&service_handled=0" + +[Problems.Current Downtimes] +url = "monitoring/list/downtimes?downtime_is_in_effect=1" +icon = "img/icons/down.png" + +[Overview] +priority = 30 +icon = "img/icons/hostgroup.png" + +[Overview.Hosts] +title = "Hosts" +url = "monitoring/list/hosts" +icon = "img/icons/host.png" +priority = 50 + +[Overview.Services] +title = "Services" +url = "monitoring/list/services" +icon = "img/icons/service.png" +priority = 50 + +[Overview.Servicegroups] +title = "Servicegroups" +url = "monitoring/list/servicegroups" +icon = "img/icons/servicegroup.png" +priority = 60 + +[Overview.Hostgroups] +title = "Hostgroups" +url = "monitoring/list/hostgroups" +icon = "img/icons/hostgroup.png" +priority = 60 + +[Overview.Downtimes] +title = "Downtimes" +url = "monitoring/list/downtimes" +icon = "img/icons/down.png" +priority = 70 + +[Overview.Comments] +title = "Comments" +url = "monitoring/list/comments" +icon = "img/icons/comment.png" +priority = 70 + +[History] +icon = "img/icons/history.png" + +[History.Notifications] +title = "Notifications" +url = "monitoring/list/notifications" +icon = "img/icons/notification.png" + +[History.Events] +title = "All Events" +url = "monitoring/list/eventhistory" +icon = "img/icons/history.png" + +[System.Performance] +title = "Performance" +url = "monitoring/process/performance" + diff --git a/.vagrant-puppet/manifests/default.pp b/.vagrant-puppet/manifests/default.pp index e1f54bccf..9325644d4 100644 --- a/.vagrant-puppet/manifests/default.pp +++ b/.vagrant-puppet/manifests/default.pp @@ -637,3 +637,45 @@ file { '/etc/icingaweb/resources.ini': group => 'apache', require => File['/etc/icingaweb'] } + +file { '/etc/icingaweb/enabledModules': + ensure => 'directory', + owner => 'apache', + group => 'apache', + require => File['/etc/icingaweb'] +} + +file { '/etc/icingaweb/modules': + ensure => 'directory', + owner => 'apache', + group => 'apache', + require => File['/etc/icingaweb'] +} + +file { '/etc/icingaweb/modules/monitoring': + ensure => 'directory', + owner => 'apache', + group => 'apache', + require => File['/etc/icingaweb/modules'] +} + +file { '/etc/icingaweb/modules/monitoring/backends.ini': + source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icingaweb/modules/monitoring/backends.ini', + owner => 'apache', + group => 'apache', + require => File['/etc/icingaweb/modules/monitoring'] +} + +file { '/etc/icingaweb/modules/monitoring/instances.ini': + source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icingaweb/modules/monitoring/instances.ini', + owner => 'apache', + group => 'apache', + require => File['/etc/icingaweb/modules/monitoring'] +} + +file { '/etc/icingaweb/modules/monitoring/menu.ini': + source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icingaweb/modules/monitoring/menu.ini', + owner => 'apache', + group => 'apache', + require => File['/etc/icingaweb/modules/monitoring'] +} diff --git a/application/controllers/ConfigController.php b/application/controllers/ConfigController.php index edee923fa..1aa792360 100644 --- a/application/controllers/ConfigController.php +++ b/application/controllers/ConfigController.php @@ -113,7 +113,7 @@ class ConfigController extends BaseConfigController { $this->view->messageBox = new AlertMessageBox(true); $form = new GeneralForm(); - $form->setConfiguration(IcingaConfig::app()); + //$form->setConfiguration(IcingaConfig::app()); $form->setRequest($this->_request); if ($form->isSubmittedAndValid()) { if (!$this->writeConfigFile($form->getConfig(), 'config')) { @@ -465,11 +465,11 @@ class ConfigController extends BaseConfigController $form = new ConfirmRemovalForm(); $form->setRequest($this->getRequest()); $form->setRemoveTarget('resource', $name); - + // Check if selected resource is currently used for authentication $authConfig = IcingaConfig::app('authentication', true)->toArray(); foreach ($authConfig as $backendName => $config) { - if (array_key_exists('resource', $config) && $config['resource'] === $name) { + if (array_key_exists('resource', $config) && $config['resource'] === $name) { $this->addErrorMessage( 'Warning: The resource "' . $name . '" is currently used for user authentication by "' . $backendName . '". ' . ' Deleting it could eventally make login impossible.' diff --git a/application/controllers/DashboardController.php b/application/controllers/DashboardController.php index 7cbf97d98..06ec7c184 100644 --- a/application/controllers/DashboardController.php +++ b/application/controllers/DashboardController.php @@ -28,13 +28,14 @@ */ // {{{ICINGA_LICENSE_HEADER}}} -use \Icinga\Web\Controller\ActionController; -use \Icinga\Web\Url; -use \Icinga\Application\Icinga; -use \Icinga\Web\Widget\Dashboard; -use \Icinga\Application\Config as IcingaConfig; -use \Icinga\Form\Dashboard\AddUrlForm; -use \Icinga\Exception\ConfigurationError; +use Icinga\Web\Controller\ActionController; +use Icinga\Web\Url; +use Icinga\Web\Widget\Dashboard; +use Icinga\Application\Config as IcingaConfig; +use Icinga\Form\Dashboard\AddUrlForm; +use Icinga\Exception\ConfigurationError; +use Icinga\Exception\NotReadableError; +use Icinga\Application\Logger; /** * Handle creation, removal and displaying of dashboards, panes and components @@ -53,7 +54,12 @@ class DashboardController extends ActionController private function getDashboard($config = 'dashboard/dashboard') { $dashboard = new Dashboard(); - $dashboard->readConfig(IcingaConfig::app($config)); + try { + $dashboardConfig = IcingaConfig::app($config); + $dashboard->readConfig($dashboardConfig); + } catch (NotReadableError $e) { + Logger::exception(new Exception('Cannot load dashboard configuration. An exception was thrown:', 0, $e)); + } return $dashboard; } diff --git a/library/Icinga/Util/String.php b/library/Icinga/Util/String.php index 08ebf6277..434159578 100644 --- a/library/Icinga/Util/String.php +++ b/library/Icinga/Util/String.php @@ -44,6 +44,6 @@ class String */ public static function trimSplit($value, $delimiter = ',') { - return array_map('trim', explode(',', $value)); + return array_map('trim', explode($delimiter, $value)); } }