2014-09-24 07:47:26 +02:00
|
|
|
<?php
|
2015-02-04 10:46:36 +01:00
|
|
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
2014-09-24 07:47:26 +02:00
|
|
|
|
2015-08-28 09:22:13 +02:00
|
|
|
namespace Icinga\Module\Monitoring\Controllers;
|
|
|
|
|
2014-09-24 07:47:26 +02:00
|
|
|
use Icinga\Data\Filter\Filter;
|
|
|
|
use Icinga\Module\Monitoring\Controller;
|
2014-11-14 11:17:22 +01:00
|
|
|
use Icinga\Module\Monitoring\Forms\Command\Object\AcknowledgeProblemCommandForm;
|
2015-08-28 09:21:23 +02:00
|
|
|
use Icinga\Module\Monitoring\Forms\Command\Object\AddCommentCommandForm;
|
2014-11-14 11:17:22 +01:00
|
|
|
use Icinga\Module\Monitoring\Forms\Command\Object\CheckNowCommandForm;
|
|
|
|
use Icinga\Module\Monitoring\Forms\Command\Object\ObjectsCommandForm;
|
2014-12-12 12:44:31 +01:00
|
|
|
use Icinga\Module\Monitoring\Forms\Command\Object\ProcessCheckResultCommandForm;
|
2014-11-14 11:17:22 +01:00
|
|
|
use Icinga\Module\Monitoring\Forms\Command\Object\RemoveAcknowledgementCommandForm;
|
|
|
|
use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleServiceCheckCommandForm;
|
|
|
|
use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleServiceDowntimeCommandForm;
|
2015-03-12 16:08:22 +01:00
|
|
|
use Icinga\Module\Monitoring\Forms\Command\Object\SendCustomNotificationCommandForm;
|
2014-09-24 07:47:26 +02:00
|
|
|
use Icinga\Module\Monitoring\Object\ServiceList;
|
|
|
|
use Icinga\Web\Url;
|
2015-04-20 14:59:20 +02:00
|
|
|
use Icinga\Web\Widget\Tabextension\DashboardAction;
|
2015-09-30 14:47:42 +02:00
|
|
|
use Icinga\Web\Widget\Tabextension\MenuAction;
|
2014-09-24 07:47:26 +02:00
|
|
|
|
2015-08-28 09:22:13 +02:00
|
|
|
class ServicesController extends Controller
|
2014-09-24 07:47:26 +02:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var ServiceList
|
|
|
|
*/
|
|
|
|
protected $serviceList;
|
|
|
|
|
|
|
|
public function init()
|
|
|
|
{
|
|
|
|
$serviceList = new ServiceList($this->backend);
|
2015-08-04 15:30:07 +02:00
|
|
|
$this->applyRestriction('monitoring/filter/objects', $serviceList);
|
|
|
|
$serviceList->addFilter(Filter::fromQueryString(
|
2015-04-20 13:18:36 +02:00
|
|
|
(string) $this->params->without(array('service_problem', 'service_handled', 'view'))
|
2015-04-20 13:03:13 +02:00
|
|
|
));
|
2014-09-24 07:47:26 +02:00
|
|
|
$this->serviceList = $serviceList;
|
2015-09-04 13:06:13 +02:00
|
|
|
$this->view->baseFilter = $this->serviceList->getFilter();
|
2015-03-05 18:32:38 +01:00
|
|
|
$this->view->listAllLink = Url::fromRequest()->setPath('monitoring/list/services');
|
|
|
|
$this->getTabs()->add(
|
|
|
|
'show',
|
|
|
|
array(
|
|
|
|
'title' => sprintf(
|
|
|
|
$this->translate('Show summarized information for %u services'),
|
|
|
|
count($this->serviceList)
|
|
|
|
),
|
2015-05-18 17:13:46 +02:00
|
|
|
'label' => $this->translate('Services') . sprintf(' (%d)', count($this->serviceList)),
|
2015-03-05 18:32:38 +01:00
|
|
|
'url' => Url::fromRequest(),
|
2015-05-18 15:22:10 +02:00
|
|
|
'icon' => 'services'
|
2015-03-05 18:32:38 +01:00
|
|
|
)
|
2015-09-30 14:47:42 +02:00
|
|
|
)->extend(new DashboardAction())->extend(new MenuAction())->activate('show');
|
2014-09-24 07:47:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function handleCommandForm(ObjectsCommandForm $form)
|
|
|
|
{
|
2015-02-02 16:30:52 +01:00
|
|
|
$this->serviceList->setColumns(array(
|
2015-05-21 11:40:08 +02:00
|
|
|
'host_icon_image',
|
2015-05-21 14:59:12 +02:00
|
|
|
'host_icon_image_alt',
|
2015-02-02 16:30:52 +01:00
|
|
|
'host_name',
|
2015-05-28 15:37:01 +02:00
|
|
|
'host_address',
|
2015-07-16 10:35:28 +02:00
|
|
|
'host_address6',
|
2015-04-09 13:53:05 +02:00
|
|
|
'host_output',
|
2015-02-02 16:30:52 +01:00
|
|
|
'host_state',
|
2015-04-09 13:53:05 +02:00
|
|
|
'host_problem',
|
|
|
|
'host_handled',
|
2015-05-19 18:08:26 +02:00
|
|
|
'service_icon_image',
|
2015-05-21 14:59:12 +02:00
|
|
|
'service_icon_image_alt',
|
2015-02-02 16:30:52 +01:00
|
|
|
'service_description',
|
|
|
|
'service_state',
|
|
|
|
'service_problem',
|
|
|
|
'service_handled',
|
|
|
|
'service_acknowledged',
|
2015-03-05 18:32:38 +01:00
|
|
|
'service_in_downtime',
|
|
|
|
'service_is_flapping',
|
|
|
|
'service_output',
|
2015-04-09 17:15:26 +02:00
|
|
|
'service_notifications_enabled',
|
2015-04-09 15:44:21 +02:00
|
|
|
'service_active_checks_enabled',
|
|
|
|
'service_passive_checks_enabled'
|
2015-02-02 16:30:52 +01:00
|
|
|
));
|
|
|
|
|
2014-09-24 07:47:26 +02:00
|
|
|
$form
|
|
|
|
->setObjects($this->serviceList)
|
|
|
|
->setRedirectUrl(Url::fromPath('monitoring/services/show')->setParams($this->params))
|
|
|
|
->handleRequest();
|
2015-02-02 16:30:52 +01:00
|
|
|
|
2014-09-24 07:47:26 +02:00
|
|
|
$this->view->form = $form;
|
2015-02-02 16:30:52 +01:00
|
|
|
$this->view->objects = $this->serviceList;
|
2015-04-09 13:53:05 +02:00
|
|
|
$this->view->stats = $this->serviceList->getServiceStateSummary();
|
|
|
|
$this->view->serviceStates = true;
|
2015-02-02 16:30:52 +01:00
|
|
|
$this->_helper->viewRenderer('partials/command/objects-command-form', null, true);
|
2014-09-24 07:47:26 +02:00
|
|
|
return $form;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function showAction()
|
|
|
|
{
|
|
|
|
$this->setAutorefreshInterval(15);
|
|
|
|
$checkNowForm = new CheckNowCommandForm();
|
|
|
|
$checkNowForm
|
|
|
|
->setObjects($this->serviceList)
|
|
|
|
->handleRequest();
|
|
|
|
$this->view->checkNowForm = $checkNowForm;
|
|
|
|
$this->serviceList->setColumns(array(
|
2015-05-21 11:40:08 +02:00
|
|
|
'host_icon_image',
|
2015-05-21 14:59:12 +02:00
|
|
|
'host_icon_image_alt',
|
2014-09-24 07:47:26 +02:00
|
|
|
'host_name',
|
2015-05-28 15:37:01 +02:00
|
|
|
'host_address',
|
2015-07-16 10:35:28 +02:00
|
|
|
'host_address6',
|
2015-03-05 18:32:38 +01:00
|
|
|
'host_output',
|
2014-09-24 07:47:26 +02:00
|
|
|
'host_state',
|
2015-04-02 16:25:20 +02:00
|
|
|
'host_problem',
|
|
|
|
'host_handled',
|
2015-05-19 18:08:26 +02:00
|
|
|
'service_icon_image',
|
2015-05-21 14:59:12 +02:00
|
|
|
'service_icon_image_alt',
|
2015-03-05 18:32:38 +01:00
|
|
|
'service_output',
|
2014-09-24 07:47:26 +02:00
|
|
|
'service_description',
|
|
|
|
'service_state',
|
|
|
|
'service_problem',
|
|
|
|
'service_handled',
|
|
|
|
'service_acknowledged',
|
2015-03-05 18:32:38 +01:00
|
|
|
'service_in_downtime',
|
|
|
|
'service_is_flapping',
|
2015-04-09 17:15:26 +02:00
|
|
|
'service_notifications_enabled',
|
2015-04-09 15:44:21 +02:00
|
|
|
'service_active_checks_enabled',
|
|
|
|
'service_passive_checks_enabled'
|
|
|
|
/*
|
2014-09-24 07:47:26 +02:00
|
|
|
'service_event_handler_enabled',
|
|
|
|
'service_flap_detection_enabled',
|
|
|
|
'service_obsessing'*/
|
|
|
|
));
|
2015-03-06 17:52:06 +01:00
|
|
|
|
|
|
|
$acknowledgedObjects = $this->serviceList->getAcknowledgedObjects();
|
2014-09-24 07:47:26 +02:00
|
|
|
if (! empty($acknowledgedObjects)) {
|
|
|
|
$removeAckForm = new RemoveAcknowledgementCommandForm();
|
|
|
|
$removeAckForm
|
|
|
|
->setObjects($acknowledgedObjects)
|
|
|
|
->handleRequest();
|
|
|
|
$this->view->removeAckForm = $removeAckForm;
|
|
|
|
}
|
2015-04-02 16:25:20 +02:00
|
|
|
|
2014-09-24 07:47:26 +02:00
|
|
|
$this->setAutorefreshInterval(15);
|
|
|
|
$this->view->rescheduleAllLink = Url::fromRequest()->setPath('monitoring/services/reschedule-check');
|
|
|
|
$this->view->downtimeAllLink = Url::fromRequest()->setPath('monitoring/services/schedule-downtime');
|
2014-12-11 15:52:23 +01:00
|
|
|
$this->view->processCheckResultAllLink = Url::fromRequest()->setPath(
|
|
|
|
'monitoring/services/process-check-result'
|
|
|
|
);
|
2015-03-06 09:23:11 +01:00
|
|
|
$this->view->addCommentLink = Url::fromRequest()->setPath('monitoring/services/add-comment');
|
|
|
|
$this->view->deleteCommentLink = Url::fromRequest()->setPath('monitoring/services/delete-comment');
|
2015-05-18 13:56:35 +02:00
|
|
|
$this->view->stats = $this->serviceList->getServiceStateSummary();
|
2014-09-24 07:47:26 +02:00
|
|
|
$this->view->objects = $this->serviceList;
|
2015-04-07 16:29:10 +02:00
|
|
|
$this->view->unhandledObjects = $this->serviceList->getUnhandledObjects();
|
|
|
|
$this->view->problemObjects = $this->serviceList->getProblemObjects();
|
2014-12-29 12:11:49 +01:00
|
|
|
$this->view->downtimeUnhandledLink = Url::fromPath('monitoring/services/schedule-downtime')
|
2015-04-09 11:19:13 +02:00
|
|
|
->setQueryString($this->serviceList->getUnhandledObjects()->objectsFilter()->toQueryString());
|
2015-04-07 16:29:10 +02:00
|
|
|
$this->view->downtimeLink = Url::fromPath('monitoring/services/schedule-downtime')
|
2015-04-09 11:19:13 +02:00
|
|
|
->setQueryString($this->serviceList->getProblemObjects()->objectsFilter()->toQueryString());
|
2014-09-24 07:47:26 +02:00
|
|
|
$this->view->acknowledgedObjects = $acknowledgedObjects;
|
2015-06-01 12:22:53 +02:00
|
|
|
$this->view->acknowledgeLink = Url::fromPath('monitoring/services/acknowledge-problem')
|
|
|
|
->setQueryString($this->serviceList->getUnacknowledgedObjects()->objectsFilter()->toQueryString());
|
|
|
|
$this->view->unacknowledgedObjects = $this->serviceList->getUnacknowledgedObjects();
|
2015-04-07 16:29:10 +02:00
|
|
|
$this->view->objectsInDowntime = $this->serviceList->getObjectsInDowntime();
|
2015-05-18 14:03:10 +02:00
|
|
|
$this->view->inDowntimeLink = Url::fromPath('monitoring/list/services')
|
2015-04-09 11:19:13 +02:00
|
|
|
->setQueryString($this->serviceList->getObjectsInDowntime()
|
2015-05-18 14:03:10 +02:00
|
|
|
->objectsFilter(array('host' => 'host_name', 'service' => 'service_description'))->toQueryString());
|
|
|
|
$this->view->showDowntimesLink = Url::fromPath('monitoring/downtimes/show')
|
|
|
|
->setQueryString(
|
|
|
|
$this->serviceList->getObjectsInDowntime()
|
|
|
|
->objectsFilter()->toQueryString()
|
|
|
|
);
|
2015-02-03 12:35:06 +01:00
|
|
|
$this->view->commentsLink = Url::fromRequest()
|
2014-09-24 07:47:26 +02:00
|
|
|
->setPath('monitoring/list/comments');
|
2015-05-11 12:18:50 +02:00
|
|
|
$this->view->sendCustomNotificationLink = Url::fromRequest()->setPath(
|
|
|
|
'monitoring/services/send-custom-notification'
|
2014-09-24 07:47:26 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-03-06 09:23:11 +01:00
|
|
|
/**
|
|
|
|
* Add a service comment
|
|
|
|
*/
|
|
|
|
public function addCommentAction()
|
|
|
|
{
|
|
|
|
$this->assertPermission('monitoring/command/comment/add');
|
|
|
|
|
|
|
|
$form = new AddCommentCommandForm();
|
|
|
|
$form->setTitle($this->translate('Add Service Comments'));
|
|
|
|
$this->handleCommandForm($form);
|
|
|
|
}
|
|
|
|
|
2014-09-24 07:47:26 +02:00
|
|
|
/**
|
|
|
|
* Acknowledge service problems
|
|
|
|
*/
|
|
|
|
public function acknowledgeProblemAction()
|
|
|
|
{
|
2015-02-03 17:36:16 +01:00
|
|
|
$this->assertPermission('monitoring/command/acknowledge-problem');
|
|
|
|
|
2015-03-02 18:39:10 +01:00
|
|
|
$form = new AcknowledgeProblemCommandForm();
|
|
|
|
$form->setTitle($this->translate('Acknowledge Service Problems'));
|
|
|
|
$this->handleCommandForm($form);
|
2014-09-24 07:47:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reschedule service checks
|
|
|
|
*/
|
|
|
|
public function rescheduleCheckAction()
|
|
|
|
{
|
2015-02-03 17:36:16 +01:00
|
|
|
$this->assertPermission('monitoring/command/schedule-check');
|
|
|
|
|
2015-03-02 18:39:10 +01:00
|
|
|
$form = new ScheduleServiceCheckCommandForm();
|
|
|
|
$form->setTitle($this->translate('Reschedule Service Checks'));
|
|
|
|
$this->handleCommandForm($form);
|
2014-09-24 07:47:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Schedule service downtimes
|
|
|
|
*/
|
|
|
|
public function scheduleDowntimeAction()
|
|
|
|
{
|
2015-02-03 17:36:16 +01:00
|
|
|
$this->assertPermission('monitoring/command/downtime/schedule');
|
|
|
|
|
2015-03-02 18:39:10 +01:00
|
|
|
$form = new ScheduleServiceDowntimeCommandForm();
|
|
|
|
$form->setTitle($this->translate('Schedule Service Downtimes'));
|
|
|
|
$this->handleCommandForm($form);
|
2014-09-24 07:47:26 +02:00
|
|
|
}
|
2014-12-11 15:52:23 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Submit passive service check results
|
|
|
|
*/
|
|
|
|
public function processCheckResultAction()
|
|
|
|
{
|
2015-02-03 17:36:16 +01:00
|
|
|
$this->assertPermission('monitoring/command/process-check-result');
|
|
|
|
|
2015-03-02 18:39:10 +01:00
|
|
|
$form = new ProcessCheckResultCommandForm();
|
2015-08-04 13:25:17 +02:00
|
|
|
$form->setBackend($this->backend);
|
2015-03-02 18:39:10 +01:00
|
|
|
$form->setTitle($this->translate('Submit Passive Service Check Results'));
|
|
|
|
$this->handleCommandForm($form);
|
2014-12-11 15:52:23 +01:00
|
|
|
}
|
2015-03-12 16:08:22 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Send a custom notification for services
|
|
|
|
*/
|
|
|
|
public function sendCustomNotificationAction()
|
|
|
|
{
|
|
|
|
$this->assertPermission('monitoring/command/send-custom-notification');
|
|
|
|
|
|
|
|
$form = new SendCustomNotificationCommandForm();
|
|
|
|
$form->setTitle($this->translate('Send Custom Service Notification'));
|
|
|
|
$this->handleCommandForm($form);
|
|
|
|
}
|
2014-09-24 07:47:26 +02:00
|
|
|
}
|