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