From 3243f9a65a45ba080ce36ff652bf02a6cf5a1f1f Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 19 May 2015 15:26:21 +0200 Subject: [PATCH 01/58] Don't handle the case $this->searchColumns === null for actions in which ::setSearchColumns() is called refs #8241 --- library/Icinga/Web/Widget/FilterEditor.php | 24 +--------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/library/Icinga/Web/Widget/FilterEditor.php b/library/Icinga/Web/Widget/FilterEditor.php index 40953a518..fb346b573 100644 --- a/library/Icinga/Web/Widget/FilterEditor.php +++ b/library/Icinga/Web/Widget/FilterEditor.php @@ -217,29 +217,7 @@ class FilterEditor extends AbstractWidget if ($search !== null) { if ($this->searchColumns === null) { if (strpos($search, '=') === false) { - // TODO: Ask the view for (multiple) search columns - switch($request->getActionName()) { - case 'services': - $searchCol = 'service'; - break; - case 'hosts': - $searchCol = 'host'; - break; - case 'hostgroups': - $searchCol = 'hostgroup'; - break; - case 'servicegroups': - $searchCol = 'servicegroup'; - break; - default: - $searchCol = null; - } - - if ($searchCol === null) { - throw new Exception('Cannot search here'); - } - $search = ltrim($search); - $filter = $this->mergeRootExpression($filter, $searchCol, '=', "*$search*"); + throw new Exception('Cannot search here'); } else { list($k, $v) = preg_split('/=/', $search); $filter = $this->mergeRootExpression($filter, trim($k), '=', ltrim($v)); From 36713fb519f38cd2071fb0a001dad444f1c83db7 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 19 May 2015 15:43:47 +0200 Subject: [PATCH 02/58] Rename parameter $query of ::filterQuery() to $dataView refs #8241 --- .../controllers/ListController.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index a793f2a0a..df5a10dee 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -13,6 +13,7 @@ use Icinga\Data\Filter\Filter; use Icinga\Web\Widget; use Icinga\Module\Monitoring\Forms\StatehistoryForm; use Icinga\Data\Filterable; +use Icinga\Module\Monitoring\DataView\DataView; class Monitoring_ListController extends Controller { @@ -627,17 +628,17 @@ class Monitoring_ListController extends Controller } /** - * Apply filters on a query + * Apply filters on a DataView * - * @param Filterable $query The query to apply filters on - * @param array $searchColumns Columns to search in + * @param DataView $dataView The DataView to apply filters on + * @param array $searchColumns Columns to search in * - * @return Filterable $query + * @return DataView $dataView */ - protected function filterQuery(Filterable $query, array $searchColumns = null) + protected function filterQuery(DataView $dataView, array $searchColumns = null) { $editor = Widget::create('filterEditor') - ->setQuery($query) + ->setQuery($dataView) ->preserveParams( 'limit', 'sort', 'dir', 'format', 'view', 'backend', 'stateType', 'addColumns', '_dev' @@ -647,13 +648,13 @@ class Monitoring_ListController extends Controller $editor->setSearchColumns($searchColumns); } $editor->handleRequest($this->getRequest()); - $query->applyFilter($editor->getFilter()); + $dataView->applyFilter($editor->getFilter()); $this->setupFilterControl($editor); $this->view->filter = $editor->getFilter(); - $this->handleFormatRequest($query); - return $query; + $this->handleFormatRequest($dataView); + return $dataView; } /** From cc050ed696fc73ebb4d344bbd1e5f679a18e5e71 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 19 May 2015 16:28:07 +0200 Subject: [PATCH 03/58] Display an error notification rather than throwing an exception refs #8241 --- library/Icinga/Web/Widget/FilterEditor.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/Icinga/Web/Widget/FilterEditor.php b/library/Icinga/Web/Widget/FilterEditor.php index fb346b573..07640872b 100644 --- a/library/Icinga/Web/Widget/FilterEditor.php +++ b/library/Icinga/Web/Widget/FilterEditor.php @@ -10,6 +10,7 @@ use Icinga\Data\Filter\FilterOr; use Icinga\Web\Url; use Icinga\Application\Icinga; use Icinga\Exception\ProgrammingError; +use Icinga\Web\Notification; use Exception; /** @@ -217,7 +218,8 @@ class FilterEditor extends AbstractWidget if ($search !== null) { if ($this->searchColumns === null) { if (strpos($search, '=') === false) { - throw new Exception('Cannot search here'); + Notification::error(mt('monitoring', 'Cannot search here')); + return $this; } else { list($k, $v) = preg_split('/=/', $search); $filter = $this->mergeRootExpression($filter, trim($k), '=', ltrim($v)); From 2ed1d6c66b0f1975b9cdbe8b74e28958a3764ff7 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 19 May 2015 16:37:39 +0200 Subject: [PATCH 04/58] Implement ::getSearchColumns() refs #8241 --- .../library/Monitoring/DataView/DataView.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/monitoring/library/Monitoring/DataView/DataView.php b/modules/monitoring/library/Monitoring/DataView/DataView.php index 8212d7bb7..6456fa203 100644 --- a/modules/monitoring/library/Monitoring/DataView/DataView.php +++ b/modules/monitoring/library/Monitoring/DataView/DataView.php @@ -378,6 +378,16 @@ abstract class DataView implements QueryInterface, IteratorAggregate return $this; } + /** + * Get the view's search columns + * + * @return string[] + */ + public function getSearchColumns() + { + return array(); + } + /** * @deprecated(EL): Only use DataView::applyFilter() for applying filter because all other functions are missing * column validation. From c0cf6e4918af12905b197b46fb418be5cb8c8bcb Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Tue, 19 May 2015 18:08:26 +0200 Subject: [PATCH 05/58] Display icon_images in all host and service detail views refs #8665 --- .../application/controllers/HostsController.php | 2 ++ .../application/controllers/ServicesController.php | 2 ++ .../scripts/partials/host/object-header.phtml | 3 +++ .../scripts/partials/host/objects-header.phtml | 3 +++ .../scripts/partials/service/object-header.phtml | 14 ++++++++++---- .../scripts/partials/service/objects-header.phtml | 3 +++ .../monitoring/library/Monitoring/Object/Host.php | 1 + .../library/Monitoring/Object/Service.php | 2 ++ 8 files changed, 26 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index 45eca1135..ac55ade9b 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -53,6 +53,7 @@ class Monitoring_HostsController extends Controller protected function handleCommandForm(ObjectsCommandForm $form) { $this->hostList->setColumns(array( + 'host_icon_image', 'host_name', 'host_state', 'host_problem', @@ -94,6 +95,7 @@ class Monitoring_HostsController extends Controller ->handleRequest(); $this->view->checkNowForm = $checkNowForm; $this->hostList->setColumns(array( + 'host_icon_image', 'host_name', 'host_state', 'host_problem', diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index f4ee73cf5..ca9788ff2 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -55,6 +55,7 @@ class Monitoring_ServicesController extends Controller 'host_state', 'host_problem', 'host_handled', + 'service_icon_image', 'service_description', 'service_state', 'service_problem', @@ -98,6 +99,7 @@ class Monitoring_ServicesController extends Controller 'host_state', 'host_problem', 'host_handled', + 'service_icon_image', 'service_output', 'service_description', 'service_state', diff --git a/modules/monitoring/application/views/scripts/partials/host/object-header.phtml b/modules/monitoring/application/views/scripts/partials/host/object-header.phtml index 0efedf328..127f492e6 100644 --- a/modules/monitoring/application/views/scripts/partials/host/object-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/object-header.phtml @@ -9,6 +9,9 @@ use Icinga\Module\Monitoring\Object\Host; prefixedTimeSince($object->host_last_state_change, true); ?> + host_icon_image && ! preg_match('/[\'"]/', $object->host_icon_image)): ?> + icon($this->resolveMacros($object->host_icon_image, $object)) ?> + escape($object->host_display_name); ?> host_display_name !== $object->host_name): ?> (escape($object->host_name); ?>) diff --git a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml index d59479e07..b6856609c 100644 --- a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml @@ -18,6 +18,9 @@ $i = 0; host_state, true); ?>
hostFlags($host)) ?> + host_icon_image && ! preg_match('/[\'"]/', $host->host_icon_image)): ?> + icon($this->resolveMacros($host->host_icon_image, $host)) ?> + escape($host->getName()); ?>
escape($host->host_output) ?> diff --git a/modules/monitoring/application/views/scripts/partials/service/object-header.phtml b/modules/monitoring/application/views/scripts/partials/service/object-header.phtml index 45111fe1e..b50aff9bc 100644 --- a/modules/monitoring/application/views/scripts/partials/service/object-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/service/object-header.phtml @@ -10,7 +10,10 @@ use Icinga\Module\Monitoring\Object\Service; prefixedTimeSince($object->host_last_state_change, true); ?> - escape($object->host_display_name); ?> + host_icon_image && ! preg_match('/[\'"]/', $object->host_icon_image)): ?> + icon($this->resolveMacros($object->host_icon_image, $object)) ?> + + escape($object->host_display_name); ?> host_display_name !== $object->host_name): ?> (escape($object->host_name); ?>) @@ -27,10 +30,13 @@ use Icinga\Module\Monitoring\Object\Service; prefixedTimeSince($object->service_last_state_change, true); ?> + service_icon_image && ! preg_match('/[\'"]/', $object->service_icon_image)): ?> + icon($this->resolveMacros($object->service_icon_image, $object)) ?> + translate('Service'); ?>: escape($object->service_display_name); ?> - service_display_name !== $object->service_description): ?> - (escape($object->service_description); ?>) - + service_display_name !== $object->service_description): ?> + (escape($object->service_description); ?>) + render('partials/service/statusicons.phtml'); ?> diff --git a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml index 0d3d4840d..fe1e4b16a 100644 --- a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml @@ -16,6 +16,9 @@ $i = 0; service_state, true); ?>
serviceFlags($service)) ?> + service_icon_image && ! preg_match('/[\'"]/', $service->service_icon_image)): ?> + icon($this->resolveMacros($service->service_icon_image, $service)) ?> + escape($service->getName()); ?> translate('on') ?> diff --git a/modules/monitoring/library/Monitoring/Object/Host.php b/modules/monitoring/library/Monitoring/Object/Host.php index 342e78812..2c01fe0eb 100644 --- a/modules/monitoring/library/Monitoring/Object/Host.php +++ b/modules/monitoring/library/Monitoring/Object/Host.php @@ -89,6 +89,7 @@ class Host extends MonitoredObject protected function getDataView() { $columns = array( + 'host_icon_image', 'host_acknowledged', 'host_action_url', 'host_active_checks_enabled', diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index 7c22ae57d..fec5de238 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -106,6 +106,7 @@ class Service extends MonitoredObject protected function getDataView() { return $this->backend->select()->from('serviceStatus', array( + 'host_icon_image', 'host_acknowledged', 'host_active_checks_enabled', 'host_address', @@ -118,6 +119,7 @@ class Service extends MonitoredObject 'host_notifications_enabled', 'host_passive_checks_enabled', 'host_state', + 'service_icon_image', 'service_acknowledged', 'service_action_url', 'service_active_checks_enabled', From 6ba07b089ddd7b9c76730455a60e2733784bdcbe Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 19 May 2015 17:31:17 +0200 Subject: [PATCH 06/58] Implement and use Hostgroupsummary and Servicegroupsummary refs #8241 --- .../application/controllers/ChartController.php | 4 ++-- .../application/controllers/ListController.php | 4 ++-- .../library/Monitoring/DataView/Groupsummary.php | 5 ----- .../library/Monitoring/DataView/Hostgroupsummary.php | 12 ++++++++++++ .../Monitoring/DataView/Servicegroupsummary.php | 12 ++++++++++++ 5 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php create mode 100644 modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php diff --git a/modules/monitoring/application/controllers/ChartController.php b/modules/monitoring/application/controllers/ChartController.php index 39f60c304..d2e9f990c 100644 --- a/modules/monitoring/application/controllers/ChartController.php +++ b/modules/monitoring/application/controllers/ChartController.php @@ -163,7 +163,7 @@ class Monitoring_ChartController extends Controller public function hostgroupAction() { $query = $this->backend->select()->from( - 'groupsummary', + 'hostgroupsummary', array( 'hostgroup', 'hosts_up', @@ -194,7 +194,7 @@ class Monitoring_ChartController extends Controller public function servicegroupAction() { $query = $this->backend->select()->from( - 'groupsummary', + 'servicegroupsummary', array( 'servicegroup', 'services_ok', diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index df5a10dee..01e2adc44 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -470,7 +470,7 @@ class Monitoring_ListController extends Controller ); $this->setAutorefreshInterval(12); - $query = $this->backend->select()->from('groupsummary', array( + $query = $this->backend->select()->from('servicegroupsummary', array( 'servicegroup_name', 'servicegroup_alias', 'hosts_up', @@ -521,7 +521,7 @@ class Monitoring_ListController extends Controller $this->addTitleTab('hostgroups', $this->translate('Host Groups'), $this->translate('List host groups')); $this->setAutorefreshInterval(12); - $query = $this->backend->select()->from('groupsummary', array( + $query = $this->backend->select()->from('hostgroupsummary', array( 'hostgroup_name', 'hostgroup_alias', 'hosts_up', diff --git a/modules/monitoring/library/Monitoring/DataView/Groupsummary.php b/modules/monitoring/library/Monitoring/DataView/Groupsummary.php index d29c1c418..f823d00a4 100644 --- a/modules/monitoring/library/Monitoring/DataView/Groupsummary.php +++ b/modules/monitoring/library/Monitoring/DataView/Groupsummary.php @@ -64,9 +64,4 @@ class Groupsummary extends DataView ) ); } - - public function getFilterColumns() - { - return array('hostgroup', 'servicegroup'); - } } diff --git a/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php b/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php new file mode 100644 index 000000000..ba8e49987 --- /dev/null +++ b/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php @@ -0,0 +1,12 @@ + Date: Tue, 19 May 2015 17:50:07 +0200 Subject: [PATCH 07/58] Override ::getSearchColumns() refs #8241 --- .../monitoring/library/Monitoring/DataView/HostStatus.php | 8 ++++++++ .../library/Monitoring/DataView/Hostgroupsummary.php | 8 ++++++++ .../library/Monitoring/DataView/ServiceStatus.php | 8 ++++++++ .../library/Monitoring/DataView/Servicegroupsummary.php | 8 ++++++++ 4 files changed, 32 insertions(+) diff --git a/modules/monitoring/library/Monitoring/DataView/HostStatus.php b/modules/monitoring/library/Monitoring/DataView/HostStatus.php index 23df6d94a..eebe496a5 100644 --- a/modules/monitoring/library/Monitoring/DataView/HostStatus.php +++ b/modules/monitoring/library/Monitoring/DataView/HostStatus.php @@ -125,4 +125,12 @@ class HostStatus extends DataView } return parent::isValidFilterTarget($column); } + + /** + * {@inheritdoc} + */ + public function getSearchColumns() + { + return array('host', 'host_display_name'); + } } diff --git a/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php b/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php index ba8e49987..b923b49e4 100644 --- a/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php +++ b/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php @@ -9,4 +9,12 @@ class Hostgroupsummary extends Groupsummary { return array('hostgroup'); } + + /** + * {@inheritdoc} + */ + public function getSearchColumns() + { + return array('hostgroup', 'hostgroup_alias'); + } } diff --git a/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php b/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php index b4f1038da..ff57266a3 100644 --- a/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php +++ b/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php @@ -183,4 +183,12 @@ class ServiceStatus extends DataView } return parent::isValidFilterTarget($column); } + + /** + * {@inheritdoc} + */ + public function getSearchColumns() + { + return array('service', 'service_display_name'); + } } diff --git a/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php b/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php index 550f8744c..f21f49d3e 100644 --- a/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php +++ b/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php @@ -9,4 +9,12 @@ class Servicegroupsummary extends Groupsummary { return array('servicegroup'); } + + /** + * {@inheritdoc} + */ + public function getSearchColumns() + { + return array('servicegroup', 'servicegroup_alias'); + } } From 0b937c86dc6e4956857cc2e812c72cf50976960a Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 19 May 2015 18:00:47 +0200 Subject: [PATCH 08/58] Get columns for FilterEditor::setSearchColumns() from DataView::getSearchColumns() refs #8241 --- .../controllers/ListController.php | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 01e2adc44..59fcd6f85 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -97,7 +97,7 @@ class Monitoring_ListController extends Controller 'host_current_check_attempt', 'host_max_check_attempts' ), $this->addColumns())); - $this->filterQuery($query, array('host', 'host_display_name')); + $this->filterQuery($query); $this->applyRestriction('monitoring/hosts/filter', $query); $this->view->hosts = $query; @@ -181,7 +181,7 @@ class Monitoring_ListController extends Controller 'max_check_attempts' => 'service_max_check_attempts' ), $this->addColumns()); $query = $this->backend->select()->from('serviceStatus', $columns); - $this->filterQuery($query, array('service', 'service_display_name')); + $this->filterQuery($query); $this->applyRestriction('monitoring/services/filter', $query); $this->view->services = $query; @@ -499,7 +499,7 @@ class Monitoring_ListController extends Controller ))->order('services_severity')->order('servicegroup_alias'); // TODO(el): Can't default to the sort rules of the data view because it's meant for both host groups and // service groups. We should separate them. - $this->filterQuery($query, array('servicegroup', 'servicegroup_alias')); + $this->filterQuery($query); $this->view->servicegroups = $query; $this->setupLimitControl(); @@ -556,7 +556,7 @@ class Monitoring_ListController extends Controller ))->order('services_severity')->order('hostgroup_alias'); // TODO(el): Can't default to the sort rules of the data view because it's meant for both host groups and // service groups. We should separate them. - $this->filterQuery($query, array('hostgroup', 'hostgroup_alias')); + $this->filterQuery($query); $this->view->hostgroups = $query; $this->setupLimitControl(); @@ -631,11 +631,10 @@ class Monitoring_ListController extends Controller * Apply filters on a DataView * * @param DataView $dataView The DataView to apply filters on - * @param array $searchColumns Columns to search in * * @return DataView $dataView */ - protected function filterQuery(DataView $dataView, array $searchColumns = null) + protected function filterQuery(DataView $dataView) { $editor = Widget::create('filterEditor') ->setQuery($dataView) @@ -643,11 +642,9 @@ class Monitoring_ListController extends Controller 'limit', 'sort', 'dir', 'format', 'view', 'backend', 'stateType', 'addColumns', '_dev' ) - ->ignoreParams('page'); - if ($searchColumns !== null) { - $editor->setSearchColumns($searchColumns); - } - $editor->handleRequest($this->getRequest()); + ->ignoreParams('page') + ->setSearchColumns($dataView->getSearchColumns()) + ->handleRequest($this->getRequest()); $dataView->applyFilter($editor->getFilter()); $this->setupFilterControl($editor); From 9b4f08eb433879f520dc7f93a4e205ae9bc631b5 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 20 May 2015 10:43:54 +0200 Subject: [PATCH 09/58] Implement classes HostgroupsummaryQuery and ServicegroupsummaryQuery Without this the Hostgroupsummary and Servicegroupsummary DataViews would not work refs #8241 --- .../Backend/Ido/Query/HostgroupsummaryQuery.php | 8 ++++++++ .../Backend/Ido/Query/ServicegroupsummaryQuery.php | 8 ++++++++ 2 files changed, 16 insertions(+) create mode 100644 modules/monitoring/library/Monitoring/Backend/Ido/Query/HostgroupsummaryQuery.php create mode 100644 modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicegroupsummaryQuery.php diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostgroupsummaryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostgroupsummaryQuery.php new file mode 100644 index 000000000..5711b88f5 --- /dev/null +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostgroupsummaryQuery.php @@ -0,0 +1,8 @@ + Date: Wed, 20 May 2015 13:48:51 +0200 Subject: [PATCH 10/58] Don't let a long plugin output make the whole container horizontally scrollable fixes #8941 --- public/css/icinga/monitoring-colors.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/css/icinga/monitoring-colors.less b/public/css/icinga/monitoring-colors.less index ba0877232..020db57cd 100644 --- a/public/css/icinga/monitoring-colors.less +++ b/public/css/icinga/monitoring-colors.less @@ -23,7 +23,7 @@ table.action { border-collapse: separate; border-spacing: 1px; width: 100%; - table-layout: fixed; + table-layout: fixed !important; margin: 0; color: @colorTextDefault; } From 2493535ac77c1dac21549a240176191d18a58116 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 20 May 2015 15:29:45 +0200 Subject: [PATCH 11/58] Revert "Implement classes HostgroupsummaryQuery and ServicegroupsummaryQuery" This reverts commit 9b4f08eb433879f520dc7f93a4e205ae9bc631b5. There's DataView::getQueryName() for this. refs #8241 --- .../Backend/Ido/Query/HostgroupsummaryQuery.php | 8 -------- .../Backend/Ido/Query/ServicegroupsummaryQuery.php | 8 -------- 2 files changed, 16 deletions(-) delete mode 100644 modules/monitoring/library/Monitoring/Backend/Ido/Query/HostgroupsummaryQuery.php delete mode 100644 modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicegroupsummaryQuery.php diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostgroupsummaryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostgroupsummaryQuery.php deleted file mode 100644 index 5711b88f5..000000000 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostgroupsummaryQuery.php +++ /dev/null @@ -1,8 +0,0 @@ - Date: Wed, 20 May 2015 15:37:24 +0200 Subject: [PATCH 12/58] monitoring: Use the groupsummary query for the host group summary view refs #8241 --- .../library/Monitoring/DataView/Hostgroupsummary.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php b/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php index b923b49e4..5383aae82 100644 --- a/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php +++ b/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php @@ -17,4 +17,12 @@ class Hostgroupsummary extends Groupsummary { return array('hostgroup', 'hostgroup_alias'); } + + /** + * {@inheritdoc} + */ + public static function getQueryName() + { + return 'groupsummary'; + } } From 5efbad3a714b9c4424796b0408874b662b479186 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 20 May 2015 15:38:48 +0200 Subject: [PATCH 13/58] monitoring: Don't sort the host group summary by service severity refs #8241 --- modules/monitoring/application/controllers/ListController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 59fcd6f85..5905e77a2 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -553,7 +553,7 @@ class Monitoring_ListController extends Controller 'services_critical_last_state_change_unhandled', 'services_unknown_last_state_change_unhandled', 'services_total' - ))->order('services_severity')->order('hostgroup_alias'); + ))->order('hostgroup_alias'); // TODO(el): Can't default to the sort rules of the data view because it's meant for both host groups and // service groups. We should separate them. $this->filterQuery($query); From d379b27c245523a39813f8c06bb025fc87175518 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 20 May 2015 15:40:49 +0200 Subject: [PATCH 14/58] monitoring: Hostgroupsummary must not extend Groupsummary which is subject to remove refs #8241 --- .../Monitoring/DataView/Hostgroupsummary.php | 40 ++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php b/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php index 5383aae82..e4d91b74d 100644 --- a/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php +++ b/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php @@ -3,8 +3,46 @@ namespace Icinga\Module\Monitoring\DataView; -class Hostgroupsummary extends Groupsummary +/** + * Data view for the host group summary + */ +class Hostgroupsummary extends DataView { + /** + * {@inheritdoc} + */ + public function getColumns() + { + return array( + 'hostgroup_alias', + 'hostgroup_name', + 'hosts_down_handled', + 'hosts_down_last_state_change_handled', + 'hosts_down_last_state_change_unhandled', + 'hosts_down_unhandled', + 'hosts_pending', + 'hosts_pending_last_state_change', + 'hosts_unreachable_handled', + 'hosts_unreachable_last_state_change_handled', + 'hosts_unreachable_last_state_change_unhandled', + 'hosts_unreachable_unhandled', + 'hosts_up', + 'hosts_up_last_state_change', + 'services_critical_handled', + 'services_critical_unhandled', + 'services_ok', + 'services_pending', + 'services_total', + 'services_unknown_handled', + 'services_unknown_unhandled', + 'services_warning_handled', + 'services_warning_unhandled' + ); + } + + /** + * {@inheritdoc} + */ public function getFilterColumns() { return array('hostgroup'); From 2dc6d5467d68a02dd0ae38bf80f4f3aeef2b41d0 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 20 May 2015 16:06:45 +0200 Subject: [PATCH 15/58] monitoring: Don't select unnecessary columns in the host group summary refs #8241 --- .../controllers/ListController.php | 34 +++++++------------ 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 5905e77a2..536fa3ecf 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -522,37 +522,29 @@ class Monitoring_ListController extends Controller $this->setAutorefreshInterval(12); $query = $this->backend->select()->from('hostgroupsummary', array( - 'hostgroup_name', 'hostgroup_alias', - 'hosts_up', - 'hosts_unreachable_handled', - 'hosts_unreachable_unhandled', + 'hostgroup_name', 'hosts_down_handled', + 'hosts_down_last_state_change_handled', + 'hosts_down_last_state_change_unhandled', 'hosts_down_unhandled', 'hosts_pending', - 'hosts_up_last_state_change', 'hosts_pending_last_state_change', - 'hosts_down_last_state_change_handled', + 'hosts_unreachable_handled', 'hosts_unreachable_last_state_change_handled', - 'hosts_down_last_state_change_unhandled', 'hosts_unreachable_last_state_change_unhandled', - 'services_ok', - 'services_unknown_handled', - 'services_unknown_unhandled', + 'hosts_unreachable_unhandled', + 'hosts_up', + 'hosts_up_last_state_change', 'services_critical_handled', 'services_critical_unhandled', - 'services_warning_handled', - 'services_warning_unhandled', + 'services_ok', 'services_pending', - 'services_ok_last_state_change', - 'services_pending_last_state_change', - 'services_warning_last_state_change_handled', - 'services_critical_last_state_change_handled', - 'services_unknown_last_state_change_handled', - 'services_warning_last_state_change_unhandled', - 'services_critical_last_state_change_unhandled', - 'services_unknown_last_state_change_unhandled', - 'services_total' + 'services_total', + 'services_unknown_handled', + 'services_unknown_unhandled', + 'services_warning_handled', + 'services_warning_unhandled' ))->order('hostgroup_alias'); // TODO(el): Can't default to the sort rules of the data view because it's meant for both host groups and // service groups. We should separate them. From a9d6a949571b0951595aa4ec2121e95281300510 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 20 May 2015 16:09:30 +0200 Subject: [PATCH 16/58] monitoring: Use the groupsummary query for the service group summary view refs #8241 --- .../Monitoring/DataView/Servicegroupsummary.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php b/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php index f21f49d3e..1b96e0788 100644 --- a/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php +++ b/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php @@ -5,11 +5,22 @@ namespace Icinga\Module\Monitoring\DataView; class Servicegroupsummary extends Groupsummary { + /** + * {@inheritdoc} + */ public function getFilterColumns() { return array('servicegroup'); } + /** + * {@inheritdoc} + */ + public static function getQueryName() + { + return 'groupsummary'; + } + /** * {@inheritdoc} */ From f9952cf231253af8c0e96d973a1a2fb1ab845958 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 20 May 2015 16:15:38 +0200 Subject: [PATCH 17/58] monitoring: Don't sort the service group summary by service severity refs #8241 --- modules/monitoring/application/controllers/ListController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 536fa3ecf..8e45f497e 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -496,7 +496,7 @@ class Monitoring_ListController extends Controller 'services_critical_last_state_change_unhandled', 'services_unknown_last_state_change_unhandled', 'services_total' - ))->order('services_severity')->order('servicegroup_alias'); + ))->order('servicegroup_alias'); // TODO(el): Can't default to the sort rules of the data view because it's meant for both host groups and // service groups. We should separate them. $this->filterQuery($query); From 80b174f526538d2fc28cf3a01d18a6c6bc90184a Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 20 May 2015 16:16:21 +0200 Subject: [PATCH 18/58] monitoring: Servicegroupsummary must not extend Groupsummary which is subject to remove refs #8241 --- .../DataView/Servicegroupsummary.php | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php b/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php index 1b96e0788..3633248f4 100644 --- a/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php +++ b/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php @@ -3,8 +3,42 @@ namespace Icinga\Module\Monitoring\DataView; -class Servicegroupsummary extends Groupsummary +class Servicegroupsummary extends DataView { + /** + * {@inheritdoc} + */ + public function getColumns() + { + return array( + 'hosts_down_handled', + 'hosts_down_unhandled', + 'hosts_pending', + 'hosts_unreachable_handled', + 'hosts_unreachable_unhandled', + 'hosts_up', + 'servicegroup_alias', + 'servicegroup_name', + 'services_critical_handled', + 'services_critical_last_state_change_handled', + 'services_critical_last_state_change_unhandled', + 'services_critical_unhandled', + 'services_ok', + 'services_ok_last_state_change', + 'services_pending', + 'services_pending_last_state_change', + 'services_total', + 'services_unknown_handled', + 'services_unknown_last_state_change_handled', + 'services_unknown_last_state_change_unhandled', + 'services_unknown_unhandled', + 'services_warning_handled', + 'services_warning_last_state_change_handled', + 'services_warning_last_state_change_unhandled', + 'services_warning_unhandled' + ); + } + /** * {@inheritdoc} */ From cfb819ec61bf398333a2b41eb4693421ab8661d5 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 20 May 2015 17:03:23 +0200 Subject: [PATCH 19/58] monitoring: Add missing column to the host group summary data view refs #8241 --- .../monitoring/library/Monitoring/DataView/Hostgroupsummary.php | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php b/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php index e4d91b74d..81725595a 100644 --- a/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php +++ b/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php @@ -22,6 +22,7 @@ class Hostgroupsummary extends DataView 'hosts_down_unhandled', 'hosts_pending', 'hosts_pending_last_state_change', + 'hosts_total', 'hosts_unreachable_handled', 'hosts_unreachable_last_state_change_handled', 'hosts_unreachable_last_state_change_unhandled', From ce463d16ef1f5c5737aa74e38de0d954ea92ce65 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 21 May 2015 11:19:58 +0200 Subject: [PATCH 20/58] Reorder group summary query's columns by name refs #8241 --- .../Backend/Ido/Query/GroupsummaryQuery.php | 84 +++++++++++-------- 1 file changed, 48 insertions(+), 36 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php index 392c97538..3418e1b2f 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php @@ -5,12 +5,19 @@ namespace Icinga\Module\Monitoring\Backend\Ido\Query; use Zend_Db_Select; +/** + * Query for host and service group summaries + */ class GroupSummaryQuery extends IdoQuery { - protected $useSubqueryCount = true; - + /** + * {@inheritdoc} + */ protected $columnMap = array( 'hoststatussummary' => array( + 'hostgroup' => 'hostgroup', + 'hostgroup_alias' => 'hostgroup_alias', + 'hostgroup_name' => 'hostgroup_name', 'hosts_total' => 'SUM(CASE WHEN object_type = \'host\' THEN 1 ELSE 0 END)', 'hosts_up' => 'SUM(CASE WHEN object_type = \'host\' AND state = 0 THEN 1 ELSE 0 END)', 'hosts_unreachable' => 'SUM(CASE WHEN object_type = \'host\' AND state = 2 THEN 1 ELSE 0 END)', @@ -18,46 +25,51 @@ class GroupSummaryQuery extends IdoQuery 'hosts_unreachable_unhandled' => 'SUM(CASE WHEN object_type = \'host\' AND state = 2 AND acknowledged + in_downtime = 0 THEN 1 ELSE 0 END)', 'hosts_down' => 'SUM(CASE WHEN object_type = \'host\' AND state = 1 THEN 1 ELSE 0 END)', 'hosts_down_handled' => 'SUM(CASE WHEN object_type = \'host\' AND state = 1 AND acknowledged + in_downtime != 0 THEN 1 ELSE 0 END)', + 'hosts_down_last_state_change_handled' => 'MAX(CASE WHEN object_type = \'host\' AND state = 1 AND acknowledged + in_downtime != 0 THEN state_change ELSE 0 END)', + 'hosts_down_last_state_change_unhandled' => 'MAX(CASE WHEN object_type = \'host\' AND state = 1 AND acknowledged + in_downtime = 0 THEN state_change ELSE 0 END)', 'hosts_down_unhandled' => 'SUM(CASE WHEN object_type = \'host\' AND state = 1 AND acknowledged + in_downtime = 0 THEN 1 ELSE 0 END)', 'hosts_pending' => 'SUM(CASE WHEN object_type = \'host\' AND state = 99 THEN 1 ELSE 0 END)', - 'hosts_up_last_state_change' => 'MAX(CASE WHEN object_type = \'host\' AND state = 0 THEN state_change ELSE 0 END)', 'hosts_pending_last_state_change' => 'MAX(CASE WHEN object_type = \'host\' AND state = 99 THEN state_change ELSE 0 END)', - 'hosts_down_last_state_change_handled' => 'MAX(CASE WHEN object_type = \'host\' AND state = 1 AND acknowledged + in_downtime != 0 THEN state_change ELSE 0 END)', 'hosts_unreachable_last_state_change_handled' => 'MAX(CASE WHEN object_type = \'host\' AND state = 2 AND acknowledged + in_downtime != 0 THEN state_change ELSE 0 END)', - 'hosts_down_last_state_change_unhandled' => 'MAX(CASE WHEN object_type = \'host\' AND state = 1 AND acknowledged + in_downtime = 0 THEN state_change ELSE 0 END)', 'hosts_unreachable_last_state_change_unhandled' => 'MAX(CASE WHEN object_type = \'host\' AND state = 2 AND acknowledged + in_downtime = 0 THEN state_change ELSE 0 END)', - 'hostgroup_name' => 'hostgroup_name', - 'hostgroup_alias' => 'hostgroup_alias', - 'hostgroup' => 'hostgroup' + 'hosts_up_last_state_change' => 'MAX(CASE WHEN object_type = \'host\' AND state = 0 THEN state_change ELSE 0 END)' ), 'servicestatussummary' => array( - 'services_total' => 'SUM(CASE WHEN object_type = \'service\' THEN 1 ELSE 0 END)', - 'services_ok' => 'SUM(CASE WHEN object_type = \'service\' AND state = 0 THEN 1 ELSE 0 END)', - 'services_pending' => 'SUM(CASE WHEN object_type = \'service\' AND state = 99 THEN 1 ELSE 0 END)', - 'services_warning' => 'SUM(CASE WHEN object_type = \'service\' AND state = 1 THEN 1 ELSE 0 END)', - 'services_warning_handled' => 'SUM(CASE WHEN object_type = \'service\' AND state = 1 AND acknowledged + in_downtime + host_state > 0 THEN 1 ELSE 0 END)', + 'servicegroup' => 'servicegroup', + 'servicegroup_alias' => 'servicegroup_alias', + 'servicegroup_name' => 'servicegroup_name', 'services_critical' => 'SUM(CASE WHEN object_type = \'service\' AND state = 2 THEN 1 ELSE 0 END)', 'services_critical_handled' => 'SUM(CASE WHEN object_type = \'service\' AND state = 2 AND acknowledged + in_downtime + host_state > 0 THEN 1 ELSE 0 END)', + 'services_critical_last_state_change_handled' => 'MAX(CASE WHEN object_type = \'service\' AND state = 2 AND acknowledged + in_downtime + host_state > 0 THEN state_change ELSE 0 END)', + 'services_critical_last_state_change_unhandled' => 'MAX(CASE WHEN object_type = \'service\' AND state = 2 AND acknowledged + in_downtime + host_state = 0 THEN state_change ELSE 0 END)', + 'services_critical_unhandled' => 'SUM(CASE WHEN object_type = \'service\' AND state = 2 AND acknowledged + in_downtime + host_state = 0 THEN 1 ELSE 0 END)', + 'services_ok' => 'SUM(CASE WHEN object_type = \'service\' AND state = 0 THEN 1 ELSE 0 END)', + 'services_ok_last_state_change' => 'MAX(CASE WHEN object_type = \'service\' AND state = 0 THEN state_change ELSE 0 END)', + 'services_pending' => 'SUM(CASE WHEN object_type = \'service\' AND state = 99 THEN 1 ELSE 0 END)', + 'services_pending_last_state_change' => 'MAX(CASE WHEN object_type = \'service\' AND state = 99 THEN state_change ELSE 0 END)', + 'services_severity' => 'MAX(CASE WHEN object_type = \'service\' THEN severity ELSE 0 END)', + 'services_total' => 'SUM(CASE WHEN object_type = \'service\' THEN 1 ELSE 0 END)', 'services_unknown' => 'SUM(CASE WHEN object_type = \'service\' AND state = 3 THEN 1 ELSE 0 END)', 'services_unknown_handled' => 'SUM(CASE WHEN object_type = \'service\' AND state = 3 AND acknowledged + in_downtime + host_state > 0 THEN 1 ELSE 0 END)', - 'services_warning_unhandled' => 'SUM(CASE WHEN object_type = \'service\' AND state = 1 AND acknowledged + in_downtime + host_state = 0 THEN 1 ELSE 0 END)', - 'services_critical_unhandled' => 'SUM(CASE WHEN object_type = \'service\' AND state = 2 AND acknowledged + in_downtime + host_state = 0 THEN 1 ELSE 0 END)', - 'services_unknown_unhandled' => 'SUM(CASE WHEN object_type = \'service\' AND state = 3 AND acknowledged + in_downtime + host_state = 0 THEN 1 ELSE 0 END)', - 'services_severity' => 'MAX(CASE WHEN object_type = \'service\' THEN severity ELSE 0 END)', - 'services_ok_last_state_change' => 'MAX(CASE WHEN object_type = \'service\' AND state = 0 THEN state_change ELSE 0 END)', - 'services_pending_last_state_change' => 'MAX(CASE WHEN object_type = \'service\' AND state = 99 THEN state_change ELSE 0 END)', - 'services_warning_last_state_change_handled' => 'MAX(CASE WHEN object_type = \'service\' AND state = 1 AND acknowledged + in_downtime + host_state > 0 THEN state_change ELSE 0 END)', - 'services_critical_last_state_change_handled' => 'MAX(CASE WHEN object_type = \'service\' AND state = 2 AND acknowledged + in_downtime + host_state > 0 THEN state_change ELSE 0 END)', 'services_unknown_last_state_change_handled' => 'MAX(CASE WHEN object_type = \'service\' AND state = 3 AND acknowledged + in_downtime + host_state > 0 THEN state_change ELSE 0 END)', - 'services_warning_last_state_change_unhandled' => 'MAX(CASE WHEN object_type = \'service\' AND state = 1 AND acknowledged + in_downtime + host_state = 0 THEN state_change ELSE 0 END)', - 'services_critical_last_state_change_unhandled' => 'MAX(CASE WHEN object_type = \'service\' AND state = 2 AND acknowledged + in_downtime + host_state = 0 THEN state_change ELSE 0 END)', 'services_unknown_last_state_change_unhandled' => 'MAX(CASE WHEN object_type = \'service\' AND state = 3 AND acknowledged + in_downtime + host_state = 0 THEN state_change ELSE 0 END)', - 'servicegroup_name' => 'servicegroup_name', - 'servicegroup_alias' => 'servicegroup_alias', - 'servicegroup' => 'servicegroup' + 'services_unknown_unhandled' => 'SUM(CASE WHEN object_type = \'service\' AND state = 3 AND acknowledged + in_downtime + host_state = 0 THEN 1 ELSE 0 END)', + 'services_warning' => 'SUM(CASE WHEN object_type = \'service\' AND state = 1 THEN 1 ELSE 0 END)', + 'services_warning_handled' => 'SUM(CASE WHEN object_type = \'service\' AND state = 1 AND acknowledged + in_downtime + host_state > 0 THEN 1 ELSE 0 END)', + 'services_warning_last_state_change_handled' => 'MAX(CASE WHEN object_type = \'service\' AND state = 1 AND acknowledged + in_downtime + host_state > 0 THEN state_change ELSE 0 END)', + 'services_warning_last_state_change_unhandled' => 'MAX(CASE WHEN object_type = \'service\' AND state = 1 AND acknowledged + in_downtime + host_state = 0 THEN state_change ELSE 0 END)', + 'services_warning_unhandled' => 'SUM(CASE WHEN object_type = \'service\' AND state = 1 AND acknowledged + in_downtime + host_state = 0 THEN 1 ELSE 0 END)' ) ); + /** + * {@inheritdoc} + */ + protected $useSubqueryCount = true; + + /** + * {@inheritdoc} + */ protected function joinBaseTables() { $columns = array( @@ -79,11 +91,11 @@ class GroupSummaryQuery extends IdoQuery $hosts = $this->createSubQuery( 'Hoststatus', $columns + array( - 'state' => 'host_state', - 'acknowledged' => 'host_acknowledged', - 'in_downtime' => 'host_in_downtime', - 'state_change' => 'host_last_state_change', - 'severity' => 'host_severity' + 'state' => 'host_state', + 'acknowledged' => 'host_acknowledged', + 'in_downtime' => 'host_in_downtime', + 'state_change' => 'host_last_state_change', + 'severity' => 'host_severity' ) ); if (in_array('servicegroup_name', $this->desiredColumns)) { @@ -101,11 +113,11 @@ class GroupSummaryQuery extends IdoQuery $services = $this->createSubQuery( 'Status', $columns + array( - 'state' => 'service_state', - 'acknowledged' => 'service_acknowledged', - 'in_downtime' => 'service_in_downtime', - 'state_change' => 'service_last_state_change', - 'severity' => 'service_severity' + 'state' => 'service_state', + 'acknowledged' => 'service_acknowledged', + 'in_downtime' => 'service_in_downtime', + 'state_change' => 'service_last_state_change', + 'severity' => 'service_severity' ) ); $union = $this->db->select()->union(array($hosts, $services), Zend_Db_Select::SQL_UNION_ALL); From bbed2cffae334d95301f12b9d8c91fdf8aec0bb4 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 21 May 2015 11:23:55 +0200 Subject: [PATCH 21/58] monitoring: Add column hosts_severity to the group summary query refs #8241 --- .../library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php index 3418e1b2f..df1a38d88 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php @@ -18,7 +18,6 @@ class GroupSummaryQuery extends IdoQuery 'hostgroup' => 'hostgroup', 'hostgroup_alias' => 'hostgroup_alias', 'hostgroup_name' => 'hostgroup_name', - 'hosts_total' => 'SUM(CASE WHEN object_type = \'host\' THEN 1 ELSE 0 END)', 'hosts_up' => 'SUM(CASE WHEN object_type = \'host\' AND state = 0 THEN 1 ELSE 0 END)', 'hosts_unreachable' => 'SUM(CASE WHEN object_type = \'host\' AND state = 2 THEN 1 ELSE 0 END)', 'hosts_unreachable_handled' => 'SUM(CASE WHEN object_type = \'host\' AND state = 2 AND acknowledged + in_downtime != 0 THEN 1 ELSE 0 END)', @@ -30,6 +29,8 @@ class GroupSummaryQuery extends IdoQuery 'hosts_down_unhandled' => 'SUM(CASE WHEN object_type = \'host\' AND state = 1 AND acknowledged + in_downtime = 0 THEN 1 ELSE 0 END)', 'hosts_pending' => 'SUM(CASE WHEN object_type = \'host\' AND state = 99 THEN 1 ELSE 0 END)', 'hosts_pending_last_state_change' => 'MAX(CASE WHEN object_type = \'host\' AND state = 99 THEN state_change ELSE 0 END)', + 'hosts_severity' => 'MAX(CASE WHEN object_type = \'host\' THEN severity ELSE 0 END)', + 'hosts_total' => 'SUM(CASE WHEN object_type = \'host\' THEN 1 ELSE 0 END)', 'hosts_unreachable_last_state_change_handled' => 'MAX(CASE WHEN object_type = \'host\' AND state = 2 AND acknowledged + in_downtime != 0 THEN state_change ELSE 0 END)', 'hosts_unreachable_last_state_change_unhandled' => 'MAX(CASE WHEN object_type = \'host\' AND state = 2 AND acknowledged + in_downtime = 0 THEN state_change ELSE 0 END)', 'hosts_up_last_state_change' => 'MAX(CASE WHEN object_type = \'host\' AND state = 0 THEN state_change ELSE 0 END)' From 37abc724de21b38f4f1156ae2ba36cb9dc51c449 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 21 May 2015 11:24:31 +0200 Subject: [PATCH 22/58] monitoring: Let the host group summary provide the column hosts_severity refs #8241 --- .../library/Monitoring/DataView/Hostgroupsummary.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php b/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php index 81725595a..a2c1dfd7a 100644 --- a/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php +++ b/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php @@ -22,6 +22,7 @@ class Hostgroupsummary extends DataView 'hosts_down_unhandled', 'hosts_pending', 'hosts_pending_last_state_change', + 'hosts_severity', 'hosts_total', 'hosts_unreachable_handled', 'hosts_unreachable_last_state_change_handled', @@ -52,16 +53,16 @@ class Hostgroupsummary extends DataView /** * {@inheritdoc} */ - public function getSearchColumns() + public static function getQueryName() { - return array('hostgroup', 'hostgroup_alias'); + return 'groupsummary'; } /** * {@inheritdoc} */ - public static function getQueryName() + public function getSearchColumns() { - return 'groupsummary'; + return array('hostgroup', 'hostgroup_alias'); } } From a52264aa3212c6f61c1391676230ba254a999783 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 21 May 2015 11:26:10 +0200 Subject: [PATCH 23/58] monitoring: Sort by hosts_severity when sorting the host group summary by severity refs #8241 --- modules/monitoring/application/controllers/ListController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 5e05de83b..a21edbbda 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -554,7 +554,7 @@ class Monitoring_ListController extends Controller $this->setupLimitControl(); $this->setupPaginationControl($this->view->hostgroups); $this->setupSortControl(array( - 'services_severity' => $this->translate('Severity'), + 'hosts_severity' => $this->translate('Severity'), 'hostgroup_alias' => $this->translate('Host Group Name'), 'services_total' => $this->translate('Total Services'), 'services_ok' => $this->translate('Services OK'), From ee6c669441ce8a8d34a269a8f7c7dfc76efaafda Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 21 May 2015 11:40:08 +0200 Subject: [PATCH 24/58] Deduplicate code and fix layout Move icon rendering code into a separate for better maintainabillity. refs #8665 --- .../controllers/ServicesController.php | 2 + .../application/views/helpers/IconImage.php | 46 +++++++++++++++++++ .../views/scripts/list/hosts.phtml | 6 +-- .../views/scripts/list/services.phtml | 6 +-- .../scripts/partials/host/object-header.phtml | 6 +-- .../partials/host/objects-header.phtml | 4 +- .../partials/service/object-header.phtml | 8 +--- .../partials/service/objects-header.phtml | 4 +- 8 files changed, 57 insertions(+), 25 deletions(-) create mode 100644 modules/monitoring/application/views/helpers/IconImage.php diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index ca9788ff2..6877aca02 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -50,6 +50,7 @@ class Monitoring_ServicesController extends Controller protected function handleCommandForm(ObjectsCommandForm $form) { $this->serviceList->setColumns(array( + 'host_icon_image', 'host_name', 'host_output', 'host_state', @@ -94,6 +95,7 @@ class Monitoring_ServicesController extends Controller ->handleRequest(); $this->view->checkNowForm = $checkNowForm; $this->serviceList->setColumns(array( + 'host_icon_image', 'host_name', 'host_output', 'host_state', diff --git a/modules/monitoring/application/views/helpers/IconImage.php b/modules/monitoring/application/views/helpers/IconImage.php new file mode 100644 index 000000000..2ed3b1d25 --- /dev/null +++ b/modules/monitoring/application/views/helpers/IconImage.php @@ -0,0 +1,46 @@ +host_icon_image && ! preg_match('/[\'"]/', $object->host_icon_image)) { + return $this->view->icon($this->view->resolveMacros($object->host_icon_image, $object)); + } + return ''; + } + + /** + * Display the image_icon of a MonitoredObject + * + * @param MonitoredObject|stdClass $object The host or service + * @return string + */ + public function service($object) + { + if ($object->service_icon_image && ! preg_match('/[\'"]/', $object->service_icon_image)) { + return $this->view->icon($this->view->resolveMacros($object->service_icon_image, $object)); + } + return ''; + } +} diff --git a/modules/monitoring/application/views/scripts/list/hosts.phtml b/modules/monitoring/application/views/scripts/list/hosts.phtml index 89c2e7d26..a83f3bb8a 100644 --- a/modules/monitoring/application/views/scripts/list/hosts.phtml +++ b/modules/monitoring/application/views/scripts/list/hosts.phtml @@ -52,9 +52,7 @@ if (count($hosts) === 0) { - host_icon_image && ! preg_match('/[\'"]/', $host->host_icon_image)): ?> - icon($this->resolveMacros($host->host_icon_image, $host)) ?> - + iconImage()->host($host) ?> hostFlags($host)) ?> qlink( $host->host_display_name, @@ -75,7 +73,7 @@ if (count($hosts) === 0) { 'host' => $host->host_name, 'service_problem' => 1, 'service_handled' => 0 - ), + ), array( 'style' => 'font-weight: normal', 'title' => sprintf( diff --git a/modules/monitoring/application/views/scripts/list/services.phtml b/modules/monitoring/application/views/scripts/list/services.phtml index 12ba232cc..964a0e982 100644 --- a/modules/monitoring/application/views/scripts/list/services.phtml +++ b/modules/monitoring/application/views/scripts/list/services.phtml @@ -58,12 +58,8 @@ if (count($services) === 0) {
perfdata($service->service_perfdata, true, 8) ?>
- + iconImage()->service($service) ?> serviceFlags($service)); ?> - - service_icon_image && ! preg_match('/[\'"]/', $service->service_icon_image)): ?> - icon($this->resolveMacros($service->service_icon_image, $service)) ?> - qlink( $service->service_display_name, $serviceLink, diff --git a/modules/monitoring/application/views/scripts/partials/host/object-header.phtml b/modules/monitoring/application/views/scripts/partials/host/object-header.phtml index 127f492e6..ed7edae79 100644 --- a/modules/monitoring/application/views/scripts/partials/host/object-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/object-header.phtml @@ -9,9 +9,7 @@ use Icinga\Module\Monitoring\Object\Host; prefixedTimeSince($object->host_last_state_change, true); ?> - host_icon_image && ! preg_match('/[\'"]/', $object->host_icon_image)): ?> - icon($this->resolveMacros($object->host_icon_image, $object)) ?> - + iconImage()->host($object) ?> escape($object->host_display_name); ?> host_display_name !== $object->host_name): ?> (escape($object->host_name); ?>) @@ -23,4 +21,4 @@ use Icinga\Module\Monitoring\Object\Host; render('partials/host/statusicons.phtml'); ?> - \ No newline at end of file + diff --git a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml index b6856609c..bce62db6b 100644 --- a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml @@ -17,10 +17,8 @@ $i = 0; host_state, true); ?>
+ iconImage()->host($host) ?> hostFlags($host)) ?> - host_icon_image && ! preg_match('/[\'"]/', $host->host_icon_image)): ?> - icon($this->resolveMacros($host->host_icon_image, $host)) ?> - escape($host->getName()); ?>
escape($host->host_output) ?> diff --git a/modules/monitoring/application/views/scripts/partials/service/object-header.phtml b/modules/monitoring/application/views/scripts/partials/service/object-header.phtml index b50aff9bc..c6dbb4730 100644 --- a/modules/monitoring/application/views/scripts/partials/service/object-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/service/object-header.phtml @@ -10,9 +10,7 @@ use Icinga\Module\Monitoring\Object\Service; prefixedTimeSince($object->host_last_state_change, true); ?> - host_icon_image && ! preg_match('/[\'"]/', $object->host_icon_image)): ?> - icon($this->resolveMacros($object->host_icon_image, $object)) ?> - + iconImage()->service($object) ?> escape($object->host_display_name); ?> host_display_name !== $object->host_name): ?> (escape($object->host_name); ?>) @@ -30,9 +28,7 @@ use Icinga\Module\Monitoring\Object\Service; prefixedTimeSince($object->service_last_state_change, true); ?> - service_icon_image && ! preg_match('/[\'"]/', $object->service_icon_image)): ?> - icon($this->resolveMacros($object->service_icon_image, $object)) ?> - + iconImage()->host($object) ?> translate('Service'); ?>: escape($object->service_display_name); ?> service_display_name !== $object->service_description): ?> (escape($object->service_description); ?>) diff --git a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml index fe1e4b16a..176c43d92 100644 --- a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml @@ -15,10 +15,8 @@ $i = 0; service_state, true); ?>
+ iconImage()->service($service) ?> serviceFlags($service)) ?> - service_icon_image && ! preg_match('/[\'"]/', $service->service_icon_image)): ?> - icon($this->resolveMacros($service->service_icon_image, $service)) ?> - escape($service->getName()); ?> translate('on') ?> From 82f9425b904f8567b373b56056669c32806fa6af Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 21 May 2015 12:01:58 +0200 Subject: [PATCH 25/58] Revert "Make ascending sort by host or service severity initiatable" This reverts commit 386d4db851aed056652d892d539de35b403c5062. The commit introduced the bug that changing the sort direction no longer changed the sort direction :) refs #9059 --- .../library/Monitoring/DataView/DataView.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/modules/monitoring/library/Monitoring/DataView/DataView.php b/modules/monitoring/library/Monitoring/DataView/DataView.php index 8212d7bb7..5175c4481 100644 --- a/modules/monitoring/library/Monitoring/DataView/DataView.php +++ b/modules/monitoring/library/Monitoring/DataView/DataView.php @@ -247,11 +247,11 @@ abstract class DataView implements QueryInterface, IteratorAggregate }; } - $globalDefaultOrder = isset($sortColumns['order']) ? $sortColumns['order'] : static::SORT_ASC; - $globalDefaultOrder = (strtoupper($globalDefaultOrder) === static::SORT_ASC) ? 'ASC' : 'DESC'; + $order = $order === null ? (isset($sortColumns['order']) ? $sortColumns['order'] : static::SORT_ASC) : $order; + $order = (strtoupper($order) === static::SORT_ASC) ? 'ASC' : 'DESC'; foreach ($sortColumns['columns'] as $column) { - list($column, $specificDefaultOrder) = $this->query->splitOrder($column); + list($column, $direction) = $this->query->splitOrder($column); if (! $this->isValidFilterTarget($column)) { throw new QueryException( mt('monitoring', 'The sort column "%s" is not allowed in "%s".'), @@ -259,10 +259,7 @@ abstract class DataView implements QueryInterface, IteratorAggregate get_class($this) ); } - $this->query->order( - $column, - $order === null && $specificDefaultOrder !== null ? $specificDefaultOrder : $globalDefaultOrder - ); + $this->query->order($column, $direction !== null ? $direction : $order); } $this->isSorted = true; return $this; From 195275a716be571bb2c94cf868c3f7364fe0ecfb Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 21 May 2015 12:17:25 +0200 Subject: [PATCH 26/58] monitoring: Don't hardcode sort direction of the severity columns fixes #9059 --- .../library/Monitoring/DataView/HostStatus.php | 5 +++-- .../library/Monitoring/DataView/ServiceStatus.php | 10 ++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/modules/monitoring/library/Monitoring/DataView/HostStatus.php b/modules/monitoring/library/Monitoring/DataView/HostStatus.php index 23df6d94a..31daabf65 100644 --- a/modules/monitoring/library/Monitoring/DataView/HostStatus.php +++ b/modules/monitoring/library/Monitoring/DataView/HostStatus.php @@ -94,10 +94,11 @@ class HostStatus extends DataView ), 'host_severity' => array( 'columns' => array( - 'host_severity DESC', + 'host_severity', 'host_last_state_change DESC', 'host_display_name ASC' - ) + ), + 'order' => self::SORT_DESC ), 'host_address' => array( 'columns' => array( diff --git a/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php b/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php index b4f1038da..40096ee02 100644 --- a/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php +++ b/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php @@ -130,19 +130,21 @@ class ServiceStatus extends DataView ), 'service_severity' => array( 'columns' => array( - 'service_severity DESC', + 'service_severity', 'service_last_state_change DESC', 'service_display_name ASC', 'host_display_name ASC' - ) + ), + 'order' => self::SORT_DESC ), 'host_severity' => array( 'columns' => array( - 'host_severity DESC', + 'host_severity', 'host_last_state_change DESC', 'host_display_name ASC', 'service_display_name ASC' - ) + ), + 'order' => self::SORT_DESC ), 'host_display_name' => array( 'columns' => array( From 58b3192ce3a48193b78736356d8b23254e10ee77 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 21 May 2015 12:26:27 +0200 Subject: [PATCH 27/58] monitoring: Add sort rules to the host group summary refs #8241 --- .../Monitoring/DataView/Hostgroupsummary.php | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php b/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php index a2c1dfd7a..0a5ec184e 100644 --- a/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php +++ b/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php @@ -65,4 +65,30 @@ class Hostgroupsummary extends DataView { return array('hostgroup', 'hostgroup_alias'); } + + /** + * {@inheritdoc} + */ + public function getSortRules() + { + return array( + 'hostgroup_alias' => array( + 'order' => self::SORT_ASC + ), + 'hosts_severity' => array( + 'columns' => array( + 'hosts_severity', + 'hostgroup_alias ASC' + ), + 'order' => self::SORT_DESC + ), + 'hosts_total' => array( + 'columns' => array( + 'hosts_total', + 'hostgroup_alias ASC' + ), + 'order' => self::SORT_ASC + ) + ); + } } From 4b9f7eb910b7ffab89b4810b3d4e3922f5c92ba3 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 21 May 2015 12:36:05 +0200 Subject: [PATCH 28/58] monitoring: Default to the sort rules of the host group summary refs #8241 --- modules/monitoring/application/controllers/ListController.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index a21edbbda..d3d573389 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -545,9 +545,7 @@ class Monitoring_ListController extends Controller 'services_unknown_unhandled', 'services_warning_handled', 'services_warning_unhandled' - ))->order('hostgroup_alias'); - // TODO(el): Can't default to the sort rules of the data view because it's meant for both host groups and - // service groups. We should separate them. + )); $this->filterQuery($query); $this->view->hostgroups = $query; From 73eb8cc805617e84dd4797369a4abd22e1e38b9a Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 21 May 2015 12:37:53 +0200 Subject: [PATCH 29/58] monitoring: Add sort rule for total services to the host group summary refs #8241 --- .../library/Monitoring/DataView/Hostgroupsummary.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php b/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php index 0a5ec184e..63c04df79 100644 --- a/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php +++ b/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php @@ -88,6 +88,13 @@ class Hostgroupsummary extends DataView 'hostgroup_alias ASC' ), 'order' => self::SORT_ASC + ), + 'services_total' => array( + 'columns' => array( + 'services_total', + 'hostgroup_alias ASC' + ), + 'order' => self::SORT_ASC ) ); } From 89bac33595ec22c417472f7fbe0ac44bf541ff7d Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 21 May 2015 12:38:20 +0200 Subject: [PATCH 30/58] monitoring: Fix sort control columns for the host group summary refs #8241 --- .../monitoring/application/controllers/ListController.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index d3d573389..be3139b72 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -554,12 +554,8 @@ class Monitoring_ListController extends Controller $this->setupSortControl(array( 'hosts_severity' => $this->translate('Severity'), 'hostgroup_alias' => $this->translate('Host Group Name'), - 'services_total' => $this->translate('Total Services'), - 'services_ok' => $this->translate('Services OK'), - 'services_unknown' => $this->translate('Services UNKNOWN'), - 'services_critical' => $this->translate('Services CRITICAL'), - 'services_warning' => $this->translate('Services WARNING'), - 'services_pending' => $this->translate('Services PENDING') + 'hosts_total' => $this->translate('Total Hosts'), + 'services_total' => $this->translate('Total Services') ), $query); } From e7396ea49cb853348e2d638816a58e55f84bff6f Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 21 May 2015 12:38:58 +0200 Subject: [PATCH 31/58] monitoring: Add services_severity to the service group summary data view refs #8241 --- .../library/Monitoring/DataView/Servicegroupsummary.php | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php b/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php index 3633248f4..c9f60f75c 100644 --- a/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php +++ b/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php @@ -27,6 +27,7 @@ class Servicegroupsummary extends DataView 'services_ok_last_state_change', 'services_pending', 'services_pending_last_state_change', + 'services_severity', 'services_total', 'services_unknown_handled', 'services_unknown_last_state_change_handled', From 1a1f93db23d1b27907add455a3f8a75ff2c21fc4 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 21 May 2015 12:41:29 +0200 Subject: [PATCH 32/58] monitoring: Add sort rules to the service group summary refs #8241 --- .../DataView/Servicegroupsummary.php | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php b/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php index c9f60f75c..11d6ec07e 100644 --- a/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php +++ b/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php @@ -63,4 +63,30 @@ class Servicegroupsummary extends DataView { return array('servicegroup', 'servicegroup_alias'); } + + /** + * {@inheritdoc} + */ + public function getSortRules() + { + return array( + 'servicegroup_alias' => array( + 'order' => self::SORT_ASC + ), + 'services_severity' => array( + 'columns' => array( + 'services_severity', + 'servicegroup_alias ASC' + ), + 'order' => self::SORT_DESC + ), + 'services_total' => array( + 'columns' => array( + 'services_total', + 'servicegroup_alias ASC' + ), + 'order' => self::SORT_ASC + ) + ); + } } From 0db7cfca885ae7cc0da78cd8574e28547a292328 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 21 May 2015 12:41:59 +0200 Subject: [PATCH 33/58] monitoring: Default to the sort rules of the service group summary refs #8241 --- .../controllers/ListController.php | 40 +++++++++---------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index be3139b72..dc82fcf65 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -470,34 +470,32 @@ class Monitoring_ListController extends Controller $this->setAutorefreshInterval(12); $query = $this->backend->select()->from('servicegroupsummary', array( - 'servicegroup_name', - 'servicegroup_alias', - 'hosts_up', - 'hosts_unreachable_handled', - 'hosts_unreachable_unhandled', 'hosts_down_handled', 'hosts_down_unhandled', 'hosts_pending', - 'services_ok', - 'services_unknown_handled', - 'services_unknown_unhandled', + 'hosts_unreachable_handled', + 'hosts_unreachable_unhandled', + 'hosts_up', + 'servicegroup_alias', + 'servicegroup_name', 'services_critical_handled', - 'services_critical_unhandled', - 'services_warning_handled', - 'services_warning_unhandled', - 'services_pending', - 'services_ok_last_state_change', - 'services_pending_last_state_change', - 'services_warning_last_state_change_handled', 'services_critical_last_state_change_handled', - 'services_unknown_last_state_change_handled', - 'services_warning_last_state_change_unhandled', 'services_critical_last_state_change_unhandled', + 'services_critical_unhandled', + 'services_ok', + 'services_ok_last_state_change', + 'services_pending', + 'services_pending_last_state_change', + 'services_total', + 'services_unknown_handled', + 'services_unknown_last_state_change_handled', 'services_unknown_last_state_change_unhandled', - 'services_total' - ))->order('servicegroup_alias'); - // TODO(el): Can't default to the sort rules of the data view because it's meant for both host groups and - // service groups. We should separate them. + 'services_unknown_unhandled', + 'services_warning_handled', + 'services_warning_last_state_change_handled', + 'services_warning_last_state_change_unhandled', + 'services_warning_unhandled' + )); $this->filterQuery($query); $this->view->servicegroups = $query; From e0c6ce58c393ca47327cfde1232b7796dc303db8 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 21 May 2015 12:42:53 +0200 Subject: [PATCH 34/58] monitoring: Fix sort control columns for the service group summary refs #8241 --- .../monitoring/application/controllers/ListController.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index dc82fcf65..c08acf2ad 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -504,12 +504,7 @@ class Monitoring_ListController extends Controller $this->setupSortControl(array( 'services_severity' => $this->translate('Severity'), 'servicegroup_alias' => $this->translate('Service Group Name'), - 'services_total' => $this->translate('Total Services'), - 'services_ok' => $this->translate('Services OK'), - 'services_unknown' => $this->translate('Services UNKNOWN'), - 'services_critical' => $this->translate('Services CRITICAL'), - 'services_warning' => $this->translate('Services WARNING'), - 'services_pending' => $this->translate('Services PENDING') + 'services_total' => $this->translate('Total Services') ), $query); } From ad5ab16b3f175a6e93553551f03c4c438b2e1710 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 21 May 2015 12:43:27 +0200 Subject: [PATCH 35/58] monitoring: Drop the Groupsummary data view We have Hostgroupsummary and Servicegroupsummary now. refs #8241 --- .../Monitoring/DataView/Groupsummary.php | 68 ------------------- 1 file changed, 68 deletions(-) delete mode 100644 modules/monitoring/library/Monitoring/DataView/Groupsummary.php diff --git a/modules/monitoring/library/Monitoring/DataView/Groupsummary.php b/modules/monitoring/library/Monitoring/DataView/Groupsummary.php deleted file mode 100644 index d27bf9ee8..000000000 --- a/modules/monitoring/library/Monitoring/DataView/Groupsummary.php +++ /dev/null @@ -1,68 +0,0 @@ - array( - 'columns' => array('services_severity'), - 'order' => self::SORT_DESC - ) - ); - } -} From 0c72686ba12dd280d86aee849a2f6e3199195791 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 21 May 2015 12:46:47 +0200 Subject: [PATCH 36/58] monitoring: Make display_name columns case insensitive The display_name columns should be case insenstive because we now support them when searching. refs #8241 --- .../library/Monitoring/Backend/Ido/Query/HoststatusQuery.php | 2 +- .../library/Monitoring/Backend/Ido/Query/StatusQuery.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php index 23a8b585a..5d32550e7 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php @@ -11,7 +11,7 @@ class HoststatusQuery extends IdoQuery 'hosts' => array( 'host' => 'ho.name1 COLLATE latin1_general_ci', 'host_name' => 'ho.name1 COLLATE latin1_general_ci', - 'host_display_name' => 'h.display_name', + 'host_display_name' => 'h.display_name COLLATE latin1_general_ci', 'host_alias' => 'h.alias', 'host_address' => 'h.address', 'host_ipv4' => 'INET_ATON(h.address)', diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php index 17a12259e..a070c983c 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php @@ -36,7 +36,7 @@ class StatusQuery extends IdoQuery 'hosts' => array( 'host' => 'ho.name1 COLLATE latin1_general_ci', 'host_name' => 'ho.name1', - 'host_display_name' => 'h.display_name', + 'host_display_name' => 'h.display_name COLLATE latin1_general_ci', 'host_alias' => 'h.alias', 'host_address' => 'h.address', 'host_ipv4' => 'INET_ATON(h.address)', @@ -174,7 +174,7 @@ class StatusQuery extends IdoQuery 'service_host_name' => 'so.name1', 'service' => 'so.name2 COLLATE latin1_general_ci', 'service_description' => 'so.name2', - 'service_display_name' => 's.display_name', + 'service_display_name' => 's.display_name COLLATE latin1_general_ci', 'service_icon_image' => 's.icon_image', 'service_action_url' => 's.action_url', 'service_notes_url' => 's.notes_url', From 57328aa6ed5f2e1b1d173430eb7cc44f1fda9040 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 21 May 2015 13:58:54 +0200 Subject: [PATCH 37/58] monitoring: Make host group and service group alias columns case insensitive The alias columns should be case insenstive because we now support them when searching. refs #8241 --- .../Monitoring/Backend/Ido/Query/GroupsummaryQuery.php | 8 ++++---- .../Monitoring/Backend/Ido/Query/HoststatusQuery.php | 2 +- .../library/Monitoring/Backend/Ido/Query/StatusQuery.php | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php index df1a38d88..da33c2bc6 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php @@ -15,8 +15,8 @@ class GroupSummaryQuery extends IdoQuery */ protected $columnMap = array( 'hoststatussummary' => array( - 'hostgroup' => 'hostgroup', - 'hostgroup_alias' => 'hostgroup_alias', + 'hostgroup' => 'hostgroup COLLATE latin1_general_ci', + 'hostgroup_alias' => 'hostgroup_alias COLLATE latin1_general_ci', 'hostgroup_name' => 'hostgroup_name', 'hosts_up' => 'SUM(CASE WHEN object_type = \'host\' AND state = 0 THEN 1 ELSE 0 END)', 'hosts_unreachable' => 'SUM(CASE WHEN object_type = \'host\' AND state = 2 THEN 1 ELSE 0 END)', @@ -36,8 +36,8 @@ class GroupSummaryQuery extends IdoQuery 'hosts_up_last_state_change' => 'MAX(CASE WHEN object_type = \'host\' AND state = 0 THEN state_change ELSE 0 END)' ), 'servicestatussummary' => array( - 'servicegroup' => 'servicegroup', - 'servicegroup_alias' => 'servicegroup_alias', + 'servicegroup' => 'servicegroup COLLATE latin1_general_ci', + 'servicegroup_alias' => 'servicegroup_alias COLLATE latin1_general_ci', 'servicegroup_name' => 'servicegroup_name', 'services_critical' => 'SUM(CASE WHEN object_type = \'service\' AND state = 2 THEN 1 ELSE 0 END)', 'services_critical_handled' => 'SUM(CASE WHEN object_type = \'service\' AND state = 2 AND acknowledged + in_downtime + host_state > 0 THEN 1 ELSE 0 END)', diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php index 5d32550e7..ec9e6bd32 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php @@ -85,7 +85,7 @@ class HoststatusQuery extends IdoQuery 'hostgroups' => array( 'hostgroup' => 'hgo.name1 COLLATE latin1_general_ci', 'hostgroup_name' => 'hgo.name1', - 'hostgroup_alias' => 'hg.alias' + 'hostgroup_alias' => 'hg.alias COLLATE latin1_general_ci' ), 'servicegroups' => array( 'servicegroup' => 'sgo.name1 COLLATE latin1_general_ci', diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php index a070c983c..84a7b64f1 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php @@ -162,12 +162,12 @@ class StatusQuery extends IdoQuery 'hostgroups' => array( 'hostgroup' => 'hgo.name1 COLLATE latin1_general_ci', 'hostgroup_name' => 'hgo.name1', - 'hostgroup_alias' => 'hg.alias' + 'hostgroup_alias' => 'hg.alias COLLATE latin1_general_ci' ), 'servicegroups' => array( 'servicegroup' => 'sgo.name1 COLLATE latin1_general_ci', 'servicegroup_name' => 'sgo.name1', - 'servicegroup_alias' => 'sg.alias' + 'servicegroup_alias' => 'sg.alias COLLATE latin1_general_ci' ), 'services' => array( 'service_host' => 'so.name1 COLLATE latin1_general_ci', From c47465a7329afaa32f57dd51103298b5057f4e71 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 21 May 2015 14:04:04 +0200 Subject: [PATCH 38/58] lib/filter: Fix check against unset search columns refs #8241 --- library/Icinga/Web/Widget/FilterEditor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Web/Widget/FilterEditor.php b/library/Icinga/Web/Widget/FilterEditor.php index 07640872b..2d64e4c2b 100644 --- a/library/Icinga/Web/Widget/FilterEditor.php +++ b/library/Icinga/Web/Widget/FilterEditor.php @@ -216,7 +216,7 @@ class FilterEditor extends AbstractWidget $filter = $this->getFilter(); if ($search !== null) { - if ($this->searchColumns === null) { + if (empty($this->searchColumns)) { if (strpos($search, '=') === false) { Notification::error(mt('monitoring', 'Cannot search here')); return $this; From 0002c0be260c0299ab92e7368f82e17ce4e53b45 Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Thu, 21 May 2015 14:40:52 +0200 Subject: [PATCH 39/58] Provide default config name for Module::getConfig() --- library/Icinga/Application/Modules/Module.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Application/Modules/Module.php b/library/Icinga/Application/Modules/Module.php index c1fd84513..e8481aab8 100644 --- a/library/Icinga/Application/Modules/Module.php +++ b/library/Icinga/Application/Modules/Module.php @@ -600,7 +600,7 @@ class Module * * @return Config */ - public function getConfig($file = null) + public function getConfig($file = 'config') { return $this->app->getConfig()->module($this->name, $file); } From e8e3b940affa3e0f2458d080a293f7f92b7d5306 Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Thu, 21 May 2015 14:34:43 +0200 Subject: [PATCH 40/58] Use CustomVariable names case insensitive refs #8696 --- .../Monitoring/Backend/Ido/Query/IdoQuery.php | 36 +++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php index fda2f188e..5e27f6e00 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php @@ -86,6 +86,18 @@ abstract class IdoQuery extends DbQuery */ protected $customVars = array(); + /** + * Printf compatible string to joins custom vars + * + * - %1$s Source field, contain the object_id + * - %2$s Alias used for the relation + * - %3$s Name of the CustomVariable + * + * @var string + */ + private $customVarsJoinTemplate = + '%1$s = %2$s.object_id AND %2$s.varname = %3$s'; + /** * An array with all 'virtual' tables that are already joined * @@ -393,14 +405,17 @@ abstract class IdoQuery extends DbQuery { parent::init(); $this->prefix = $this->ds->getTablePrefix(); - - if ($this->ds->getDbType() === 'oracle') { + $dbType = $this->ds->getDbType(); + if ($dbType === 'oracle') { $this->initializeForOracle(); - } elseif ($this->ds->getDbType() === 'pgsql') { + } elseif ($dbType === 'pgsql') { $this->initializeForPostgres(); + $this->customVarsJoinTemplate = + '%1$s = %2$s.object_id AND LOWER(%2$s.varname) = %3$s'; + } elseif ($dbType === 'mysql') { + $this->customVarsJoinTemplate .= ' COLLATE latin1_general_ci'; } $this->dbSelect(); - $this->select->columns($this->columns); //$this->joinBaseTables(); $this->prepareAliasIndexes(); @@ -604,14 +619,14 @@ abstract class IdoQuery extends DbQuery protected function hasCustomvar($customvar) { - return array_key_exists($customvar, $this->customVars); + return array_key_exists(strtolower($customvar), $this->customVars); } protected function joinCustomvar($customvar) { // TODO: This is not generic enough yet list($type, $name) = $this->customvarNameToTypeName($customvar); - $alias = ($type === 'host' ? 'hcv_' : 'scv_') . strtolower($name); + $alias = ($type === 'host' ? 'hcv_' : 'scv_') . $name; $this->customVars[$customvar] = $alias; @@ -622,12 +637,12 @@ abstract class IdoQuery extends DbQuery } else { $leftcol = 'h.' . $type . '_object_id'; } + $joinOn = sprintf( - '%s = %s.object_id AND %s.varname = %s', + $this->customVarsJoinTemplate, $leftcol, $alias, - $alias, - $this->db->quote(strtoupper($name)) + $this->db->quote($name) ); $this->select->joinLeft( @@ -641,6 +656,7 @@ abstract class IdoQuery extends DbQuery protected function customvarNameToTypeName($customvar) { + $customvar = strtolower($customvar); // TODO: Improve this: if (! preg_match('~^_(host|service)_([a-zA-Z0-9_]+)$~', $customvar, $m)) { throw new ProgrammingError( @@ -658,7 +674,7 @@ abstract class IdoQuery extends DbQuery protected function getCustomvarColumnName($customvar) { - return $this->customVars[$customvar] . '.varvalue'; + return $this->customVars[strtolower($customvar)] . '.varvalue'; } public function aliasToColumnName($alias) From 598ef1e8f409b61e47ee1070009bc40d2484fef9 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 21 May 2015 14:59:12 +0200 Subject: [PATCH 41/58] Add alt-text to icon_images Print alt-text as title and alt-attribute in the helper class and add the alt-column to the backend query. refs #9300 --- .../controllers/HostsController.php | 2 ++ .../application/controllers/ListController.php | 2 ++ .../controllers/ServicesController.php | 4 ++++ .../application/views/helpers/IconImage.php | 18 ++++++++++++++++-- .../Backend/Ido/Query/StatusQuery.php | 2 ++ .../Monitoring/DataView/ServiceStatus.php | 2 -- .../library/Monitoring/Object/Host.php | 1 + .../library/Monitoring/Object/Service.php | 2 ++ 8 files changed, 29 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index ac55ade9b..78c8eaa7e 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -54,6 +54,7 @@ class Monitoring_HostsController extends Controller { $this->hostList->setColumns(array( 'host_icon_image', + 'host_icon_image_alt', 'host_name', 'host_state', 'host_problem', @@ -96,6 +97,7 @@ class Monitoring_HostsController extends Controller $this->view->checkNowForm = $checkNowForm; $this->hostList->setColumns(array( 'host_icon_image', + 'host_icon_image_alt', 'host_name', 'host_state', 'host_problem', diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 92c42d4ad..6b864be24 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -70,6 +70,7 @@ class Monitoring_ListController extends Controller $this->setAutorefreshInterval(10); $query = $this->backend->select()->from('hostStatus', array_merge(array( 'host_icon_image', + 'host_icon_image_alt', 'host_name', 'host_display_name', 'host_state' => $stateColumn, @@ -162,6 +163,7 @@ class Monitoring_ListController extends Controller 'service_attempt', 'service_last_state_change' => $stateChangeColumn, 'service_icon_image', + 'service_icon_image_alt', 'service_is_flapping', 'service_state_type', 'service_handled', diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index 6877aca02..1a8ec9a58 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -51,12 +51,14 @@ class Monitoring_ServicesController extends Controller { $this->serviceList->setColumns(array( 'host_icon_image', + 'host_icon_image_alt', 'host_name', 'host_output', 'host_state', 'host_problem', 'host_handled', 'service_icon_image', + 'service_icon_image_alt', 'service_description', 'service_state', 'service_problem', @@ -96,12 +98,14 @@ class Monitoring_ServicesController extends Controller $this->view->checkNowForm = $checkNowForm; $this->serviceList->setColumns(array( 'host_icon_image', + 'host_icon_image_alt', 'host_name', 'host_output', 'host_state', 'host_problem', 'host_handled', 'service_icon_image', + 'service_icon_image_alt', 'service_output', 'service_description', 'service_state', diff --git a/modules/monitoring/application/views/helpers/IconImage.php b/modules/monitoring/application/views/helpers/IconImage.php index 2ed3b1d25..416a4f335 100644 --- a/modules/monitoring/application/views/helpers/IconImage.php +++ b/modules/monitoring/application/views/helpers/IconImage.php @@ -25,7 +25,14 @@ class Zend_View_Helper_IconImage extends Zend_View_Helper_Abstract public function host($object) { if ($object->host_icon_image && ! preg_match('/[\'"]/', $object->host_icon_image)) { - return $this->view->icon($this->view->resolveMacros($object->host_icon_image, $object)); + return $this->view->img( + 'img/icons/' . $this->view->resolveMacros($object->host_icon_image, $object), + null, + array( + 'alt' => $object->host_icon_image_alt, + 'title' => $object->host_icon_image_alt + ) + ); } return ''; } @@ -39,7 +46,14 @@ class Zend_View_Helper_IconImage extends Zend_View_Helper_Abstract public function service($object) { if ($object->service_icon_image && ! preg_match('/[\'"]/', $object->service_icon_image)) { - return $this->view->icon($this->view->resolveMacros($object->service_icon_image, $object)); + return $this->view->img( + 'img/icons/' . $this->view->resolveMacros($object->service_icon_image, $object), + null, + array( + 'alt' => $object->service_icon_image_alt, + 'title' => $object->service_icon_image_alt + ) + ); } return ''; } diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php index 17a12259e..14ffb438b 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php @@ -41,6 +41,7 @@ class StatusQuery extends IdoQuery 'host_address' => 'h.address', 'host_ipv4' => 'INET_ATON(h.address)', 'host_icon_image' => 'h.icon_image', + 'host_icon_image_alt' => 'h.icon_image_alt', 'host_action_url' => 'h.action_url', 'host_notes_url' => 'h.notes_url' ), @@ -176,6 +177,7 @@ class StatusQuery extends IdoQuery 'service_description' => 'so.name2', 'service_display_name' => 's.display_name', 'service_icon_image' => 's.icon_image', + 'service_icon_image_alt' => 's.icon_image_alt', 'service_action_url' => 's.action_url', 'service_notes_url' => 's.notes_url', 'object_type' => '(\'service\')' diff --git a/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php b/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php index b4f1038da..18bf1aa80 100644 --- a/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php +++ b/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php @@ -40,7 +40,6 @@ class ServiceStatus extends DataView 'service_unhandled', 'service_output', 'service_last_state_change', - 'service_icon_image', 'service_long_output', 'service_is_flapping', 'service_state_type', @@ -60,7 +59,6 @@ class ServiceStatus extends DataView 'service_last_notification', 'service_check_command', 'service_current_notification_number', - 'host_icon_image', 'host_acknowledged', 'host_output', 'host_long_output', diff --git a/modules/monitoring/library/Monitoring/Object/Host.php b/modules/monitoring/library/Monitoring/Object/Host.php index 2c01fe0eb..a158625b5 100644 --- a/modules/monitoring/library/Monitoring/Object/Host.php +++ b/modules/monitoring/library/Monitoring/Object/Host.php @@ -90,6 +90,7 @@ class Host extends MonitoredObject { $columns = array( 'host_icon_image', + 'host_icon_image_alt', 'host_acknowledged', 'host_action_url', 'host_active_checks_enabled', diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index fec5de238..0e8c975f2 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -107,6 +107,7 @@ class Service extends MonitoredObject { return $this->backend->select()->from('serviceStatus', array( 'host_icon_image', + 'host_icon_image_alt', 'host_acknowledged', 'host_active_checks_enabled', 'host_address', @@ -120,6 +121,7 @@ class Service extends MonitoredObject 'host_passive_checks_enabled', 'host_state', 'service_icon_image', + 'service_icon_image_alt', 'service_acknowledged', 'service_action_url', 'service_active_checks_enabled', From f808d373ea8124df7101639b0ea650a1cecf8097 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 21 May 2015 15:02:23 +0200 Subject: [PATCH 42/58] Display image icon tooltip instantly refs #9300 --- modules/monitoring/application/views/helpers/IconImage.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/views/helpers/IconImage.php b/modules/monitoring/application/views/helpers/IconImage.php index 416a4f335..e0e969db4 100644 --- a/modules/monitoring/application/views/helpers/IconImage.php +++ b/modules/monitoring/application/views/helpers/IconImage.php @@ -30,7 +30,8 @@ class Zend_View_Helper_IconImage extends Zend_View_Helper_Abstract null, array( 'alt' => $object->host_icon_image_alt, - 'title' => $object->host_icon_image_alt + 'title' => $object->host_icon_image_alt, + 'data-tooltip-delay' => 0 ) ); } @@ -51,7 +52,8 @@ class Zend_View_Helper_IconImage extends Zend_View_Helper_Abstract null, array( 'alt' => $object->service_icon_image_alt, - 'title' => $object->service_icon_image_alt + 'title' => $object->service_icon_image_alt, + 'data-tooltip-delay' => 0 ) ); } From 7c04664888d1bad237312fd3ecbade6016bf5e40 Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Thu, 21 May 2015 16:09:03 +0200 Subject: [PATCH 43/58] Make MySQL collation syntax default Overwrite customVarsJoinTemplate for Postgres and Oracle. refs #8696 --- .../library/Monitoring/Backend/Ido/Query/IdoQuery.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php index 5e27f6e00..9371399bc 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php @@ -96,7 +96,7 @@ abstract class IdoQuery extends DbQuery * @var string */ private $customVarsJoinTemplate = - '%1$s = %2$s.object_id AND %2$s.varname = %3$s'; + '%1$s = %2$s.object_id AND %2$s.varname = %3$s COLLATE latin1_general_ci'; /** * An array with all 'virtual' tables that are already joined @@ -363,6 +363,8 @@ abstract class IdoQuery extends DbQuery $this->object_id = $this->host_id = $this->service_id = $this->hostgroup_id = $this->servicegroup_id = $this->contact_id = $this->contactgroup_id = 'id'; + $this->customVarsJoinTemplate = + '%1$s = %2$s.object_id AND LOWER(%2$s.varname) = %3$s'; foreach ($this->columnMap as &$columns) { foreach ($columns as &$value) { $value = preg_replace('/UNIX_TIMESTAMP/', 'localts2unixts', $value); @@ -376,6 +378,8 @@ abstract class IdoQuery extends DbQuery */ private function initializeForPostgres() { + $this->customVarsJoinTemplate = + '%1$s = %2$s.object_id AND LOWER(%2$s.varname) = %3$s'; foreach ($this->columnMap as $table => & $columns) { foreach ($columns as $key => & $value) { $value = preg_replace('/ COLLATE .+$/', '', $value, -1, $count); @@ -410,10 +414,6 @@ abstract class IdoQuery extends DbQuery $this->initializeForOracle(); } elseif ($dbType === 'pgsql') { $this->initializeForPostgres(); - $this->customVarsJoinTemplate = - '%1$s = %2$s.object_id AND LOWER(%2$s.varname) = %3$s'; - } elseif ($dbType === 'mysql') { - $this->customVarsJoinTemplate .= ' COLLATE latin1_general_ci'; } $this->dbSelect(); $this->select->columns($this->columns); From ce9110d22d0f8114ebd5902f5e9577724c85fdc0 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 20 May 2015 10:31:58 +0200 Subject: [PATCH 44/58] Revert "Add proper respond http codes to service and host controller" This reverts commit 6df031dc786256e0bd42f8047d6c308e90abedf6. I revert this commit for the following reasons: - MissingParameterException must not be thrown manually because we have UrlParams::getRequired() which was UrlParams::req() before. - The commit introduces the untranslated string 'host or service'. - 4xx are client, not server errors. - Copy and paste code for the stack trace handling in the ErrorController. refs #6281 --- application/controllers/ErrorController.php | 6 +----- .../application/controllers/HostController.php | 13 +------------ .../application/controllers/ServiceController.php | 13 +------------ 3 files changed, 3 insertions(+), 29 deletions(-) diff --git a/application/controllers/ErrorController.php b/application/controllers/ErrorController.php index b1343dc81..a77d36f4f 100644 --- a/application/controllers/ErrorController.php +++ b/application/controllers/ErrorController.php @@ -34,11 +34,7 @@ class ErrorController extends ActionController $path = preg_split('~/~', $path); $path = array_shift($path); $this->getResponse()->setHttpResponseCode(404); - $title = preg_replace('/\r?\n.*$/s', '', $exception->getMessage()); - $this->view->title = 'Server error: ' . $title; - if ($this->getInvokeArg('displayExceptions')) { - $this->view->stackTrace = $exception->getTraceAsString(); - } + $this->view->message = $this->translate('Page not found.'); if ($modules->hasInstalled($path) && ! $modules->hasEnabled($path)) { $this->view->message .= ' ' . sprintf( $this->translate('Enabling the "%s" module might help!'), diff --git a/modules/monitoring/application/controllers/HostController.php b/modules/monitoring/application/controllers/HostController.php index 7693023eb..2fc2bc7f3 100644 --- a/modules/monitoring/application/controllers/HostController.php +++ b/modules/monitoring/application/controllers/HostController.php @@ -1,7 +1,6 @@ params->get('host') === null) { - throw new MissingParameterException( - $this->translate('Required parameter \'%s\' is missing'), - 'host' - ); - } - $host = new Host($this->backend, $this->params->get('host')); $this->applyRestriction('monitoring/hosts/filter', $host); if ($host->fetch() === false) { - throw new Zend_Controller_Action_Exception( - sprintf($this->translate('Host \'%s\' not found'), $this->params->get('host')), - 404 - ); + throw new Zend_Controller_Action_Exception($this->translate('Host not found')); } $this->object = $host; $this->createTabs(); diff --git a/modules/monitoring/application/controllers/ServiceController.php b/modules/monitoring/application/controllers/ServiceController.php index e61c4685d..d6105df4d 100644 --- a/modules/monitoring/application/controllers/ServiceController.php +++ b/modules/monitoring/application/controllers/ServiceController.php @@ -1,7 +1,6 @@ params->get('host') === null || $this->params->get('service') === null) { - throw new MissingParameterException( - $this->translate('One of the required parameters \'%s\' is missing'), - 'host or service' - ); - } - $service = new Service($this->backend, $this->params->get('host'), $this->params->get('service')); $this->applyRestriction('monitoring/services/filter', $service); if ($service->fetch() === false) { - throw new Zend_Controller_Action_Exception( - sprintf($this->translate('Service \'%s\' not found'), $this->params->get('service')), - 404 - ); + throw new Zend_Controller_Action_Exception($this->translate('Service not found')); } $this->object = $service; $this->createTabs(); From e8c704b98d46abb1304e098b744f61f8d2829c2b Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 20 May 2015 10:36:05 +0200 Subject: [PATCH 45/58] monitoring: Fix HTTP response code when showing an invalid service refs #6281 --- .../application/controllers/ServiceController.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/application/controllers/ServiceController.php b/modules/monitoring/application/controllers/ServiceController.php index d6105df4d..2886650c9 100644 --- a/modules/monitoring/application/controllers/ServiceController.php +++ b/modules/monitoring/application/controllers/ServiceController.php @@ -21,17 +21,17 @@ class Monitoring_ServiceController extends MonitoredObjectController /** * Fetch the requested service from the monitoring backend - * - * @throws Zend_Controller_Action_Exception If the service was not found */ public function init() { - $service = new Service($this->backend, $this->params->get('host'), $this->params->get('service')); + $service = new Service( + $this->backend, $this->params->getRequired('host'), $this->params->getRequired('service') + ); $this->applyRestriction('monitoring/services/filter', $service); if ($service->fetch() === false) { - throw new Zend_Controller_Action_Exception($this->translate('Service not found')); + $this->httpNotFound($this->translate('Service not found')); } $this->object = $service; $this->createTabs(); From 0b81a1130f9df955801273c0a91c2c2d3e0ef0cb Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 20 May 2015 10:38:00 +0200 Subject: [PATCH 46/58] monitoring: Fix HTTP response code when showing an invalid host refs #6281 --- .../monitoring/application/controllers/HostController.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/application/controllers/HostController.php b/modules/monitoring/application/controllers/HostController.php index 2fc2bc7f3..464da200c 100644 --- a/modules/monitoring/application/controllers/HostController.php +++ b/modules/monitoring/application/controllers/HostController.php @@ -21,17 +21,15 @@ class Monitoring_HostController extends MonitoredObjectController /** * Fetch the requested host from the monitoring backend - * - * @throws Zend_Controller_Action_Exception If the host was not found */ public function init() { - $host = new Host($this->backend, $this->params->get('host')); + $host = new Host($this->backend, $this->params->getRequired('host')); $this->applyRestriction('monitoring/hosts/filter', $host); if ($host->fetch() === false) { - throw new Zend_Controller_Action_Exception($this->translate('Host not found')); + $this->httpNotFound($this->translate('Host not found')); } $this->object = $host; $this->createTabs(); From 54f72377c5cb9e3ac388dced40dda61a64032d9b Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 21 May 2015 16:28:00 +0200 Subject: [PATCH 47/58] Do not display mouse-over effect in comment multi-view --- .../views/scripts/partials/comment/comment-detail.phtml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/application/views/scripts/partials/comment/comment-detail.phtml b/modules/monitoring/application/views/scripts/partials/comment/comment-detail.phtml index 98ee0534b..46de949d2 100644 --- a/modules/monitoring/application/views/scripts/partials/comment/comment-detail.phtml +++ b/modules/monitoring/application/views/scripts/partials/comment/comment-detail.phtml @@ -1,11 +1,10 @@ objecttype === 'service'): ?> icon('service', $this->translate('Service')); ?> - link()->service( - $comment->service_description, + translate('%s on %s', 'Service running on host'), $comment->service_display_name, - $comment->host_name, $comment->host_display_name - ); ?> + ) ?> icon('host', $this->translate('Host')); ?> link()->host($comment->host_name, $comment->host_display_name); ?> From c4ed49cb1a0a12ca153606cb1949b42ba740011b Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 21 May 2015 16:43:58 +0200 Subject: [PATCH 48/58] lib: Add HttpNotFoundException The HttpNotFoundException should be used for sending a HTTP 404 response w/ a custom message. There's also Zend_Controller_Action_Exception but this exception will always show 'Page not found' because we want to hide messages generated by Zend, like 'Action "foobar" does not exist and was not trapped in __call()'. refs #6281 --- library/Icinga/Exception/HttpNotFoundException.php | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 library/Icinga/Exception/HttpNotFoundException.php diff --git a/library/Icinga/Exception/HttpNotFoundException.php b/library/Icinga/Exception/HttpNotFoundException.php new file mode 100644 index 000000000..09febf0b4 --- /dev/null +++ b/library/Icinga/Exception/HttpNotFoundException.php @@ -0,0 +1,11 @@ + Date: Thu, 21 May 2015 16:54:00 +0200 Subject: [PATCH 49/58] Throw HttpNotFoundException on Controller::httpNotFound() refs #6281 --- library/Icinga/Web/Controller.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/Icinga/Web/Controller.php b/library/Icinga/Web/Controller.php index 0975d4c13..cdc049c87 100644 --- a/library/Icinga/Web/Controller.php +++ b/library/Icinga/Web/Controller.php @@ -3,7 +3,7 @@ namespace Icinga\Web; -use Zend_Controller_Action_Exception; +use Icinga\Exception\HttpNotFoundException; use Icinga\Data\Sortable; use Icinga\Data\QueryInterface; use Icinga\Web\Controller\ModuleActionController; @@ -55,11 +55,11 @@ class Controller extends ModuleActionController * * @param $message * - * @throws Zend_Controller_Action_Exception + * @throws HttpNotFoundException */ public function httpNotFound($message) { - throw new Zend_Controller_Action_Exception($message, 404); + throw new HttpNotFoundException($message); } /** From 03b4de32530e5b7c3822ca66129230d1debcbc5a Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 21 May 2015 16:56:27 +0200 Subject: [PATCH 50/58] Handle the HttpNotFoundException in the ErrorController refs #6281 --- application/controllers/ErrorController.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/application/controllers/ErrorController.php b/application/controllers/ErrorController.php index a77d36f4f..ba9b44266 100644 --- a/application/controllers/ErrorController.php +++ b/application/controllers/ErrorController.php @@ -3,6 +3,7 @@ use Icinga\Application\Icinga; use Icinga\Application\Logger; +use Icinga\Exception\HttpNotFoundException; use Icinga\Exception\MissingParameterException; use Icinga\Security\SecurityException; use Icinga\Web\Controller\ActionController; @@ -45,8 +46,8 @@ class ErrorController extends ActionController break; default: switch (true) { - case $exception instanceof SecurityException: - $this->getResponse()->setHttpResponseCode(403); + case $exception instanceof HttpNotFoundException: + $this->getResponse()->setHttpResponseCode(404); break; case $exception instanceof MissingParameterException: $this->getResponse()->setHttpResponseCode(400); @@ -55,6 +56,9 @@ class ErrorController extends ActionController 'Missing parameter ' . $exception->getParameter() ); break; + case $exception instanceof SecurityException: + $this->getResponse()->setHttpResponseCode(403); + break; default: $this->getResponse()->setHttpResponseCode(500); break; From 5e520e7b59420371e8b882cd3e2e8d5de5ab1064 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 21 May 2015 16:57:43 +0200 Subject: [PATCH 51/58] Don't display a error message as title too refs #6281 --- application/controllers/ErrorController.php | 2 -- application/views/scripts/error/error.phtml | 5 ----- 2 files changed, 7 deletions(-) diff --git a/application/controllers/ErrorController.php b/application/controllers/ErrorController.php index ba9b44266..e5e98ee7e 100644 --- a/application/controllers/ErrorController.php +++ b/application/controllers/ErrorController.php @@ -63,8 +63,6 @@ class ErrorController extends ActionController $this->getResponse()->setHttpResponseCode(500); break; } - $title = preg_replace('/\r?\n.*$/s', '', $exception->getMessage()); - $this->view->title = 'Server error: ' . $title; $this->view->message = $exception->getMessage(); if ($this->getInvokeArg('displayExceptions')) { $this->view->stackTrace = $exception->getTraceAsString(); diff --git a/application/views/scripts/error/error.phtml b/application/views/scripts/error/error.phtml index d9422474c..5b3480922 100644 --- a/application/views/scripts/error/error.phtml +++ b/application/views/scripts/error/error.phtml @@ -1,13 +1,8 @@
tabs->showOnlyCloseButton() ?> -title): ?> -

escape($title) ?>

-
-message): ?>

escape($message)) ?>

-
escape($stackTrace) ?>
From 8f42d7a1d34c5867738ddf8aa460f679b3b8c873 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 21 May 2015 17:17:25 +0200 Subject: [PATCH 52/58] monitoring: Fix HTTP response code when showing an invalid downtime refs #6281 --- .../application/controllers/DowntimeController.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/monitoring/application/controllers/DowntimeController.php b/modules/monitoring/application/controllers/DowntimeController.php index c06e0311d..706090f62 100644 --- a/modules/monitoring/application/controllers/DowntimeController.php +++ b/modules/monitoring/application/controllers/DowntimeController.php @@ -35,8 +35,8 @@ class Monitoring_DowntimeController extends Controller */ public function init() { - $downtimeId = $this->params->get('downtime_id'); - + $downtimeId = $this->params->getRequired('downtime_id'); + $this->downtime = $this->backend->select()->from('downtime', array( 'id' => 'downtime_internal_id', 'objecttype' => 'downtime_objecttype', @@ -60,17 +60,17 @@ class Monitoring_DowntimeController extends Controller 'host_display_name', 'service_display_name' ))->where('downtime_internal_id', $downtimeId)->getQuery()->fetchRow(); - - if (false === $this->downtime) { - throw new Zend_Controller_Action_Exception($this->translate('Downtime not found')); + + if ($this->downtime === false) { + $this->httpNotFound($this->translate('Downtime not found')); } - + if (isset($this->downtime->service_description)) { $this->isService = true; } else { $this->isService = false; } - + $this->getTabs() ->add( 'downtime', From fcd7aaef876a9826471aa40df30ad48d81b61e87 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 21 May 2015 17:18:29 +0200 Subject: [PATCH 53/58] lib: Add HttpException as base class for HTTP exceptions refs #6281 --- library/Icinga/Exception/Http/HttpException.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 library/Icinga/Exception/Http/HttpException.php diff --git a/library/Icinga/Exception/Http/HttpException.php b/library/Icinga/Exception/Http/HttpException.php new file mode 100644 index 000000000..4f47f5b67 --- /dev/null +++ b/library/Icinga/Exception/Http/HttpException.php @@ -0,0 +1,13 @@ + Date: Thu, 21 May 2015 17:19:07 +0200 Subject: [PATCH 54/58] lib: Add HttpMethodNotAllowedException At the moment we throw a Zend_Controller_Action_Exception when the HTTP method is not allowed. I'll replace this w/ the exception introduced. refs #6281 --- .../Http/HttpMethodNotAllowedException.php | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 library/Icinga/Exception/Http/HttpMethodNotAllowedException.php diff --git a/library/Icinga/Exception/Http/HttpMethodNotAllowedException.php b/library/Icinga/Exception/Http/HttpMethodNotAllowedException.php new file mode 100644 index 000000000..5826e52de --- /dev/null +++ b/library/Icinga/Exception/Http/HttpMethodNotAllowedException.php @@ -0,0 +1,41 @@ +allowedMethods; + } + + /** + * Set the allowed HTTP methods + * + * @param string $allowedMethods + * + * @return $this + */ + public function setAllowedMethods($allowedMethods) + { + $this->allowedMethods = (string) $allowedMethods; + return $this; + } +} From 71a2324cb9c9e3f817abf8519a5e39bb0817b5e7 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 22 May 2015 09:12:42 +0200 Subject: [PATCH 55/58] lib: Let Controller::assertHttpMethod() throw a HttpMethodNotAllowedException refs #6281 --- library/Icinga/Web/Controller/ActionController.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/library/Icinga/Web/Controller/ActionController.php b/library/Icinga/Web/Controller/ActionController.php index b78090a7f..a60c82c8e 100644 --- a/library/Icinga/Web/Controller/ActionController.php +++ b/library/Icinga/Web/Controller/ActionController.php @@ -7,6 +7,7 @@ use Exception; use Icinga\Application\Benchmark; use Icinga\Application\Config; use Icinga\Authentication\Manager; +use Icinga\Exception\Http\HttpMethodNotAllowedException; use Icinga\Exception\IcingaException; use Icinga\Exception\ProgrammingError; use Icinga\File\Pdf; @@ -192,16 +193,17 @@ class ActionController extends Zend_Controller_Action /** * Respond with HTTP 405 if the current request's method is not one of the given methods * - * @param string $httpMethod Unlimited number of allowed HTTP methods + * @param string $httpMethod Unlimited number of allowed HTTP methods * - * @throws \Zend_Controller_Action_Exception If the request method is not one of the given methods + * @throws HttpMethodNotAllowedException If the request method is not one of the given methods */ public function assertHttpMethod($httpMethod) { $httpMethods = array_flip(array_map('strtoupper', func_get_args())); if (! isset($httpMethods[$this->getRequest()->getMethod()])) { - $this->getResponse()->setHeader('Allow', implode(', ', array_keys($httpMethods))); - throw new \Zend_Controller_Action_Exception($this->translate('Method Not Allowed'), 405); + $e = new HttpMethodNotAllowedException($this->translate('Method Not Allowed')); + $e->setAllowedMethods(implode(', ', array_keys($httpMethods))); + throw $e; } } From 3f608fda24276ea9942d0b92236a66d432ad1162 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 22 May 2015 09:15:52 +0200 Subject: [PATCH 56/58] Handle the HttpMethodNotAllowedException in the ErrorController refs #6281 --- application/controllers/ErrorController.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/application/controllers/ErrorController.php b/application/controllers/ErrorController.php index e5e98ee7e..0acc85bdd 100644 --- a/application/controllers/ErrorController.php +++ b/application/controllers/ErrorController.php @@ -3,6 +3,7 @@ use Icinga\Application\Icinga; use Icinga\Application\Logger; +use Icinga\Exception\Http\HttpMethodNotAllowedException; use Icinga\Exception\HttpNotFoundException; use Icinga\Exception\MissingParameterException; use Icinga\Security\SecurityException; @@ -46,6 +47,10 @@ class ErrorController extends ActionController break; default: switch (true) { + case $exception instanceof HttpMethodNotAllowedException: + $this->getResponse()->setHttpResponseCode(405); + $this->getResponse()->setHeader('Allow', $exception->getAllowedMethods()); + break; case $exception instanceof HttpNotFoundException: $this->getResponse()->setHttpResponseCode(404); break; From e137263c4b061bd4f2b26c96406a8aff4d3a7d22 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 22 May 2015 09:20:27 +0200 Subject: [PATCH 57/58] monitoring: Fix HTTP response code when showing an invalid comment refs #6281 --- .../application/controllers/CommentController.php | 14 ++++++-------- .../application/controllers/DowntimeController.php | 2 -- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/modules/monitoring/application/controllers/CommentController.php b/modules/monitoring/application/controllers/CommentController.php index c3fcd18f8..4237d598b 100644 --- a/modules/monitoring/application/controllers/CommentController.php +++ b/modules/monitoring/application/controllers/CommentController.php @@ -20,13 +20,11 @@ class Monitoring_CommentController extends Controller /** * Fetch the first comment with the given id and add tabs - * - * @throws Zend_Controller_Action_Exception */ public function init() { - $commentId = $this->params->get('comment_id'); - + $commentId = $this->params->getRequired('comment_id'); + $this->comment = $this->backend->select()->from('comment', array( 'id' => 'comment_internal_id', 'objecttype' => 'comment_objecttype', @@ -41,9 +39,9 @@ class Monitoring_CommentController extends Controller 'host_display_name', 'service_display_name' ))->where('comment_internal_id', $commentId)->getQuery()->fetchRow(); - - if (false === $this->comment) { - throw new Zend_Controller_Action_Exception($this->translate('Comment not found')); + + if ($this->comment === false) { + $this->httpNotFound($this->translate('Comment not found')); } $this->getTabs()->add( @@ -88,7 +86,7 @@ class Monitoring_CommentController extends Controller private function createDelCommentForm() { $this->assertPermission('monitoring/command/comment/delete'); - + $delCommentForm = new DeleteCommentCommandForm(); $delCommentForm->setAction( Url::fromPath('monitoring/comment/show') diff --git a/modules/monitoring/application/controllers/DowntimeController.php b/modules/monitoring/application/controllers/DowntimeController.php index 706090f62..67b8b6a33 100644 --- a/modules/monitoring/application/controllers/DowntimeController.php +++ b/modules/monitoring/application/controllers/DowntimeController.php @@ -30,8 +30,6 @@ class Monitoring_DowntimeController extends Controller /** * Fetch the downtime matching the given id and add tabs - * - * @throws Zend_Controller_Action_Exception */ public function init() { From d2bb74a2f96fe5c4e03c8dec3b8e7206faeba2d9 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 22 May 2015 09:25:49 +0200 Subject: [PATCH 58/58] lib: Move HttpNotFoundException beneath the Http Exception namespace refs #6281 --- application/controllers/ErrorController.php | 2 +- .../Icinga/Exception/Http/HttpMethodNotAllowedException.php | 4 +--- library/Icinga/Exception/{ => Http}/HttpNotFoundException.php | 4 ++-- library/Icinga/Web/Controller.php | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) rename library/Icinga/Exception/{ => Http}/HttpNotFoundException.php (52%) diff --git a/application/controllers/ErrorController.php b/application/controllers/ErrorController.php index 0acc85bdd..0223a66b7 100644 --- a/application/controllers/ErrorController.php +++ b/application/controllers/ErrorController.php @@ -4,7 +4,7 @@ use Icinga\Application\Icinga; use Icinga\Application\Logger; use Icinga\Exception\Http\HttpMethodNotAllowedException; -use Icinga\Exception\HttpNotFoundException; +use Icinga\Exception\Http\HttpNotFoundException; use Icinga\Exception\MissingParameterException; use Icinga\Security\SecurityException; use Icinga\Web\Controller\ActionController; diff --git a/library/Icinga/Exception/Http/HttpMethodNotAllowedException.php b/library/Icinga/Exception/Http/HttpMethodNotAllowedException.php index 5826e52de..57144a883 100644 --- a/library/Icinga/Exception/Http/HttpMethodNotAllowedException.php +++ b/library/Icinga/Exception/Http/HttpMethodNotAllowedException.php @@ -2,12 +2,10 @@ namespace Icinga\Exception\Http; -use Icinga\Exception\IcingaException; - /** * Exception thrown if the HTTP method is not allowed */ -class HttpMethodNotAllowedException extends IcingaException +class HttpMethodNotAllowedException extends HttpException { /** * Allowed HTTP methods diff --git a/library/Icinga/Exception/HttpNotFoundException.php b/library/Icinga/Exception/Http/HttpNotFoundException.php similarity index 52% rename from library/Icinga/Exception/HttpNotFoundException.php rename to library/Icinga/Exception/Http/HttpNotFoundException.php index 09febf0b4..8ec6b7fcb 100644 --- a/library/Icinga/Exception/HttpNotFoundException.php +++ b/library/Icinga/Exception/Http/HttpNotFoundException.php @@ -1,11 +1,11 @@