diff --git a/application/controllers/ErrorController.php b/application/controllers/ErrorController.php index b1343dc81..0223a66b7 100644 --- a/application/controllers/ErrorController.php +++ b/application/controllers/ErrorController.php @@ -3,6 +3,8 @@ use Icinga\Application\Icinga; use Icinga\Application\Logger; +use Icinga\Exception\Http\HttpMethodNotAllowedException; +use Icinga\Exception\Http\HttpNotFoundException; use Icinga\Exception\MissingParameterException; use Icinga\Security\SecurityException; use Icinga\Web\Controller\ActionController; @@ -34,11 +36,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!'), @@ -49,8 +47,12 @@ class ErrorController extends ActionController break; default: switch (true) { - case $exception instanceof SecurityException: - $this->getResponse()->setHttpResponseCode(403); + case $exception instanceof HttpMethodNotAllowedException: + $this->getResponse()->setHttpResponseCode(405); + $this->getResponse()->setHeader('Allow', $exception->getAllowedMethods()); + break; + case $exception instanceof HttpNotFoundException: + $this->getResponse()->setHttpResponseCode(404); break; case $exception instanceof MissingParameterException: $this->getResponse()->setHttpResponseCode(400); @@ -59,12 +61,13 @@ class ErrorController extends ActionController 'Missing parameter ' . $exception->getParameter() ); break; + case $exception instanceof SecurityException: + $this->getResponse()->setHttpResponseCode(403); + break; default: $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) ?>
diff --git a/library/Icinga/Application/Modules/Module.php b/library/Icinga/Application/Modules/Module.php index 516e6ad0f..54e23d02c 100644 --- a/library/Icinga/Application/Modules/Module.php +++ b/library/Icinga/Application/Modules/Module.php @@ -621,7 +621,7 @@ class Module * * @return Config */ - public function getConfig($file = null) + public function getConfig($file = 'config') { return $this->app->getConfig()->module($this->name, $file); } 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 @@ +allowedMethods; + } + + /** + * Set the allowed HTTP methods + * + * @param string $allowedMethods + * + * @return $this + */ + public function setAllowedMethods($allowedMethods) + { + $this->allowedMethods = (string) $allowedMethods; + return $this; + } +} diff --git a/library/Icinga/Exception/Http/HttpNotFoundException.php b/library/Icinga/Exception/Http/HttpNotFoundException.php new file mode 100644 index 000000000..8ec6b7fcb --- /dev/null +++ b/library/Icinga/Exception/Http/HttpNotFoundException.php @@ -0,0 +1,11 @@ +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; } } diff --git a/library/Icinga/Web/Widget/FilterEditor.php b/library/Icinga/Web/Widget/FilterEditor.php index 40953a518..2d64e4c2b 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; /** @@ -215,31 +216,10 @@ class FilterEditor extends AbstractWidget $filter = $this->getFilter(); if ($search !== null) { - if ($this->searchColumns === null) { + if (empty($this->searchColumns)) { 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*"); + Notification::error(mt('monitoring', 'Cannot search here')); + return $this; } else { list($k, $v) = preg_split('/=/', $search); $filter = $this->mergeRootExpression($filter, trim($k), '=', ltrim($v)); 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/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 c06e0311d..67b8b6a33 100644 --- a/modules/monitoring/application/controllers/DowntimeController.php +++ b/modules/monitoring/application/controllers/DowntimeController.php @@ -30,13 +30,11 @@ class Monitoring_DowntimeController extends Controller /** * Fetch the downtime matching the given id and add tabs - * - * @throws Zend_Controller_Action_Exception */ 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 +58,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', diff --git a/modules/monitoring/application/controllers/HostController.php b/modules/monitoring/application/controllers/HostController.php index 7693023eb..464da200c 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')); + $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( - sprintf($this->translate('Host \'%s\' not found'), $this->params->get('host')), - 404 - ); + $this->httpNotFound($this->translate('Host not found')); } $this->object = $host; $this->createTabs(); diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index 45eca1135..78c8eaa7e 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -53,6 +53,8 @@ class Monitoring_HostsController extends Controller protected function handleCommandForm(ObjectsCommandForm $form) { $this->hostList->setColumns(array( + 'host_icon_image', + 'host_icon_image_alt', 'host_name', 'host_state', 'host_problem', @@ -94,6 +96,8 @@ class Monitoring_HostsController extends Controller ->handleRequest(); $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..1c49e36d1 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -12,6 +12,7 @@ use Icinga\Web\Widget\Tabs; use Icinga\Data\Filter\Filter; use Icinga\Web\Widget; use Icinga\Module\Monitoring\Forms\StatehistoryForm; +use Icinga\Module\Monitoring\DataView\DataView; class Monitoring_ListController extends Controller { @@ -70,6 +71,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 +164,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', @@ -468,35 +471,33 @@ class Monitoring_ListController extends Controller ); $this->setAutorefreshInterval(12); - $query = $this->backend->select()->from('groupsummary', array( - 'servicegroup_name', - 'servicegroup_alias', - 'hosts_up', - 'hosts_unreachable_handled', - 'hosts_unreachable_unhandled', + $query = $this->backend->select()->from('servicegroupsummary', array( '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('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. + '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; @@ -505,12 +506,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); } @@ -519,56 +515,42 @@ 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( - 'hostgroup_name', + $query = $this->backend->select()->from('hostgroupsummary', array( '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_last_state_change_handled', - 'hosts_down_last_state_change_unhandled', - 'hosts_unreachable_last_state_change_unhandled', 'hosts_total', - 'services_ok', - 'services_unknown_handled', - 'services_unknown_unhandled', + '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_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' - ))->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. + 'services_total', + 'services_unknown_handled', + 'services_unknown_unhandled', + 'services_warning_handled', + 'services_warning_unhandled' + )); $this->filterQuery($query); $this->view->hostgroups = $query; $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'), - '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); } @@ -626,23 +608,31 @@ class Monitoring_ListController extends Controller $this->view->verticalPaginator = $pivot->paginateYAxis(); } - protected function filterQuery($query) + /** + * Apply filters on a DataView + * + * @param DataView $dataView The DataView to apply filters on + * + * @return DataView $dataView + */ + protected function filterQuery(DataView $dataView) { $editor = Widget::create('filterEditor') - ->setQuery($query) + ->setQuery($dataView) ->preserveParams( 'limit', 'sort', 'dir', 'format', 'view', 'backend', 'stateType', 'addColumns', '_dev' ) ->ignoreParams('page') + ->setSearchColumns($dataView->getSearchColumns()) ->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; } /** diff --git a/modules/monitoring/application/controllers/ServiceController.php b/modules/monitoring/application/controllers/ServiceController.php index e61c4685d..2886650c9 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')); + $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( - sprintf($this->translate('Service \'%s\' not found'), $this->params->get('service')), - 404 - ); + $this->httpNotFound($this->translate('Service not found')); } $this->object = $service; $this->createTabs(); diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index f4ee73cf5..1a8ec9a58 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -50,11 +50,15 @@ class Monitoring_ServicesController extends Controller protected function handleCommandForm(ObjectsCommandForm $form) { $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', @@ -93,11 +97,15 @@ class Monitoring_ServicesController extends Controller ->handleRequest(); $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 new file mode 100644 index 000000000..e0e969db4 --- /dev/null +++ b/modules/monitoring/application/views/helpers/IconImage.php @@ -0,0 +1,62 @@ +host_icon_image && ! preg_match('/[\'"]/', $object->host_icon_image)) { + 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, + 'data-tooltip-delay' => 0 + ) + ); + } + 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->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, + 'data-tooltip-delay' => 0 + ) + ); + } + 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/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); ?> 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..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,6 +9,7 @@ use Icinga\Module\Monitoring\Object\Host; prefixedTimeSince($object->host_last_state_change, true); ?> + iconImage()->host($object) ?> escape($object->host_display_name); ?> host_display_name !== $object->host_name): ?> (escape($object->host_name); ?>) @@ -20,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 d59479e07..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,6 +17,7 @@ $i = 0; host_state, true); ?>
+ iconImage()->host($host) ?> hostFlags($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..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,7 +10,8 @@ use Icinga\Module\Monitoring\Object\Service; prefixedTimeSince($object->host_last_state_change, true); ?> - escape($object->host_display_name); ?> + iconImage()->service($object) ?> + escape($object->host_display_name); ?> host_display_name !== $object->host_name): ?> (escape($object->host_name); ?>) @@ -27,10 +28,11 @@ use Icinga\Module\Monitoring\Object\Service; prefixedTimeSince($object->service_last_state_change, true); ?> + iconImage()->host($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..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,6 +15,7 @@ $i = 0; service_state, true); ?>
+ iconImage()->service($service) ?> serviceFlags($service)) ?> escape($service->getName()); ?> diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php index 392c97538..da33c2bc6 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php @@ -5,59 +5,72 @@ 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( - 'hosts_total' => 'SUM(CASE WHEN object_type = \'host\' THEN 1 ELSE 0 END)', + '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)', 'hosts_unreachable_handled' => 'SUM(CASE WHEN object_type = \'host\' AND state = 2 AND acknowledged + in_downtime != 0 THEN 1 ELSE 0 END)', '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_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_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 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)', + '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 +92,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 +114,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); diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php index 23a8b585a..ec9e6bd32 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)', @@ -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/IdoQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php index fda2f188e..9371399bc 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 COLLATE latin1_general_ci'; + /** * An array with all 'virtual' tables that are already joined * @@ -351,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); @@ -364,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); @@ -393,14 +409,13 @@ 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->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) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php index 17a12259e..2aad7d31c 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php @@ -36,11 +36,12 @@ 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)', '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' ), @@ -162,20 +163,21 @@ 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', '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_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/DataView.php b/modules/monitoring/library/Monitoring/DataView/DataView.php index d1895bbc8..ba628f31c 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; @@ -378,6 +375,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. diff --git a/modules/monitoring/library/Monitoring/DataView/HostStatus.php b/modules/monitoring/library/Monitoring/DataView/HostStatus.php index 23df6d94a..a7c77e2e2 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( @@ -125,4 +126,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 new file mode 100644 index 000000000..63c04df79 --- /dev/null +++ b/modules/monitoring/library/Monitoring/DataView/Hostgroupsummary.php @@ -0,0 +1,101 @@ + 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 + ), + 'services_total' => array( + 'columns' => array( + 'services_total', + 'hostgroup_alias ASC' + ), + 'order' => self::SORT_ASC + ) + ); + } +} diff --git a/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php b/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php index b4f1038da..20f61d515 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', @@ -130,19 +128,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( @@ -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/Groupsummary.php b/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php similarity index 56% rename from modules/monitoring/library/Monitoring/DataView/Groupsummary.php rename to modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php index 36174bfde..11d6ec07e 100644 --- a/modules/monitoring/library/Monitoring/DataView/Groupsummary.php +++ b/modules/monitoring/library/Monitoring/DataView/Servicegroupsummary.php @@ -3,71 +3,90 @@ namespace Icinga\Module\Monitoring\DataView; -class Groupsummary extends DataView +class Servicegroupsummary extends DataView { /** - * Retrieve columns provided by this view - * - * @return array + * {@inheritdoc} */ public function getColumns() { return array( - 'servicegroup_name', - 'servicegroup_alias', - 'hostgroup_name', - 'hostgroup_alias', - 'hosts_total', - 'hosts_up', - 'hosts_unreachable', - 'hosts_unreachable_handled', - 'hosts_unreachable_unhandled', - 'hosts_down', 'hosts_down_handled', 'hosts_down_unhandled', 'hosts_pending', - 'hosts_up_last_state_change', - 'hosts_pending_last_state_change', - 'hosts_down_last_state_change_handled', - 'hosts_unreachable_last_state_change_handled', - 'hosts_down_last_state_change_unhandled', - 'hosts_unreachable_last_state_change_unhandled', - 'services_total', - 'services_ok', - 'services_unknown', - 'services_unknown_handled', - 'services_unknown_unhandled', - 'services_critical', + 'hosts_unreachable_handled', + 'hosts_unreachable_unhandled', + 'hosts_up', + 'servicegroup_alias', + 'servicegroup_name', 'services_critical_handled', - 'services_critical_unhandled', - 'services_warning', - 'services_warning_handled', - 'services_warning_unhandled', - 'services_pending', - 'services_severity', - '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_critical_unhandled', + 'services_ok', + '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', + '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} + */ + public function getFilterColumns() + { + return array('servicegroup'); + } + + /** + * {@inheritdoc} + */ + public static function getQueryName() + { + return 'groupsummary'; + } + + /** + * {@inheritdoc} + */ + public function getSearchColumns() + { + 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'), - 'order' => self::SORT_DESC + '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 ) ); } - - public function getFilterColumns() - { - return array('hostgroup', 'servicegroup'); - } } diff --git a/modules/monitoring/library/Monitoring/Object/Host.php b/modules/monitoring/library/Monitoring/Object/Host.php index 342e78812..a158625b5 100644 --- a/modules/monitoring/library/Monitoring/Object/Host.php +++ b/modules/monitoring/library/Monitoring/Object/Host.php @@ -89,6 +89,8 @@ class Host extends MonitoredObject protected function getDataView() { $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 7c22ae57d..0e8c975f2 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -106,6 +106,8 @@ class Service extends MonitoredObject protected function getDataView() { return $this->backend->select()->from('serviceStatus', array( + 'host_icon_image', + 'host_icon_image_alt', 'host_acknowledged', 'host_active_checks_enabled', 'host_address', @@ -118,6 +120,8 @@ class Service extends MonitoredObject 'host_notifications_enabled', 'host_passive_checks_enabled', 'host_state', + 'service_icon_image', + 'service_icon_image_alt', 'service_acknowledged', 'service_action_url', 'service_active_checks_enabled', 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; }