diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index ec4e470a20..55f8a6e60b 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -110,16 +110,7 @@ public function showAction() $acknowledgedObjects = array(); $objectsInDowntime = array(); $downtimeFilterExpressions = array(); - $hostStates = array( - 'hosts_' . Host::getStateText(Host::STATE_UP) => 0, - 'hosts_' . Host::getStateText(Host::STATE_UP) . '_unhandled' => 0, - 'hosts_' . Host::getStateText(Host::STATE_DOWN) => 0, - 'hosts_' . Host::getStateText(Host::STATE_DOWN) . '_unhandled' => 0, - 'hosts_' . Host::getStateText(Host::STATE_UNREACHABLE) => 0, - 'hosts_' . Host::getStateText(Host::STATE_UNREACHABLE) . '_unhandled' => 0, - 'hosts_' . Host::getStateText(Host::STATE_PENDING) => 0, - 'hosts_' . Host::getStateText(Host::STATE_PENDING) . '_unhandled' => 0, - ); + foreach ($this->hostList as $host) { /** @var Host $host */ $unhandled = (bool) $host->problem === true && (bool) $host->handled === false; @@ -134,7 +125,6 @@ public function showAction() $objectsInDowntime[] = $host; $downtimeFilterExpressions[] = Filter::where('downtime_host', $host->getName()); } - ++$hostStates['hosts_' . $host::getStateText($host->state) . ($unhandled ? '_unhandled' : '')]; } if (! empty($acknowledgedObjects)) { $removeAckForm = new RemoveAcknowledgementCommandForm(); @@ -150,7 +140,7 @@ public function showAction() $this->view->processCheckResultAllLink = Url::fromRequest()->setPath('monitoring/hosts/process-check-result'); $this->view->addCommentLink = Url::fromRequest()->setPath('monitoring/hosts/add-comment'); $this->view->deleteCommentLink = Url::fromRequest()->setPath('monitoring/hosts/delete-comment'); - $this->view->hostStates = (object)$hostStates; + $this->view->stats = (object)$this->hostList->getStateSummary(); $this->view->objects = $this->hostList; $this->view->unhandledObjects = $unhandledObjects; $unhandledFilterQueryString = Filter::matchAny($unhandledFilterExpressions)->toQueryString(); diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index 1514a0ea0c..dcd95184cb 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -132,35 +132,10 @@ public function showAction() $acknowledgedObjects = array(); $objectsInDowntime = array(); $downtimeFilterExpressions = array(); - $serviceStates = array( - 'services_' . Service::getStateText(Service::STATE_OK) => 0, - 'services_' . Service::getStateText(Service::STATE_OK) . '_unhandled' => 0, - 'services_' . Service::getStateText(Service::STATE_WARNING) => 0, - 'services_' . Service::getStateText(Service::STATE_WARNING) . '_unhandled' => 0, - 'services_' . Service::getStateText(Service::STATE_CRITICAL) => 0, - 'services_' . Service::getStateText(Service::STATE_CRITICAL) . '_unhandled' => 0, - 'services_' . Service::getStateText(Service::STATE_UNKNOWN) => 0, - 'services_' . Service::getStateText(Service::STATE_UNKNOWN) . '_unhandled' => 0, - 'services_' . Service::getStateText(Service::STATE_PENDING) => 0, - 'services_' . Service::getStateText(Service::STATE_PENDING) . '_unhandled' => 0 - ); - $knownHostStates = array(); - $hostStates = array( - 'hosts_' . Host::getStateText(Host::STATE_UP) => 0, - 'hosts_' . Host::getStateText(Host::STATE_UP) . '_unhandled' => 0, - 'hosts_' . Host::getStateText(Host::STATE_DOWN) => 0, - 'hosts_' . Host::getStateText(Host::STATE_DOWN) . '_unhandled' => 0, - 'hosts_' . Host::getStateText(Host::STATE_UNREACHABLE) => 0, - 'hosts_' . Host::getStateText(Host::STATE_UNREACHABLE) . '_unhandled' => 0, - 'hosts_' . Host::getStateText(Host::STATE_PENDING) => 0, - 'hosts_' . Host::getStateText(Host::STATE_PENDING) . '_unhandled' => 0 - ); - foreach ($this->serviceList as $service) { - $unhandled = false; + foreach ($this->serviceList as $service) { /** @var Service $service */ if ((bool) $service->problem === true && (bool) $service->handled === false) { - $unhandled = true; $unhandledObjects[] = $service; $unhandledFilterExpressions[] = Filter::matchAll( Filter::where('host', $service->getHost()->getName()), @@ -177,12 +152,6 @@ public function showAction() Filter::where('downtime_service', $service->getName()) ); } - - ++$serviceStates['services_' . $service::getStateText($service->state) . ($unhandled ? '_unhandled' : '')]; - if (! isset($knownHostStates[$service->getHost()->getName()])) { - $knownHostStates[$service->getHost()->getName()] = true; - ++$hostStates['hosts_' . $service->getHost()->getStateText($service->host_state)]; - } } if (! empty($acknowledgedObjects)) { $removeAckForm = new RemoveAcknowledgementCommandForm(); @@ -208,8 +177,7 @@ public function showAction() ); $this->view->addCommentLink = Url::fromRequest()->setPath('monitoring/services/add-comment'); $this->view->deleteCommentLink = Url::fromRequest()->setPath('monitoring/services/delete-comment'); - $this->view->hostStates = (object)$hostStates; - $this->view->serviceStates = (object)$serviceStates; + $this->view->stats = $this->serviceList->getStateSummary(); $this->view->objects = $this->serviceList; $this->view->unhandledObjects = $unhandledObjects; $unhandledFilterQueryString = Filter::matchAny($unhandledFilterExpressions)->toQueryString(); diff --git a/modules/monitoring/application/views/scripts/hosts/show.phtml b/modules/monitoring/application/views/scripts/hosts/show.phtml index f4ac409041..d56f92af49 100644 --- a/modules/monitoring/application/views/scripts/hosts/show.phtml +++ b/modules/monitoring/application/views/scripts/hosts/show.phtml @@ -8,7 +8,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; = $tabs; ?> - = $this->render('partials/host/objects-tinysummary.phtml') ?> + = $this->render('list/components/hostssummary.phtml') ?> = $this->render('partials/host/objects-header.phtml'); ?> diff --git a/modules/monitoring/application/views/scripts/partials/host/objects-tinysummary.phtml b/modules/monitoring/application/views/scripts/partials/host/objects-tinysummary.phtml deleted file mode 100644 index fa841c6337..0000000000 --- a/modules/monitoring/application/views/scripts/partials/host/objects-tinysummary.phtml +++ /dev/null @@ -1,44 +0,0 @@ - - -