parent
5f13db73ce
commit
5d07b04f82
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
<div class="content">
|
||||
<h1><?= $title ?></h1>
|
||||
<?= $form ?>
|
||||
</div>
|
|
@ -0,0 +1,27 @@
|
|||
<div class="controls">
|
||||
<?= $this->render('show/components/header.phtml') ?>
|
||||
<h1><?= $this->translate("This service's current state") ?></h1>
|
||||
</div>
|
||||
<div class="content" data-base-target="_next">
|
||||
<?= $this->render('show/components/output.phtml') ?>
|
||||
<?= $this->render('show/components/grapher.phtml') ?>
|
||||
|
||||
<table class="avp newsection">
|
||||
<tbody>
|
||||
<?= $this->render('show/components/acknowledgement.phtml') ?>
|
||||
<?= $this->render('show/components/comments.phtml') ?>
|
||||
<?= $this->render('show/components/notifications.phtml') ?>
|
||||
<?= $this->render('show/components/downtime.phtml') ?>
|
||||
<?= $this->render('show/components/flapping.phtml') ?>
|
||||
<?= $this->render('show/components/perfdata.phtml') ?>
|
||||
<?= $this->render('show/components/checksource.phtml') ?>
|
||||
<?= $this->render('show/components/actions.phtml') ?>
|
||||
<?= $this->render('show/components/command.phtml') ?>
|
||||
<?= $this->render('show/components/servicegroups.phtml') ?>
|
||||
<?= $this->render('show/components/contacts.phtml') ?>
|
||||
<?= $this->render('show/components/checkstatistics.phtml') ?>
|
||||
<?= $this->render('show/components/customvars.phtml') ?>
|
||||
<?= $this->render('show/components/flags.phtml') ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
Loading…
Reference in New Issue