2014-09-04 09:43:37 -04:00
|
|
|
<?php
|
2016-02-08 09:41:00 -05:00
|
|
|
/* Icinga Web 2 | (c) 2014 Icinga Development Team | GPLv2+ */
|
2014-09-04 09:43:37 -04:00
|
|
|
|
2015-08-28 03:19:43 -04:00
|
|
|
namespace Icinga\Module\Monitoring\Controllers;
|
|
|
|
|
|
2014-11-14 05:17:22 -05:00
|
|
|
use Icinga\Module\Monitoring\Forms\Command\Object\AcknowledgeProblemCommandForm;
|
|
|
|
|
use Icinga\Module\Monitoring\Forms\Command\Object\AddCommentCommandForm;
|
2014-12-12 06:44:31 -05:00
|
|
|
use Icinga\Module\Monitoring\Forms\Command\Object\ProcessCheckResultCommandForm;
|
2014-11-14 05:17:22 -05:00
|
|
|
use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleServiceCheckCommandForm;
|
|
|
|
|
use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleServiceDowntimeCommandForm;
|
2015-03-12 11:08:22 -04:00
|
|
|
use Icinga\Module\Monitoring\Forms\Command\Object\SendCustomNotificationCommandForm;
|
2014-09-04 09:43:37 -04:00
|
|
|
use Icinga\Module\Monitoring\Object\Service;
|
2014-09-16 12:46:27 -04:00
|
|
|
use Icinga\Module\Monitoring\Web\Controller\MonitoredObjectController;
|
2015-05-18 05:45:39 -04:00
|
|
|
use Icinga\Web\Hook;
|
2016-01-12 02:58:32 -05:00
|
|
|
use Icinga\Web\Navigation\Navigation;
|
2014-09-04 09:43:37 -04:00
|
|
|
|
2015-08-28 03:19:43 -04:00
|
|
|
class ServiceController extends MonitoredObjectController
|
2014-09-04 09:43:37 -04:00
|
|
|
{
|
|
|
|
|
/**
|
2015-08-28 03:20:33 -04:00
|
|
|
* {@inheritdoc}
|
2014-09-04 09:43:37 -04:00
|
|
|
*/
|
2014-09-16 12:46:27 -04:00
|
|
|
protected $commandRedirectUrl = 'monitoring/service/show';
|
2014-09-04 09:43:37 -04:00
|
|
|
|
2014-09-16 12:46:27 -04:00
|
|
|
/**
|
|
|
|
|
* Fetch the requested service from the monitoring backend
|
|
|
|
|
*/
|
|
|
|
|
public function init()
|
2014-09-04 09:43:37 -04:00
|
|
|
{
|
2015-05-20 04:36:05 -04:00
|
|
|
$service = new Service(
|
2017-01-27 08:48:59 -05:00
|
|
|
$this->backend,
|
|
|
|
|
$this->params->getRequired('host'),
|
|
|
|
|
$this->params->getRequired('service')
|
2015-05-20 04:36:05 -04:00
|
|
|
);
|
2015-01-27 08:57:54 -05:00
|
|
|
|
2015-06-05 08:44:35 -04:00
|
|
|
$this->applyRestriction('monitoring/filter/objects', $service);
|
2015-01-27 08:57:54 -05:00
|
|
|
|
2014-09-12 10:50:42 -04:00
|
|
|
if ($service->fetch() === false) {
|
2015-05-20 04:36:05 -04:00
|
|
|
$this->httpNotFound($this->translate('Service not found'));
|
2014-09-12 10:50:42 -04:00
|
|
|
}
|
2014-09-16 12:46:27 -04:00
|
|
|
$this->object = $service;
|
2014-09-24 01:16:33 -04:00
|
|
|
$this->createTabs();
|
|
|
|
|
$this->getTabs()->activate('service');
|
2019-07-12 04:23:06 -04:00
|
|
|
$this->view->title = $service->service_display_name;
|
|
|
|
|
$this->view->defaultTitle = join(' :: ', [
|
|
|
|
|
$service->host_display_name,
|
|
|
|
|
$this->translate('Services'),
|
|
|
|
|
$this->view->defaultTitle
|
|
|
|
|
]);
|
2014-09-04 09:43:37 -04:00
|
|
|
}
|
|
|
|
|
|
2015-05-18 05:45:39 -04:00
|
|
|
/**
|
|
|
|
|
* Get service actions from hook
|
|
|
|
|
*
|
2016-01-12 02:58:32 -05:00
|
|
|
* @return Navigation
|
2015-05-18 05:45:39 -04:00
|
|
|
*/
|
|
|
|
|
protected function getServiceActions()
|
|
|
|
|
{
|
2016-01-12 02:58:32 -05:00
|
|
|
$navigation = new Navigation();
|
2015-05-18 05:45:39 -04:00
|
|
|
foreach (Hook::all('Monitoring\\ServiceActions') as $hook) {
|
2016-01-12 02:58:32 -05:00
|
|
|
$navigation->merge($hook->getNavigation($this->object));
|
2015-05-18 05:45:39 -04:00
|
|
|
}
|
|
|
|
|
|
2016-01-12 02:58:32 -05:00
|
|
|
return $navigation;
|
2015-05-18 05:45:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Show a service
|
|
|
|
|
*/
|
|
|
|
|
public function showAction()
|
|
|
|
|
{
|
|
|
|
|
$this->view->actions = $this->getServiceActions();
|
|
|
|
|
parent::showAction();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-09-12 10:50:42 -04:00
|
|
|
/**
|
2014-09-16 12:46:27 -04:00
|
|
|
* Acknowledge a service problem
|
2014-09-12 10:50:42 -04:00
|
|
|
*/
|
|
|
|
|
public function acknowledgeProblemAction()
|
|
|
|
|
{
|
2015-01-22 09:23:02 -05:00
|
|
|
$this->assertPermission('monitoring/command/acknowledge-problem');
|
|
|
|
|
|
2015-03-02 12:39:10 -05:00
|
|
|
$form = new AcknowledgeProblemCommandForm();
|
|
|
|
|
$form->setTitle($this->translate('Acknowledge Service Problem'));
|
|
|
|
|
$this->handleCommandForm($form);
|
2014-09-12 10:50:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add a service comment
|
|
|
|
|
*/
|
|
|
|
|
public function addCommentAction()
|
|
|
|
|
{
|
2015-01-22 10:56:00 -05:00
|
|
|
$this->assertPermission('monitoring/command/comment/add');
|
2015-01-22 09:23:02 -05:00
|
|
|
|
2015-03-02 12:39:10 -05:00
|
|
|
$form = new AddCommentCommandForm();
|
|
|
|
|
$form->setTitle($this->translate('Add Service Comment'));
|
|
|
|
|
$this->handleCommandForm($form);
|
2014-09-12 10:50:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Reschedule a service check
|
|
|
|
|
*/
|
|
|
|
|
public function rescheduleCheckAction()
|
|
|
|
|
{
|
2015-01-22 09:23:02 -05:00
|
|
|
$this->assertPermission('monitoring/command/schedule-check');
|
|
|
|
|
|
2015-03-02 12:39:10 -05:00
|
|
|
$form = new ScheduleServiceCheckCommandForm();
|
|
|
|
|
$form->setTitle($this->translate('Reschedule Service Check'));
|
|
|
|
|
$this->handleCommandForm($form);
|
2014-09-12 10:50:42 -04:00
|
|
|
}
|
|
|
|
|
|
2014-09-04 09:43:37 -04:00
|
|
|
/**
|
|
|
|
|
* Schedule a service downtime
|
|
|
|
|
*/
|
|
|
|
|
public function scheduleDowntimeAction()
|
|
|
|
|
{
|
2015-01-22 10:56:00 -05:00
|
|
|
$this->assertPermission('monitoring/command/downtime/schedule');
|
2015-01-22 09:23:02 -05:00
|
|
|
|
2015-03-02 12:39:10 -05:00
|
|
|
$form = new ScheduleServiceDowntimeCommandForm();
|
|
|
|
|
$form->setTitle($this->translate('Schedule Service Downtime'));
|
|
|
|
|
$this->handleCommandForm($form);
|
2014-09-04 09:43:37 -04:00
|
|
|
}
|
2014-12-11 09:52:23 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Submit a passive service check result
|
|
|
|
|
*/
|
|
|
|
|
public function processCheckResultAction()
|
|
|
|
|
{
|
2015-01-22 09:23:02 -05:00
|
|
|
$this->assertPermission('monitoring/command/process-check-result');
|
|
|
|
|
|
2015-03-02 12:39:10 -05:00
|
|
|
$form = new ProcessCheckResultCommandForm();
|
|
|
|
|
$form->setTitle($this->translate('Submit Passive Service Check Result'));
|
|
|
|
|
$this->handleCommandForm($form);
|
2014-12-11 09:52:23 -05:00
|
|
|
}
|
2015-03-12 11:08:22 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Send a custom notification for a service
|
|
|
|
|
*/
|
|
|
|
|
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-04 09:43:37 -04:00
|
|
|
}
|