From ca33e71f2d62ca6419787578efe71284366d867a Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 4 Sep 2015 13:02:57 +0200 Subject: [PATCH 1/5] Deduplicate and clean up service summary component Remove redundant component view script and streamline subFilter handling in all views that render it. Remove heading from component to allow embedding in different types of views. refs #10033 --- library/Icinga/Web/Url.php | 22 ++- .../views/scripts/host/services.phtml | 10 +- .../application/views/scripts/host/show.phtml | 10 +- .../views/scripts/hosts/show.phtml | 4 +- .../list/components/hostssummary.phtml | 29 ++-- .../list/components/servicesummary.phtml | 26 ++- .../views/scripts/list/hosts.phtml | 4 +- .../views/scripts/list/services.phtml | 4 +- .../command/object-command-form.phtml | 10 +- .../command/objects-command-form.phtml | 10 +- .../partials/host/servicesummary.phtml | 150 ------------------ .../views/scripts/services/show.phtml | 5 +- 12 files changed, 91 insertions(+), 193 deletions(-) delete mode 100644 modules/monitoring/application/views/scripts/partials/host/servicesummary.phtml diff --git a/library/Icinga/Web/Url.php b/library/Icinga/Web/Url.php index 7c3829537..237c8988a 100644 --- a/library/Icinga/Web/Url.php +++ b/library/Icinga/Web/Url.php @@ -6,7 +6,7 @@ namespace Icinga\Web; use Icinga\Application\Icinga; use Icinga\Cli\FakeRequest; use Icinga\Exception\ProgrammingError; -use Icinga\Web\UrlParams; +use Icinga\Data\Filter\Filter; /** * Url class that provides convenient access to parameters, allows to modify query parameters and @@ -156,6 +156,26 @@ class Url return $urlObject; } + /** + * Create a new filter that needs to fullfill the base filter and the optional filter (if it exists) + * + * @param string $url The url to apply the new filter to + * @param Filter $filter The base filter + * @param Filter $optional The optional filter + * + * @return Url The altered URL containing the new filter + * @throws ProgrammingError + */ + public static function urlAddFilterOptional($url, $filter, $optional) + { + $url = Url::fromPath($url); + $f = $filter; + if (isset($optional)) { + $f = Filter::matchAll($filter, $optional); + } + return $url->setQueryString($f->toQueryString()); + } + /** * Overwrite the baseUrl * diff --git a/modules/monitoring/application/views/scripts/host/services.phtml b/modules/monitoring/application/views/scripts/host/services.phtml index 11166f8fa..fd69d88ad 100644 --- a/modules/monitoring/application/views/scripts/host/services.phtml +++ b/modules/monitoring/application/views/scripts/host/services.phtml @@ -1,9 +1,17 @@ + +
compact): ?> tabs; ?> render('partials/host/object-header.phtml') ?> - render('partials/host/servicesummary.phtml') ?> +

compact ? ' data-base-target="col1"' : ''; ?> + baseFilter = Filter::where('host', $object->host_name); + $this->stats = $object->stats; + echo $this->render('list/components/servicesummary.phtml'); + ?> +

partial( 'list/services.phtml', diff --git a/modules/monitoring/application/views/scripts/host/show.phtml b/modules/monitoring/application/views/scripts/host/show.phtml index a612ae1af..12de39a78 100644 --- a/modules/monitoring/application/views/scripts/host/show.phtml +++ b/modules/monitoring/application/views/scripts/host/show.phtml @@ -1,9 +1,17 @@ + +
compact): ?> tabs; ?> render('partials/host/object-header.phtml') ?> - render('partials/host/servicesummary.phtml') ?> +

compact ? ' data-base-target="col1"' : ''; ?>> + stats = $object->stats; + $this->baseFilter = Filter::where('host', $object->host_name); + echo $this->render('list/components/servicesummary.phtml'); + ?> +

render('show/components/output.phtml') ?> diff --git a/modules/monitoring/application/views/scripts/hosts/show.phtml b/modules/monitoring/application/views/scripts/hosts/show.phtml index 3dbb0673f..053c44520 100644 --- a/modules/monitoring/application/views/scripts/hosts/show.phtml +++ b/modules/monitoring/application/views/scripts/hosts/show.phtml @@ -3,7 +3,9 @@ - render('list/components/hostssummary.phtml') ?> +

compact ? ' data-base-target="col1"' : ''; ?> + render('list/components/hostssummary.phtml') ?> +

render('partials/host/objects-header.phtml'); ?>
diff --git a/modules/monitoring/application/views/scripts/list/components/hostssummary.phtml b/modules/monitoring/application/views/scripts/list/components/hostssummary.phtml index 22f84b583..3fe11bcca 100644 --- a/modules/monitoring/application/views/scripts/list/components/hostssummary.phtml +++ b/modules/monitoring/application/views/scripts/list/components/hostssummary.phtml @@ -3,20 +3,16 @@ use Icinga\Web\Url; use Icinga\Data\Filter\Filter; -function urlAddFilterOptional($url, $filter, $optional) { - $url = Url::fromPath($url); - $f = $filter; - if (isset($optional)) { - $f = Filter::matchAll($filter, $optional); - } - return $url->setQueryString($f->toQueryString()); -} $this->baseFilter = isset($this->baseFilter) ? $this->baseFilter : null; -$stats = $stats->fetchRow(); +// don't fetch rows until they are actually needed to improve dashlet performance +if (!$stats instanceof stdClass) { + $stats = $stats->fetchRow(); +} + $selfUrl = 'monitoring/list/hosts'; $currentUrl = Url::fromRequest()->getRelativeUrl(); -?>

compact ? ' data-base-target="col1"' : ''; ?>> +?> qlink( sprintf($this->translatePlural('%u Host', '%u Hosts', $stats->hosts_total), $stats->hosts_total), $selfUrl, @@ -31,7 +27,7 @@ $currentUrl = Url::fromRequest()->getRelativeUrl(); qlink( $stats->hosts_up, - urlAddFilterOptional( + Url::urlAddFilterOptional( $selfUrl, Filter::where('host_state', 0), $this->baseFilter @@ -54,7 +50,7 @@ $currentUrl = Url::fromRequest()->getRelativeUrl(); qlink( $stats->hosts_down_unhandled, - urlAddFilterOptional( + Url::urlAddFilterOptional( $selfUrl, Filter::matchAll(Filter::where('host_state', 1), Filter::where('host_unhandled', 1)), $this->baseFilter @@ -75,7 +71,7 @@ $currentUrl = Url::fromRequest()->getRelativeUrl(); qlink( $stats->hosts_down_handled, - urlAddFilterOptional( + Url::urlAddFilterOptional( $selfUrl, Filter::matchAll(Filter::where('host_state', 1), Filter::where('host_unhandled', 0)), $this->baseFilter @@ -101,7 +97,7 @@ $currentUrl = Url::fromRequest()->getRelativeUrl(); qlink( $stats->hosts_unreachable_unhandled, - urlAddFilterOptional( + Url::urlAddFilterOptional( $selfUrl, Filter::matchAll(Filter::where('host_state', 2), Filter::where('host_unhandled', 1)), $this->baseFilter @@ -122,7 +118,7 @@ $currentUrl = Url::fromRequest()->getRelativeUrl(); qlink( $stats->hosts_unreachable_handled, - urlAddFilterOptional( + Url::urlAddFilterOptional( $selfUrl, Filter::matchAll(Filter::where('host_state', 2), Filter::where('host_unhandled', 0)), $this->baseFilter @@ -148,7 +144,7 @@ $currentUrl = Url::fromRequest()->getRelativeUrl(); qlink( $stats->hosts_pending, - urlAddFilterOptional( + Url::urlAddFilterOptional( $selfUrl, Filter::where('host_state', 99), $this->baseFilter @@ -166,4 +162,3 @@ $currentUrl = Url::fromRequest()->getRelativeUrl(); -

diff --git a/modules/monitoring/application/views/scripts/list/components/servicesummary.phtml b/modules/monitoring/application/views/scripts/list/components/servicesummary.phtml index 9fd798a0d..1f401004d 100644 --- a/modules/monitoring/application/views/scripts/list/components/servicesummary.phtml +++ b/modules/monitoring/application/views/scripts/list/components/servicesummary.phtml @@ -4,21 +4,16 @@ use Icinga\Data\Filter\Filter; use Icinga\Web\Url; use Icinga\Module\Monitoring\Object\Service; -function urlAddFilterOptional($url, $filter, $optional) { - $url = Url::fromPath($url); - $f = $filter; - if (isset($optional)) { - $f = Filter::matchAll($filter, $optional); - } - return $url->setQueryString($f->toQueryString()); -} $this->baseFilter = isset($this->baseFilter) ? $this->baseFilter : null; -$stats = $stats->fetchRow(); +// don't fetch rows until they are actually needed, to improve dashlet performance +if (!$stats instanceof stdClass) { + $stats = $stats->fetchRow(); +}; $selfUrl = 'monitoring/list/services'; $currentUrl = Url::fromRequest()->getRelativeUrl(); -?>

compact ? ' data-base-target="col1"' : ''; ?>> -qlink( + +echo $this->qlink( sprintf($this->translatePlural( '%u Service', '%u Services', $stats->services_total), $stats->services_total @@ -36,7 +31,7 @@ $currentUrl = Url::fromRequest()->getRelativeUrl(); qlink( $stats->services_ok, - urlAddFilterOptional($selfUrl, Filter::where('service_state', 0), $this->baseFilter), + Url::urlAddFilterOptional($selfUrl, Filter::where('service_state', 0), $this->baseFilter), null, array('title' => sprintf( $this->translatePlural( @@ -81,7 +76,7 @@ foreach (array(2 => 'critical', 3 => 'unknown', 1 => 'warning') as $stateId => $ echo $this->qlink( $stats->$unhandled, - urlAddFilterOptional($selfUrl, $paramsUnhandled, $this->baseFilter), + Url::urlAddFilterOptional($selfUrl, $paramsUnhandled, $this->baseFilter), null, array('title' => sprintf( $this->translatePlural( @@ -106,7 +101,7 @@ foreach (array(2 => 'critical', 3 => 'unknown', 1 => 'warning') as $stateId => $ } echo $this->qlink( $stats->$handled, - urlAddFilterOptional($selfUrl, $paramsHandled, $this->baseFilter), + Url::urlAddFilterOptional($selfUrl, $paramsHandled, $this->baseFilter), null, array('title' => sprintf( $this->translatePlural( @@ -130,7 +125,7 @@ foreach (array(2 => 'critical', 3 => 'unknown', 1 => 'warning') as $stateId => $ qlink( $stats->services_pending, - urlAddFilterOptional($selfUrl, Filter::where('service_state', 99), $this->baseFilter), + Url::urlAddFilterOptional($selfUrl, Filter::where('service_state', 99), $this->baseFilter), null, array('title' => sprintf( $this->translatePlural( @@ -144,4 +139,3 @@ foreach (array(2 => 'critical', 3 => 'unknown', 1 => 'warning') as $stateId => $ -

diff --git a/modules/monitoring/application/views/scripts/list/hosts.phtml b/modules/monitoring/application/views/scripts/list/hosts.phtml index 62ca65121..859f01aec 100644 --- a/modules/monitoring/application/views/scripts/list/hosts.phtml +++ b/modules/monitoring/application/views/scripts/list/hosts.phtml @@ -8,7 +8,9 @@ if (! $this->compact): ?> tabs; ?>
render('list/components/selectioninfo.phtml'); ?> - render('list/components/hostssummary.phtml'); ?> +

compact ? ' data-base-target="col1"' : ''; ?> + render('list/components/hostssummary.phtml'); ?> +

sortBox; ?> limiter; ?> diff --git a/modules/monitoring/application/views/scripts/list/services.phtml b/modules/monitoring/application/views/scripts/list/services.phtml index d2dfb250a..9b5dd1ec1 100644 --- a/modules/monitoring/application/views/scripts/list/services.phtml +++ b/modules/monitoring/application/views/scripts/list/services.phtml @@ -10,7 +10,9 @@ if (! $this->compact): ?> tabs ?>
render('list/components/selectioninfo.phtml') ?> - render('list/components/servicesummary.phtml') ?> +

compact ? ' data-base-target="col1"' : ''; ?>> + render('list/components/servicesummary.phtml') ?> +

sortBox ?> limiter ?> diff --git a/modules/monitoring/application/views/scripts/partials/command/object-command-form.phtml b/modules/monitoring/application/views/scripts/partials/command/object-command-form.phtml index ab14b1b2a..095d9a4c4 100644 --- a/modules/monitoring/application/views/scripts/partials/command/object-command-form.phtml +++ b/modules/monitoring/application/views/scripts/partials/command/object-command-form.phtml @@ -1,10 +1,18 @@ + +
compact): ?> tabs; ?> getType() === $object::TYPE_HOST): ?> render('partials/host/object-header.phtml'); ?> - render('partials/host/servicesummary.phtml'); ?> +

compact ? ' data-base-target="col1"' : ''; ?>"> + baseFilter = Filter::where('host', $object->host_name); + $this->stats = $object->stats; + echo $this->render('list/components/servicesummary.phtml'); + ?> +

render('partials/service/object-header.phtml'); ?>
diff --git a/modules/monitoring/application/views/scripts/partials/command/objects-command-form.phtml b/modules/monitoring/application/views/scripts/partials/command/objects-command-form.phtml index 42c6e73cd..6a209e159 100644 --- a/modules/monitoring/application/views/scripts/partials/command/objects-command-form.phtml +++ b/modules/monitoring/application/views/scripts/partials/command/objects-command-form.phtml @@ -1,3 +1,5 @@ + +
compact): ?> @@ -5,10 +7,14 @@ - render('list/components/servicesummary.phtml') ?> +

compact ? ' data-base-target="col1"' : ''; ?> + render('list/components/servicesummary.phtml'); ?> +

render('partials/service/objects-header.phtml'); ?> - render('list/components/hostssummary.phtml') ?> +

compact ? ' data-base-target="col1"' : ''; ?> + render('list/components/hostssummary.phtml') ?> +

render('partials/host/objects-header.phtml'); ?>
diff --git a/modules/monitoring/application/views/scripts/partials/host/servicesummary.phtml b/modules/monitoring/application/views/scripts/partials/host/servicesummary.phtml deleted file mode 100644 index be146acbe..000000000 --- a/modules/monitoring/application/views/scripts/partials/host/servicesummary.phtml +++ /dev/null @@ -1,150 +0,0 @@ -setQueryString($f->toQueryString()); -} - -$selfUrl = Url::fromPath('monitoring/list/services', array('host' => $object->host_name)); -?>

compact ? ' data-base-target="col1"' : ''; ?>> -stats->services_total): ?> -qlink( - sprintf( - $this->translatePlural( - '%u configured service:', - '%u configured services:', - $object->stats->services_total - ), - $object->stats->services_total - ), - $selfUrl, - null, - array( - 'title' => sprintf( - $this->translatePlural( - 'List all %u service on host %s', - 'List all %u services on host %s', - $object->stats->services_total - ), - $object->stats->services_total, - $object->host_name - ), - 'data-base-target' => '_next' - ) -); ?> - -translate('No services configured on this host'); ?> - - - -stats->services_ok): ?> - - qlink( - $object->stats->services_ok, - $selfUrl, - array('service_state' => 0), - array( - 'title' => sprintf( - $this->translatePlural( - 'List %u service that is currently in state OK on host %s', - 'List %u services which are currently in state OK on host %s', - $object->stats->services_ok - ), - $object->stats->services_ok, - $object->host_name - ), - 'data-base-target' => '_next' - ) - ); ?> - - - 'critical', 3 => 'unknown', 1 => 'warning') as $stateId => $state) { - $pre = 'services_' . $state; - if ($object->stats->$pre) { - $handled = $pre . '_handled'; - $unhandled = $pre . '_unhandled'; - $paramsHandled = array('service_state' => $stateId, 'service_handled' => 1); - $paramsUnhandled = array('service_state' => $stateId, 'service_handled' => 0); - echo ''; - if ($object->stats->$unhandled) { - - echo $this->qlink( - $object->stats->$unhandled, - $selfUrl, - $paramsUnhandled, - array( - 'title' => sprintf( - $this->translatePlural( - 'List %u service that is currently in state %s on host %s', - 'List %u services which are currently in state %s on host %s', - $object->stats->$unhandled - ), - $object->stats->$unhandled, - Service::getStateText($stateId, true), - $object->host_name - ), - 'data-base-target' => '_next' - ) - ); - } - if ($object->stats->$handled) { - if ($object->stats->$unhandled) { - echo ''; - } - echo $this->qlink( - $object->stats->$handled, - $selfUrl, - $paramsHandled, - array( - 'title' => sprintf( - $this->translatePlural( - 'List %u service that is currently in state %s (Acknowledged) on host %s', - 'List %u services which are currently in state %s (Acknowledged) on host %s', - $object->stats->$handled - ), - $object->stats->$handled, - Service::getStateText($stateId, true), - $object->host_name - ), - 'data-base-target' => '_next' - ) - ); - if ($object->stats->$unhandled) { - echo "\n"; - } - } - echo "\n"; - } -} -?> -stats->services_pending): ?> - - qlink( - $object->stats->services_pending, - $selfUrl, - array('service_state' => 99), - array( - 'title' => sprintf( - $this->translatePlural( - 'List %u service that is currently in state PENDING on host %s', - 'List %u services which are currently in state PENDING on host %s', - $object->stats->services_pending - ), - $object->stats->services_pending, - $object->host_name - ), - 'data-base-target' => '_next' - ) - ) ?> - - - -

diff --git a/modules/monitoring/application/views/scripts/services/show.phtml b/modules/monitoring/application/views/scripts/services/show.phtml index d2ad21bca..be8cf5a8b 100644 --- a/modules/monitoring/application/views/scripts/services/show.phtml +++ b/modules/monitoring/application/views/scripts/services/show.phtml @@ -4,7 +4,10 @@ - render('list/components/servicesummary.phtml') ?> + +

compact ? ' data-base-target="col1"' : ''; ?> + render('list/components/servicesummary.phtml') ?> +

render('partials/service/objects-header.phtml'); ?>
From daa23a4edd45646ce65e39aa53b1da5d78cdc2f1 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 4 Sep 2015 13:06:13 +0200 Subject: [PATCH 2/5] Use correct filters in multi-object command views --- modules/monitoring/application/controllers/HostsController.php | 2 +- .../monitoring/application/controllers/ServicesController.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index 036b78c32..3c576fbc8 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -32,6 +32,7 @@ class HostsController extends Controller $this->applyRestriction('monitoring/filter/objects', $hostList); $hostList->addFilter(Filter::fromQueryString((string) $this->params)); $this->hostList = $hostList; + $this->view->baseFilter = $this->hostList->getFilter(); $this->getTabs()->add( 'show', array( @@ -152,7 +153,6 @@ class HostsController extends Controller ->toQueryString() ); $this->view->commentsLink = Url::fromRequest()->setPath('monitoring/list/comments'); - $this->view->baseFilter = $this->hostList->getFilter(); $this->view->sendCustomNotificationLink = Url::fromRequest()->setPath('monitoring/hosts/send-custom-notification'); } diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index deee364fa..26561f8ff 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -33,6 +33,7 @@ class ServicesController extends Controller (string) $this->params->without(array('service_problem', 'service_handled', 'view')) )); $this->serviceList = $serviceList; + $this->view->baseFilter = $this->serviceList->getFilter(); $this->view->listAllLink = Url::fromRequest()->setPath('monitoring/list/services'); $this->getTabs()->add( 'show', @@ -163,7 +164,6 @@ class ServicesController extends Controller ); $this->view->commentsLink = Url::fromRequest() ->setPath('monitoring/list/comments'); - $this->view->baseFilter = $this->serviceList->getFilter(); $this->view->sendCustomNotificationLink = Url::fromRequest()->setPath( 'monitoring/services/send-custom-notification' ); From fff9bf7b2b0e58b0bdddec3b36954f9e1c1b7776 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 4 Sep 2015 14:11:56 +0200 Subject: [PATCH 3/5] Implement view to display stats about checks and monitored objects refs #10033 --- ...essController.php => HealthController.php} | 70 ++++++- .../ToggleInstanceFeaturesCommandForm.php | 2 +- .../disable-notifications.phtml | 0 .../views/scripts/health/info.phtml | 84 ++++++++ .../{process => health}/not-running.phtml | 0 .../views/scripts/health/stats.phtml | 106 ++++++++++ .../views/scripts/process/info.phtml | 185 ------------------ modules/monitoring/configuration.php | 2 +- 8 files changed, 256 insertions(+), 193 deletions(-) rename modules/monitoring/application/controllers/{ProcessController.php => HealthController.php} (63%) rename modules/monitoring/application/views/scripts/{process => health}/disable-notifications.phtml (100%) create mode 100644 modules/monitoring/application/views/scripts/health/info.phtml rename modules/monitoring/application/views/scripts/{process => health}/not-running.phtml (100%) create mode 100644 modules/monitoring/application/views/scripts/health/stats.phtml delete mode 100644 modules/monitoring/application/views/scripts/process/info.phtml diff --git a/modules/monitoring/application/controllers/ProcessController.php b/modules/monitoring/application/controllers/HealthController.php similarity index 63% rename from modules/monitoring/application/controllers/ProcessController.php rename to modules/monitoring/application/controllers/HealthController.php index 84a1a15f5..c6f239d0c 100644 --- a/modules/monitoring/application/controllers/ProcessController.php +++ b/modules/monitoring/application/controllers/HealthController.php @@ -11,7 +11,7 @@ use Icinga\Web\Widget\Tabextension\DashboardAction; /** * Display process and performance information of the monitoring host and program-wide commands */ -class ProcessController extends Controller +class HealthController extends Controller { /** * Add tabs @@ -29,10 +29,21 @@ class ProcessController extends Controller 'Show information about the current monitoring instance\'s process' . ' and it\'s performance as well as available features' ), - 'label' => $this->translate('Monitoring Health'), - 'url' =>'monitoring/process/info' + 'label' => $this->translate('Process Information'), + 'url' =>'monitoring/health/info' ) - )->extend(new DashboardAction()); + ) + ->add( + 'stats', + array( + 'title' => $this->translate( + 'Show statistics about the monitored objects' + ), + 'label' => $this->translate('Stats'), + 'url' =>'monitoring/health/stats' + ) + ) + ->extend(new DashboardAction()); } /** @@ -40,7 +51,7 @@ class ProcessController extends Controller */ public function infoAction() { - $this->view->title = $this->translate('Monitoring Health'); + $this->view->title = $this->translate('Process Information'); $this->getTabs()->activate('info'); $this->setAutorefreshInterval(10); $this->view->backendName = $this->backend->getName(); @@ -95,6 +106,53 @@ class ProcessController extends Controller ->getQuery()->fetchAll(); } + /** + * Display stats about current checks and monitored objects + */ + public function statsAction() + { + $this->getTabs()->activate('stats'); + + $servicestats = $this->backend->select()->from('servicestatussummary', array( + 'services_critical', + 'services_critical_handled', + 'services_critical_unhandled', + 'services_ok', + 'services_pending', + 'services_total', + 'services_unknown', + 'services_unknown_handled', + 'services_unknown_unhandled', + 'services_warning', + 'services_warning_handled', + 'services_warning_unhandled' + )); + $this->applyRestriction('monitoring/filter/objects', $servicestats); + $this->view->servicestats = $servicestats->fetchRow(); + + $hoststats = $this->backend->select()->from('hoststatussummary', array( + 'hosts_total', + 'hosts_up', + 'hosts_down', + 'hosts_down_handled', + 'hosts_down_unhandled', + 'hosts_unreachable', + 'hosts_unreachable_handled', + 'hosts_unreachable_unhandled', + 'hosts_pending', + )); + $this->applyRestriction('monitoring/filter/objects', $hoststats); + $this->view->hoststats = $hoststats; + + $this->view->runtimevariables = (object) $this->backend->select() + ->from('runtimevariables', array('varname', 'varvalue')) + ->getQuery()->fetchPairs(); + + $this->view->checkperformance = $this->backend->select() + ->from('runtimesummary') + ->getQuery()->fetchAll(); + } + /** * Disable notifications w/ an optional expire time */ @@ -119,7 +177,7 @@ class ProcessController extends Controller } else { $form = new DisableNotificationsExpireCommandForm(); $form - ->setRedirectUrl('monitoring/process/info') + ->setRedirectUrl('monitoring/health/info') ->handleRequest(); $this->view->form = $form; } diff --git a/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php b/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php index d487647e2..6f727232f 100644 --- a/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php +++ b/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php @@ -65,7 +65,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm $notificationDescription = sprintf( '%3$s', $this->translate('Disable notifications for a specific time on a program-wide basis'), - $this->getView()->href('monitoring/process/disable-notifications'), + $this->getView()->href('monitoring/health/disable-notifications'), $this->translate('Disable temporarily') ); } else { diff --git a/modules/monitoring/application/views/scripts/process/disable-notifications.phtml b/modules/monitoring/application/views/scripts/health/disable-notifications.phtml similarity index 100% rename from modules/monitoring/application/views/scripts/process/disable-notifications.phtml rename to modules/monitoring/application/views/scripts/health/disable-notifications.phtml diff --git a/modules/monitoring/application/views/scripts/health/info.phtml b/modules/monitoring/application/views/scripts/health/info.phtml new file mode 100644 index 000000000..78a58d525 --- /dev/null +++ b/modules/monitoring/application/views/scripts/health/info.phtml @@ -0,0 +1,84 @@ +runtimeVariables()->create($this->runtimevariables); +$cp = $this->checkPerformance()->create($this->checkperformance); + +if (! $this->compact): ?> +
+ tabs; ?> +
+ + +
+
+
+

translate('Process Info') ?>

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
translate('Program Version') ?>programStatus->program_version + ? $this->programStatus->program_version + : $this->translate('N/A') ?>
translate('Program Start Time') ?>formatDateTime($this->programStatus->program_start_time) ?>
translate('Last Status Update'); ?>timeAgo($this->programStatus->status_update_time); ?>
translate('Last External Command Check'); ?>timeAgo($this->programStatus->last_command_check); ?>
translate('Last Log File Rotation'); ?>programStatus->last_log_rotation + ? $this->timeSince($this->programStatus->last_log_rotation) + : $this->translate('N/A') ?>
translate('Global Service Event Handler'); ?>programStatus->global_service_event_handler + ? $this->programStatus->global_service_event_handler + : $this->translate('N/A'); ?>
translate('Global Host Event Handler'); ?>programStatus->global_host_event_handler + ? $this->programStatus->global_host_event_handler + : $this->translate('N/A'); ?>
translate('Active Endpoint'); ?>programStatus->endpoint_name + ? $this->programStatus->endpoint_name + : $this->translate('N/A') ?>
+ programStatus->is_currently_running === true): ?> +
+ translate( + '%1$s has been up and running with PID %2$d %3$s', + 'Last format parameter represents the time running' + ), + $this->backendName, + $this->programStatus->process_id, + $this->timeSince($this->programStatus->program_start_time)) ?> +
+ +
+ translate('Backend %s is not running'), $this->backendName) ?> +
+ +
+ +
+
+ toggleFeaturesForm; ?> +
+
+
diff --git a/modules/monitoring/application/views/scripts/process/not-running.phtml b/modules/monitoring/application/views/scripts/health/not-running.phtml similarity index 100% rename from modules/monitoring/application/views/scripts/process/not-running.phtml rename to modules/monitoring/application/views/scripts/health/not-running.phtml diff --git a/modules/monitoring/application/views/scripts/health/stats.phtml b/modules/monitoring/application/views/scripts/health/stats.phtml new file mode 100644 index 000000000..30828cec7 --- /dev/null +++ b/modules/monitoring/application/views/scripts/health/stats.phtml @@ -0,0 +1,106 @@ +runtimeVariables()->create($this->runtimevariables); +$cp = $this->checkPerformance()->create($this->checkperformance); + +if (! $this->compact): ?> +
+ tabs ?> +
+ + +
+ +
+ +
+

+ stats = $hoststats ?> + render('list/components/hostssummary.phtml') ?> +

+ + + + + + + + + + + + +
translate('Total') ?> total_scheduled_hosts ?>
translate('Scheduled') ?> total_scheduled_hosts ?>
+ +

+ stats = $servicestats ?> + render('list/components/servicesummary.phtml') ?> +

+ + + + + + + + + + + + + + + + + + + + + + + + +
translate('Amount') ?>translate('Per Host') ?>
translate('Total') ?> total_services ?> average_services_per_host) ?>
translate('Scheduled') ?> total_scheduled_services ?> average_scheduled_services_per_host) ?>
+ +

translate('Active checks') ?>

+ + + + + + + + + + + + + + + + + + + + + + + +
translate('Checks') ?>translate('Latency') ?>translate('Execution time') ?>
translate('Host Checks') ?>host_active_count; ?>host_active_latency_avg) ?>shost_active_execution_avg) ?>s
translate('Service Checks') ?>service_active_count; ?>service_active_latency_avg) ?>sservice_active_execution_avg) ?>s
+ +

translate('Passive checks') ?>

+ + + + + + + + + + + +
translate('Host Checks') ?>host_passive_count ?>
translate('Service Checks') ?>service_passive_count ?>
+
+ +
+
diff --git a/modules/monitoring/application/views/scripts/process/info.phtml b/modules/monitoring/application/views/scripts/process/info.phtml deleted file mode 100644 index 85e576116..000000000 --- a/modules/monitoring/application/views/scripts/process/info.phtml +++ /dev/null @@ -1,185 +0,0 @@ -runtimeVariables()->create($this->runtimevariables); -$cp = $this->checkPerformance()->create($this->checkperformance); - -if (! $this->compact): ?> -
- tabs; ?> -
- - -
-
- -
- toggleFeaturesForm; ?> -
- -
-

translate('Process Info') ?>

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
translate('Program Version') ?>programStatus->program_version - ? $this->programStatus->program_version - : $this->translate('N/A') ?>
translate('Program Start Time') ?>formatDateTime($this->programStatus->program_start_time) ?>
translate('Last Status Update'); ?>timeAgo($this->programStatus->status_update_time); ?>
translate('Last External Command Check'); ?>timeAgo($this->programStatus->last_command_check); ?>
translate('Last Log File Rotation'); ?>programStatus->last_log_rotation - ? $this->timeSince($this->programStatus->last_log_rotation) - : $this->translate('N/A') ?>
translate('Global Service Event Handler'); ?>programStatus->global_service_event_handler - ? $this->programStatus->global_service_event_handler - : $this->translate('N/A'); ?>
translate('Global Host Event Handler'); ?>programStatus->global_host_event_handler - ? $this->programStatus->global_host_event_handler - : $this->translate('N/A'); ?>
translate('Active Endpoint'); ?>programStatus->endpoint_name - ? $this->programStatus->endpoint_name - : $this->translate('N/A') ?>
- programStatus->is_currently_running === true): ?> -
- translate( - '%1$s has been up and running with PID %2$d %3$s', - 'Last format parameter represents the time running' - ), - $this->backendName, - $this->programStatus->process_id, - $this->timeSince($this->programStatus->program_start_time)) ?> -
- -
- translate('Backend %s is not running'), $this->backendName) ?> -
- -
- -
-

translate('Performance Info') ?>

- -

translate('Object summaries') ?>

- - - - - - - - - - - - - - - - - - - - - - - - - - - -
translate('overall') ?>translate('scheduled') ?>
- translate('Hosts') ?> - - total_hosts; ?> - - total_scheduled_hosts; ?> -
- translate('Services') ?> - - total_services; ?> - - total_scheduled_services; ?> -
- translate('Average services per host') ?> - - average_services_per_host); ?> - - average_scheduled_services_per_host); ?> -
- -

translate('Active checks') ?>

- - - - - - - - - - - - - - - - - - - - - - - -
translate('Latency') ?>translate('Execution time') ?>
- translate('Host Checks') ?> - host_active_count; ?>host_active_latency_avg); ?>shost_active_execution_avg); ?>s
- translate('Service Checks') ?> - service_active_count; ?>service_active_latency_avg); ?>sservice_active_execution_avg); ?>s
- -

translate('Passive checks') ?>

- - - - - - - - - - - -
- translate('Host Checks') ?> - host_passive_count; ?>
- translate('Service Checks') ?> - service_passive_count; ?>
-
- -
-
diff --git a/modules/monitoring/configuration.php b/modules/monitoring/configuration.php index 4d915c123..49c616a1f 100644 --- a/modules/monitoring/configuration.php +++ b/modules/monitoring/configuration.php @@ -222,7 +222,7 @@ $section->add($this->translate('Alert Summary'), array( */ $section = $this->menuSection($this->translate('System')); $section->add($this->translate('Monitoring Health'), array( - 'url' => 'monitoring/process/info', + 'url' => 'monitoring/health/info', 'priority' => 720, 'renderer' => 'Icinga\Module\Monitoring\Web\Menu\BackendAvailabilityMenuItemRenderer' )); From a630869bcf528468ced70db9c8d3b2095e67fe3a Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 4 Sep 2015 15:17:28 +0200 Subject: [PATCH 4/5] Provide stats for unhandled problems and improve layout refs #10033 --- .../controllers/HealthController.php | 10 ++- .../views/scripts/health/stats.phtml | 64 +++++++++++++++++-- public/css/icinga/widgets.less | 5 ++ 3 files changed, 71 insertions(+), 8 deletions(-) diff --git a/modules/monitoring/application/controllers/HealthController.php b/modules/monitoring/application/controllers/HealthController.php index c6f239d0c..bbfdcb030 100644 --- a/modules/monitoring/application/controllers/HealthController.php +++ b/modules/monitoring/application/controllers/HealthController.php @@ -129,6 +129,9 @@ class HealthController extends Controller )); $this->applyRestriction('monitoring/filter/objects', $servicestats); $this->view->servicestats = $servicestats->fetchRow(); + $this->view->unhandledServiceProblems = $this->view->servicestats->services_critical_unhandled + + $this->view->servicestats->services_unknown_unhandled + + $this->view->servicestats->services_warning_unhandled; $hoststats = $this->backend->select()->from('hoststatussummary', array( 'hosts_total', @@ -142,7 +145,12 @@ class HealthController extends Controller 'hosts_pending', )); $this->applyRestriction('monitoring/filter/objects', $hoststats); - $this->view->hoststats = $hoststats; + $this->view->hoststats = $hoststats->fetchRow(); + $this->view->unhandledhostProblems = $this->view->hoststats->hosts_down_unhandled + + $this->view->hoststats->hosts_unreachable_unhandled; + + $this->view->unhandledProblems = $this->view->unhandledhostProblems + + $this->view->unhandledServiceProblems; $this->view->runtimevariables = (object) $this->backend->select() ->from('runtimevariables', array('varname', 'varvalue')) diff --git a/modules/monitoring/application/views/scripts/health/stats.phtml b/modules/monitoring/application/views/scripts/health/stats.phtml index 30828cec7..275fbf4f8 100644 --- a/modules/monitoring/application/views/scripts/health/stats.phtml +++ b/modules/monitoring/application/views/scripts/health/stats.phtml @@ -9,16 +9,56 @@ if (! $this->compact): ?>
-
-
+

unhandledProblems ?> translate('Unhandled Problems:') ?> + unhandledProblems ?> +

+ + + + + + + + + + + +
translate('Service Problems:') ?> + + qlink( + $this->unhandledServiceProblems, + 'monitoring/list/services?service_problem=1&service_handled=0&sort=service_severity' + ) + ?> + +
translate('Host Problems:') ?> + + qlink( + $this->unhandledhostProblems, + 'monitoring/list/hosts?host_problem=1&host_handled=0' + ) + ?> + +
+
+

stats = $hoststats ?> render('list/components/hostssummary.phtml') ?>

- + + + + + + + + @@ -30,17 +70,17 @@ if (! $this->compact): ?>
translate('Runtime Variables') ?>translate('Host Checks') ?>
translate('Total') ?>
+

stats = $servicestats ?> render('list/components/servicesummary.phtml') ?>

- - - + + @@ -60,12 +100,13 @@ if (! $this->compact): ?>
translate('Amount') ?> translate('Runtime Variables') ?> translate('Service Checks') ?> translate('Per Host') ?>
+

translate('Active checks') ?>

- + @@ -86,9 +127,18 @@ if (! $this->compact): ?>
translate('Check Performance') ?> translate('Checks') ?> translate('Latency') ?> translate('Execution time') ?>
+

translate('Passive checks') ?>

+ + + + + + + + diff --git a/public/css/icinga/widgets.less b/public/css/icinga/widgets.less index 95b64429a..9f884e746 100644 --- a/public/css/icinga/widgets.less +++ b/public/css/icinga/widgets.less @@ -234,6 +234,11 @@ li li .badge-container { background-color: @colorInvalid; } +.badge a[href] { + color: white; + text-decoration: none; +} + #menu nav ul .badge { margin-right: 0em; top: 0.3em; From 8837004fca1c462b18cced63b378dd7b84bd3558 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 4 Sep 2015 15:24:26 +0200 Subject: [PATCH 5/5] Fix base target in problem badges The stats view is always a main pane, so it makes sense to open the badge links in col2. refs #10033 --- .../application/views/scripts/health/stats.phtml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/views/scripts/health/stats.phtml b/modules/monitoring/application/views/scripts/health/stats.phtml index 275fbf4f8..792b5a050 100644 --- a/modules/monitoring/application/views/scripts/health/stats.phtml +++ b/modules/monitoring/application/views/scripts/health/stats.phtml @@ -23,7 +23,9 @@ if (! $this->compact): ?> qlink( $this->unhandledServiceProblems, - 'monitoring/list/services?service_problem=1&service_handled=0&sort=service_severity' + 'monitoring/list/services?service_problem=1&service_handled=0&sort=service_severity', + null, + array('data-base-target' => '_next') ) ?> @@ -36,7 +38,9 @@ if (! $this->compact): ?> qlink( $this->unhandledhostProblems, - 'monitoring/list/hosts?host_problem=1&host_handled=0' + 'monitoring/list/hosts?host_problem=1&host_handled=0', + null, + array('data-base-target' => '_next') ) ?>
translate('Check Performance') ?> translate('Passive Checks') ?>
translate('Host Checks') ?>