From 8b377cd65158f63da215132ac2c1d9ec5e79964e Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 2 Feb 2015 16:30:52 +0100 Subject: [PATCH] Use the new command-view scripts --- .../controllers/HostsController.php | 30 +++++++++++- .../controllers/ServicesController.php | 49 ++++++++++++++++++- .../Controller/MonitoredObjectController.php | 4 +- modules/monitoring/public/css/module.less | 9 ++++ 4 files changed, 88 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index 869be92d8..dbe395b28 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -12,7 +12,6 @@ use Icinga\Module\Monitoring\Forms\Command\Object\RemoveAcknowledgementCommandFo use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleHostCheckCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleHostDowntimeCommandForm; use Icinga\Module\Monitoring\Object\Host; -use Icinga\Module\Monitoring\Object\Service; use Icinga\Module\Monitoring\Object\HostList; use Icinga\Web\Url; use Icinga\Web\Widget\Chart\InlinePie; @@ -33,12 +32,39 @@ class Monitoring_HostsController extends Controller protected function handleCommandForm(ObjectsCommandForm $form) { + $this->hostList->setColumns(array( + 'host_name', + 'host_state', + 'host_problem', + 'host_handled', + 'host_acknowledged', + 'host_in_downtime' + )); + $form ->setObjects($this->hostList) ->setRedirectUrl(Url::fromPath('monitoring/hosts/show')->setParams($this->params)) ->handleRequest(); + + $hostStates = array( + Host::getStateText(Host::STATE_UP) => 0, + Host::getStateText(Host::STATE_DOWN) => 0, + Host::getStateText(Host::STATE_UNREACHABLE) => 0, + Host::getStateText(Host::STATE_PENDING) => 0, + ); + foreach ($this->hostList as $host) { + ++$hostStates[$host::getStateText($host->state)]; + } + $this->view->form = $form; - $this->_helper->viewRenderer('partials/command-form', null, true); + $this->view->objects = $this->hostList; + $this->view->hostStates = $hostStates; + $this->view->hostStatesPieChart = $this->createPieChart( + $hostStates, + $this->translate('Host State'), + array('#44bb77', '#FF5566', '#E066FF', '#77AAFF') + ); + $this->_helper->viewRenderer('partials/command/objects-command-form', null, true); return $form; } diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index dc7feb2da..88df52e46 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -33,12 +33,59 @@ class Monitoring_ServicesController extends Controller protected function handleCommandForm(ObjectsCommandForm $form) { + $this->serviceList->setColumns(array( + 'host_name', + 'host_state', + 'service_description', + 'service_state', + 'service_problem', + 'service_handled', + 'service_acknowledged', + 'service_in_downtime' + )); + $form ->setObjects($this->serviceList) ->setRedirectUrl(Url::fromPath('monitoring/services/show')->setParams($this->params)) ->handleRequest(); + + $serviceStates = array( + Service::getStateText(Service::STATE_OK) => 0, + Service::getStateText(Service::STATE_WARNING) => 0, + Service::getStateText(Service::STATE_CRITICAL) => 0, + Service::getStateText(Service::STATE_UNKNOWN) => 0, + Service::getStateText(Service::STATE_PENDING) => 0 + ); + $knownHostStates = array(); + $hostStates = array( + Host::getStateText(Host::STATE_UP) => 0, + Host::getStateText(Host::STATE_DOWN) => 0, + Host::getStateText(Host::STATE_UNREACHABLE) => 0, + Host::getStateText(Host::STATE_PENDING) => 0, + ); + foreach ($this->serviceList as $service) { + ++$serviceStates[$service::getStateText($service->state)]; + if (! isset($knownHostStates[$service->getHost()->getName()])) { + $knownHostStates[$service->getHost()->getName()] = true; + ++$hostStates[$service->getHost()->getStateText($service->host_state)]; + } + } + $this->view->form = $form; - $this->_helper->viewRenderer('partials/command-form', null, true); + $this->view->objects = $this->serviceList; + $this->view->serviceStates = $serviceStates; + $this->view->hostStates = $hostStates; + $this->view->serviceStatesPieChart = $this->createPieChart( + $serviceStates, + $this->translate('Service State'), + array('#44bb77', '#FFCC66', '#FF5566', '#E066FF', '#77AAFF') + ); + $this->view->hostStatesPieChart = $this->createPieChart( + $hostStates, + $this->translate('Host State'), + array('#44bb77', '#FF5566', '#E066FF', '#77AAFF') + ); + $this->_helper->viewRenderer('partials/command/objects-command-form', null, true); return $form; } diff --git a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php index 5de11e1e2..1c3db0799 100644 --- a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php +++ b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php @@ -109,7 +109,9 @@ abstract class MonitoredObjectController extends Controller ->setRedirectUrl(Url::fromPath($this->commandRedirectUrl)->setParams($this->params)) ->handleRequest(); $this->view->form = $form; - $this->_helper->viewRenderer('partials/command-form', null, true); + $this->view->object = $this->object; + $this->view->tabs->remove('dashboard'); + $this->_helper->viewRenderer('partials/command/object-command-form', null, true); return $form; } diff --git a/modules/monitoring/public/css/module.less b/modules/monitoring/public/css/module.less index 675988056..82ee0b629 100644 --- a/modules/monitoring/public/css/module.less +++ b/modules/monitoring/public/css/module.less @@ -190,3 +190,12 @@ div.selection-info { .optionbox input { vertical-align: middle; } + +h1.command-title { + border: none; +} + +hr.command-separator { + border: none; + border-bottom: 2px solid @colorPetrol; +} \ No newline at end of file