From 0ba4d24880bf96ea3f1f727055ee2705ca289b82 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 29 May 2015 14:17:12 +0200 Subject: [PATCH 01/24] Move notifications to the bottom of the page refs #8247 --- application/layouts/scripts/body.phtml | 45 +++++++++++++------------- library/Icinga/Web/StyleSheet.php | 1 + public/css/icinga/footer-elements.less | 8 +++++ 3 files changed, 32 insertions(+), 22 deletions(-) create mode 100644 public/css/icinga/footer-elements.less diff --git a/application/layouts/scripts/body.phtml b/application/layouts/scripts/body.phtml index 78bb4f91d..5da1e4322 100644 --- a/application/layouts/scripts/body.phtml +++ b/application/layouts/scripts/body.phtml @@ -5,29 +5,20 @@ use Icinga\Web\Notification; use Icinga\Authentication\Manager as Auth; -if (Auth::getInstance()->isAuthenticated()): ?> - \ No newline at end of file diff --git a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php index 0b1cda923..8879a40ea 100644 --- a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php +++ b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php @@ -93,6 +93,19 @@ abstract class MonitoredObjectController extends Controller $this->view->object = $this->object; } + /** + * Show the history for a host or service + */ + public function historyAction() + { + $this->getTabs()->activate('history'); + $this->view->history = $this->object->fetchEventHistory()->eventhistory; + + $this->setupLimitControl(50); + $this->setupPaginationControl($this->view->history, 50); + $this->view->object = $this->object; + } + /** * Handle a command form * @@ -211,7 +224,7 @@ abstract class MonitoredObjectController extends Controller , 'label' => $this->translate('History'), 'icon' => 'rewind', - 'url' => 'monitoring/show/history', + 'url' => $isService ? 'monitoring/service/history' : 'monitoring/host/history', 'urlParams' => $params ) ); From 71e932bcf91c996ea4f2ea5545b64116faefb2fd Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 16 Jun 2015 17:05:41 +0200 Subject: [PATCH 18/24] ShowController: Deprecate historyAction --- .../controllers/ShowController.php | 155 +--------------- .../views/scripts/show/history.phtml | 174 ------------------ 2 files changed, 7 insertions(+), 322 deletions(-) delete mode 100644 modules/monitoring/application/views/scripts/show/history.phtml diff --git a/modules/monitoring/application/controllers/ShowController.php b/modules/monitoring/application/controllers/ShowController.php index 60f2b186f..2321e0f82 100644 --- a/modules/monitoring/application/controllers/ShowController.php +++ b/modules/monitoring/application/controllers/ShowController.php @@ -1,12 +1,7 @@ view->object = MonitoredObject::fromParams($this->params); - if ($this->view->object && $this->view->object->fetch() === false) { - throw new Zend_Controller_Action_Exception($this->translate('Host or service not found')); - } - - if (Hook::has('ticket')) { - $this->view->tickets = Hook::first('ticket'); - } - if (Hook::has('grapher')) { - $this->grapher = Hook::first('grapher'); - if ($this->grapher && ! $this->grapher->hasPreviews()) { - $this->grapher = null; - } - } - - $this->createTabs(); - } - /** * @deprecated */ @@ -66,37 +33,16 @@ class Monitoring_ShowController extends Controller $this->redirectNow(Url::fromRequest()->setPath('monitoring/host/show')); } + /** + * @deprecated + */ public function historyAction() { - $this->getTabs()->activate('history'); - $this->view->object->fetchEventHistory(); - $this->view->history = $this->view->object->eventhistory; - $this->handleFormatRequest($this->view->object->eventhistory); - $this->fetchHostStats(); + if ($this->params->has('service')) { + $this->redirectNow(Url::fromRequest()->setPath('monitoring/service/history')); + } - $this->setupLimitControl(50); - $this->setupPaginationControl($this->view->history, 50); - } - - protected function fetchHostStats() - { - $this->view->stats = $this->backend->select()->from('statusSummary', array( - 'services_total', - 'services_ok', - 'services_problem', - 'services_problem_handled', - 'services_problem_unhandled', - 'services_critical', - 'services_critical_unhandled', - 'services_critical_handled', - 'services_warning', - 'services_warning_unhandled', - 'services_warning_handled', - 'services_unknown', - 'services_unknown_unhandled', - 'services_unknown_handled', - 'services_pending', - ))->where('service_host_name', $this->params->get('host'))->getQuery()->fetchRow(); + $this->redirectNow(Url::fromRequest()->setPath('monitoring/host/history')); } public function contactAction() @@ -162,91 +108,4 @@ class Monitoring_ShowController extends Controller $this->view->contact = $contact; $this->view->contactName = $contactName; } - - /** - * Creating tabs for this controller - * @return Tabs - */ - protected function createTabs() - { - if (($object = $this->view->object) === null) { - return; - } - if ($object->getType() === $object::TYPE_HOST) { - $isService = false; - $params = array( - 'host' => $object->getName() - ); - } else { - $isService = true; - $params = array( - 'host' => $object->getHost()->getName(), - 'service' => $object->getName() - ); - } - $tabs = $this->getTabs(); - $tabs->add( - 'host', - array( - 'title' => sprintf( - $this->translate('Show detailed information for host %s'), - $isService ? $object->getHost()->getName() : $object->getName() - ), - 'label' => $this->translate('Host'), - 'icon' => 'host', - 'url' => 'monitoring/show/host', - 'urlParams' => $params, - ) - ); - if ($isService) { - $tabs->add( - 'service', - array( - 'title' => sprintf( - $this->translate('Show detailed information for service %s on host %s'), - $object->getName(), - $object->getHost()->getName() - ), - 'label' => $this->translate('Service'), - 'icon' => 'service', - 'url' => 'monitoring/show/service', - 'urlParams' => $params, - ) - ); - } - $tabs->add( - 'services', - array( - 'title' => sprintf( - $this->translate('List all services on host %s'), - $isService ? $object->getHost()->getName() : $object->getName() - ), - 'label' => $this->translate('Services'), - 'icon' => 'services', - 'url' => 'monitoring/host/services', - 'urlParams' => $params, - ) - ); - if ($this->backend->hasQuery('eventHistory')) { - $tabs->add( - 'history', - array( - 'title' => $isService - ? sprintf( - $this->translate('Show all event records of service %s on host %s'), - $object->getName(), - $object->getHost()->getName() - ) - : sprintf($this->translate('Show all event records of host %s'), $object->getName()) - , - 'label' => $this->translate('History'), - 'icon' => 'rewind', - 'url' => 'monitoring/show/history', - 'urlParams' => $params, - ) - ); - } - $tabs->extend(new OutputFormat()) - ->extend(new DashboardAction()); - } } diff --git a/modules/monitoring/application/views/scripts/show/history.phtml b/modules/monitoring/application/views/scripts/show/history.phtml deleted file mode 100644 index 3777d0384..000000000 --- a/modules/monitoring/application/views/scripts/show/history.phtml +++ /dev/null @@ -1,174 +0,0 @@ -getType() === 'host'; - -if (! $this->compact): ?> -
- tabs; ?> - - render('partials/host/object-header.phtml'); ?> - - render('partials/service/object-header.phtml'); ?> - -

translate('This Object\'s Event History'); ?>

- sortBox; ?> - limiter; ?> - paginator; ?> - filterEditor; ?> -
- -
-translate('No history available for this object') . '
'; - return; -} -?> - -qlink( - $contact, - 'monitoring/show/contact', - array('contact_name' => $contact), - array('title' => sprintf($view->translate('Show detailed information about %s'), $contact)) - ); - } - return '[' . implode(', ', $links) . ']'; -} -?> - - - - - service_description); - switch ($event->type) { - case 'notify': - $icon = 'notification'; - $title = $this->translate('Notification'); - $stateClass = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state); - - $msg = preg_replace_callback( - '/^\[([^\]]+)\]/', - function($match) use ($self) { return contactsLink($match, $self); }, - $this->escape($event->output) - ); - break; - case 'comment': - $icon = 'comment'; - $title = $this->translate('Comment'); - $msg = $this->escape($event->output); - break; - case 'comment_deleted': - $icon = 'remove'; - $title = $this->translate('Comment deleted'); - $msg = $this->escape($event->output); - break; - case 'ack': - $icon = 'acknowledgement'; - $title = $this->translate('Acknowledge'); - $msg = $this->escape($event->output); - break; - case 'ack_deleted': - $icon = 'remove'; - $title = $this->translate('Ack removed'); - $msg = $this->escape($event->output); - break; - case 'dt_comment': - $icon = 'in_downtime'; - $title = $this->translate('In Downtime'); - $msg = $this->escape($event->output); - break; - case 'dt_comment_deleted': - $icon = 'remove'; - $title = $this->translate('Downtime removed'); - $msg = $this->escape($event->output); - break; - case 'flapping': - $icon = 'flapping'; - $title = $this->translate('Flapping'); - $msg = $this->escape($event->output); - break; - case 'flapping_deleted': - $icon = 'remove'; - $title = $this->translate('Flapping stopped'); - $msg = $this->escape($event->output); - break; - case 'hard_state': - $msg = '[ ' . $event->attempt . '/' . $event->max_attempts . ' ] ' . $this->escape($event->output); - $stateClass = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state); - $icon = 'attention-alt'; - $title = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state); - break; - case 'soft_state': - $icon = 'spinner'; - $msg = '[ ' . $event->attempt . '/' . $event->max_attempts . ' ] ' . $this->escape($event->output); - $stateClass = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state); - $title = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state); - break; - case 'dt_start': - $icon = 'downtime_start'; - $title = $this->translate('Downtime Start'); - $msg = $this->escape($event->output); - break; - case 'dt_end': - $icon = 'downtime_end'; - $title = $this->translate('Downtime End'); - $msg = $this->escape($event->output); - break; - } - ?> - - - - - - -
- escape($title); ?> -
- timestamp); ?> -
tickets ? preg_replace_callback( - $this->tickets->getPattern(), - array($this->tickets, 'createLink'), - $msg -) : $msg; - -?> - - translate('%s on %s', 'Service running on host'), - $hostContext ? $this->qlink( - $event->service_display_name, - 'monitoring/show/service', - array( - 'host' => $event->host_name, - 'service' => $event->service_description - ), - array('title' => sprintf( - $this->translate('Show detailed information for service %s on host %s'), - $event->service_display_name, - $event->host_display_name - )) - ) : $this->escape($event->service_display_name), - $event->host_display_name - ) ?> - - escape($event->host_name); ?> - -
-
- icon($icon, $title); ?> -
-
- From f31f18dc5192bd70d412663d048741234adb77ae Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Tue, 16 Jun 2015 17:54:21 +0200 Subject: [PATCH 19/24] Move security documentation for monitoring module into correct directory refs #9377 --- modules/{doc => monitoring}/doc/security.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename modules/{doc => monitoring}/doc/security.md (100%) diff --git a/modules/doc/doc/security.md b/modules/monitoring/doc/security.md similarity index 100% rename from modules/doc/doc/security.md rename to modules/monitoring/doc/security.md From 36622101ae7c41b3b5b7eca2afe266466b99c34d Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Tue, 16 Jun 2015 18:36:12 +0200 Subject: [PATCH 20/24] Use built-in php sort functions refs #8205 --- .../application/views/helpers/Perfdata.php | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/modules/monitoring/application/views/helpers/Perfdata.php b/modules/monitoring/application/views/helpers/Perfdata.php index 1ff59b6ae..aaf6b3fee 100644 --- a/modules/monitoring/application/views/helpers/Perfdata.php +++ b/modules/monitoring/application/views/helpers/Perfdata.php @@ -19,19 +19,12 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract public function perfdata($perfdataStr, $compact = false, $limit = 0, $color = Perfdata::PERFDATA_OK) { $pieChartData = PerfdataSet::fromString($perfdataStr)->asArray(); - - if (1 < ($i = count($pieChartData))) { - while (--$i) { - for ($j = 0, $k = 1; $j < $i; ++$j, ++$k) { - if ($pieChartData[$k]->worseThan($pieChartData[$j])) { - $perfdata = $pieChartData[$k]; - $pieChartData[$k] = $pieChartData[$j]; - $pieChartData[$j] = $perfdata; - } - } + uasort( + $pieChartData, + function($a, $b) { + return $a->worseThan($b) ? -1 : ($b->worseThan($a) ? 1 : 0); } - } - + ); $results = array(); $table = array( '' . implode( From 0d32b94eaa4854a13aef012fae1c8e76aed4af72 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 17 Jun 2015 10:24:18 +0200 Subject: [PATCH 21/24] HostController: Open a host's service in the current column --- .../monitoring/application/views/scripts/host/services.phtml | 3 ++- .../monitoring/application/views/scripts/list/services.phtml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/views/scripts/host/services.phtml b/modules/monitoring/application/views/scripts/host/services.phtml index ca12f3d0e..11166f8fa 100644 --- a/modules/monitoring/application/views/scripts/host/services.phtml +++ b/modules/monitoring/application/views/scripts/host/services.phtml @@ -12,6 +12,7 @@ 'compact' => true, 'showHost' => false, 'services' => $services, - 'addColumns' => array() + 'addColumns' => array(), + 'baseTarget' => '_self' ) ); ?> \ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/list/services.phtml b/modules/monitoring/application/views/scripts/list/services.phtml index c9dae8332..f3b28bb5e 100644 --- a/modules/monitoring/application/views/scripts/list/services.phtml +++ b/modules/monitoring/application/views/scripts/list/services.phtml @@ -25,7 +25,7 @@ if (count($services) === 0) { return; } ?> -" data-icinga-multiselect-data="service,host"> From 31406a70bcfd1f28f643a3bb02194b4ba5229659 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 17 Jun 2015 12:54:36 +0200 Subject: [PATCH 22/24] Show a small border above the first notification Looks better, somehow.. refs #8247 --- public/css/icinga/main-content.less | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/public/css/icinga/main-content.less b/public/css/icinga/main-content.less index 6f15533cc..24297b991 100644 --- a/public/css/icinga/main-content.less +++ b/public/css/icinga/main-content.less @@ -28,6 +28,10 @@ img.icon { #notifications { margin: 0; padding: 0; + + li:first-child { + border-top: 2px solid @colorPetrol; + } } #notifications > li { From 858c015d4cc3cedd06ea0c4c26d093d89bfdce90 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 17 Jun 2015 13:37:11 +0200 Subject: [PATCH 23/24] Move notification related css into footer-elements.less.. ..and fix the border and z-index. --- public/css/icinga/footer-elements.less | 38 ++++++++++++++++++++++++ public/css/icinga/main-content.less | 41 -------------------------- 2 files changed, 38 insertions(+), 41 deletions(-) diff --git a/public/css/icinga/footer-elements.less b/public/css/icinga/footer-elements.less index a9d513103..d9c49f100 100644 --- a/public/css/icinga/footer-elements.less +++ b/public/css/icinga/footer-elements.less @@ -5,4 +5,42 @@ div#footer { left: 0px; right: 0px; bottom: 0px; + z-index: 9999; } + +/** Notifications **/ + +#notifications { + margin: 0; + padding: 0; +} + +#notifications > li { + list-style-type: none; + display: block; + border-top: 1px solid #999; + color: white; + line-height: 2.5em; + padding-left: 3em; + background-repeat: no-repeat; + background-position: 1em center; +} + +#notifications > li.info { + background-color: @colorFormNotificationInfo; +} + +#notifications > li.warning { + background-color: @colorWarningHandled; +} +#notifications > li.error { + background-color: @colorCritical; + background-image: url(../img/icons/error_white.png); +} + +#notifications > li.success { + background-color: #fe6; + background-image: url(../img/icons/success.png); + color: #333; +} +/** END of Notifications **/ diff --git a/public/css/icinga/main-content.less b/public/css/icinga/main-content.less index 24297b991..635c1628f 100644 --- a/public/css/icinga/main-content.less +++ b/public/css/icinga/main-content.less @@ -23,47 +23,6 @@ img.icon { border: none; } -/** Notifications **/ - -#notifications { - margin: 0; - padding: 0; - - li:first-child { - border-top: 2px solid @colorPetrol; - } -} - -#notifications > li { - list-style-type: none; - display: block; - border-bottom: 1px solid #999; - color: white; - line-height: 2.5em; - padding-left: 3em; - background-repeat: no-repeat; - background-position: 1em center; -} - -#notifications > li.info { - background-color: @colorFormNotificationInfo; -} - -#notifications > li.warning { - background-color: @colorWarningHandled; -} -#notifications > li.error { - background-color: @colorCritical; - background-image: url(../img/icons/error_white.png); -} - -#notifications > li.success { - background-color: #fe6; - background-image: url(../img/icons/success.png); - color: #333; -} -/** END of Notifications **/ - /* TODO: Remove once there is no more module container */ .container > div > pre { margin: 1em; From b54bf3540294e0890b4bea32b4af86274c91648f Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 17 Jun 2015 13:43:59 +0200 Subject: [PATCH 24/24] ConfigController: Do not use forward() but redirectNow() fixes #9349 --- application/controllers/ConfigController.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/application/controllers/ConfigController.php b/application/controllers/ConfigController.php index 9d55910e9..0f3d7d1ed 100644 --- a/application/controllers/ConfigController.php +++ b/application/controllers/ConfigController.php @@ -86,12 +86,8 @@ class ConfigController extends Controller if ($this->firstAllowedAction === null) { throw new SecurityException($this->translate('No permission for application configuration')); } - $action = $this->getTabs()->get($this->firstAllowedAction); - if (substr($action->getUrl()->getPath(), 0, 7) === 'config/') { - $this->forward($this->firstAllowedAction); - } else { - $this->redirectNow($action->getUrl()); - } + + $this->redirectNow($this->getTabs()->get($this->firstAllowedAction)->getUrl()); } /**