diff --git a/modules/monitoring/application/controllers/ServiceController.php b/modules/monitoring/application/controllers/ServiceController.php index 7f643e657..f0d298be0 100644 --- a/modules/monitoring/application/controllers/ServiceController.php +++ b/modules/monitoring/application/controllers/ServiceController.php @@ -3,9 +3,18 @@ // {{{ICINGA_LICENSE_HEADER}}} use Icinga\Module\Monitoring\Controller; -use Icinga\Module\Monitoring\Form\Command\CommandForm; -use Icinga\Module\Monitoring\Form\Command\Service\ScheduleServiceDowntimeCommandForm; +use Icinga\Module\Monitoring\Form\Command\Object\AcknowledgeProblemCommandForm; +use Icinga\Module\Monitoring\Form\Command\Object\AddCommentCommandForm; +use Icinga\Module\Monitoring\Form\Command\Object\CheckNowCommandForm; +use Icinga\Module\Monitoring\Form\Command\Object\DeleteCommentCommandForm; +use Icinga\Module\Monitoring\Form\Command\Object\DeleteDowntimeCommandForm; +use Icinga\Module\Monitoring\Form\Command\Object\ObjectsCommandForm; +use Icinga\Module\Monitoring\Form\Command\Object\RemoveAcknowledgementCommandForm; +use Icinga\Module\Monitoring\Form\Command\Object\ScheduleServiceCheckCommandForm; +use Icinga\Module\Monitoring\Form\Command\Object\ScheduleServiceDowntimeCommandForm; +use Icinga\Module\Monitoring\Form\Command\Object\ToggleObjectFeaturesCommandForm; use Icinga\Module\Monitoring\Object\Service; +use Icinga\Web\Url; class Monitoring_ServiceController extends Controller { @@ -14,22 +23,107 @@ class Monitoring_ServiceController extends Controller */ protected $service; - public function init() + public function moduleInit() { - $this->service = new Service($this->params); // Use $this->_request->getParams() instead of $this->params - // once #7049 has been fixed + parent::moduleInit(); + $service = new Service($this->backend, $this->params->get('host'), $this->params->get('service')); + if ($service->fetch() === false) { + throw new Zend_Controller_Action_Exception($this->translate('Service not found')); + } + $this->service = $service; } - protected function handleCommandForm(CommandForm $form) + public function showAction() + { + $this->setAutorefreshInterval(10); + $checkNowForm = new CheckNowCommandForm(); + $checkNowForm + ->setObjects($this->service) + ->handleRequest(); + $this->view->checkNowForm = $checkNowForm; + + if ( ! in_array((int) $this->service->state, array(0, 99))) { + if ((bool) $this->service->acknowledged) { + $removeAckForm = new RemoveAcknowledgementCommandForm(); + $removeAckForm + ->setObjects($this->service) + ->handleRequest(); + $this->view->removeAckForm = $removeAckForm; + } else { + $ackForm = new AcknowledgeProblemCommandForm(); + $ackForm + ->setObjects($this->service) + ->handleRequest(); + $this->view->ackForm = $ackForm; + } + } + if (count($this->service->comments) > 0) { + $delCommentForm = new DeleteCommentCommandForm(); + $delCommentForm + ->setObjects($this->service) + ->handleRequest(); + $this->view->delCommentForm = $delCommentForm; + } + + if (count($this->service->downtimes > 0)) { + $delDowntimeForm = new DeleteDowntimeCommandForm(); + $delDowntimeForm + ->setObjects($this->service) + ->handleRequest(); + $this->view->delDowntimeForm = $delDowntimeForm; + } + + $toggleFeaturesForm = new ToggleObjectFeaturesCommandForm(); + $toggleFeaturesForm + ->load($this->service) + ->setObjects($this->service) + ->handleRequest(); + $this->view->toggleFeaturesForm = $toggleFeaturesForm; + + $this->view->object = $this->service->populate(); + } + + protected function handleCommandForm(ObjectsCommandForm $form) { $form - ->setService($this->service) + ->setObjects($this->service) + ->setRedirectUrl(Url::fromPath( + 'monitoring/service/show', + array('host' => $this->service->getHost(), 'service' => $this->service->getService()) + )) ->handleRequest(); $this->view->form = $form; $this->_helper->viewRenderer('command'); return $form; } + /** + * Acknowledge a service downtime + */ + public function acknowledgeProblemAction() + { + $this->view->title = $this->translate('Acknowledge Service Downtime'); + $this->handleCommandForm(new AcknowledgeProblemCommandForm()); + } + + /** + * Add a service comment + */ + public function addCommentAction() + { + $this->view->title = $this->translate('Add Service Comment'); + $this->handleCommandForm(new AddCommentCommandForm()); + } + + /** + * Reschedule a service check + */ + public function rescheduleCheckAction() + { + $this->view->title = $this->translate('Reschedule Service Check'); + $this->handleCommandForm(new ScheduleServiceCheckCommandForm()); + } + /** * Schedule a service downtime */ diff --git a/modules/monitoring/application/views/scripts/service/command.phtml b/modules/monitoring/application/views/scripts/service/command.phtml new file mode 100644 index 000000000..5bff418e3 --- /dev/null +++ b/modules/monitoring/application/views/scripts/service/command.phtml @@ -0,0 +1,4 @@ +
+

+ +
diff --git a/modules/monitoring/application/views/scripts/service/show.phtml b/modules/monitoring/application/views/scripts/service/show.phtml new file mode 100644 index 000000000..5d0fd22c1 --- /dev/null +++ b/modules/monitoring/application/views/scripts/service/show.phtml @@ -0,0 +1,27 @@ +
+ render('show/components/header.phtml') ?> +

translate("This service's current state") ?>

+
+
+ render('show/components/output.phtml') ?> + render('show/components/grapher.phtml') ?> + + + + render('show/components/acknowledgement.phtml') ?> + render('show/components/comments.phtml') ?> + render('show/components/notifications.phtml') ?> + render('show/components/downtime.phtml') ?> + render('show/components/flapping.phtml') ?> + render('show/components/perfdata.phtml') ?> + render('show/components/checksource.phtml') ?> + render('show/components/actions.phtml') ?> + render('show/components/command.phtml') ?> + render('show/components/servicegroups.phtml') ?> + render('show/components/contacts.phtml') ?> + render('show/components/checkstatistics.phtml') ?> + render('show/components/customvars.phtml') ?> + render('show/components/flags.phtml') ?> + +
+