2014-09-16 18:46:58 +02:00
|
|
|
<?php
|
2015-02-04 10:46:36 +01:00
|
|
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
2014-09-16 18:46:58 +02:00
|
|
|
|
2015-05-06 14:21:46 +02:00
|
|
|
use Icinga\Exception\MissingParameterException;
|
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\ScheduleHostCheckCommandForm;
|
|
|
|
use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleHostDowntimeCommandForm;
|
2015-03-12 16:08:22 +01:00
|
|
|
use Icinga\Module\Monitoring\Forms\Command\Object\SendCustomNotificationCommandForm;
|
2014-09-16 18:46:58 +02:00
|
|
|
use Icinga\Module\Monitoring\Object\Host;
|
|
|
|
use Icinga\Module\Monitoring\Web\Controller\MonitoredObjectController;
|
2015-01-14 11:01:39 +01:00
|
|
|
use Icinga\Web\Hook;
|
2014-09-16 18:46:58 +02:00
|
|
|
|
|
|
|
class Monitoring_HostController extends MonitoredObjectController
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* (non-PHPDoc)
|
|
|
|
* @see MonitoredObjectController::$commandRedirectUrl For the property documentation.
|
|
|
|
*/
|
|
|
|
protected $commandRedirectUrl = 'monitoring/host/show';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fetch the requested host from the monitoring backend
|
|
|
|
*
|
|
|
|
* @throws Zend_Controller_Action_Exception If the host was not found
|
|
|
|
*/
|
|
|
|
public function init()
|
|
|
|
{
|
2015-05-06 14:21:46 +02:00
|
|
|
if ($this->params->get('host') === null) {
|
|
|
|
throw new MissingParameterException(
|
|
|
|
$this->translate('Required parameter \'%s\' is missing'),
|
|
|
|
'host'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-04-20 16:11:22 +02:00
|
|
|
$host = new Host($this->backend, $this->params->get('host'));
|
2015-01-27 14:57:22 +01:00
|
|
|
|
|
|
|
$this->applyRestriction('monitoring/hosts/filter', $host);
|
|
|
|
|
2014-09-16 18:46:58 +02:00
|
|
|
if ($host->fetch() === false) {
|
2015-05-06 14:21:46 +02:00
|
|
|
throw new Zend_Controller_Action_Exception(
|
|
|
|
sprintf($this->translate('Host \'%s\' not found'), $this->params->get('host')),
|
|
|
|
404
|
|
|
|
);
|
2014-09-16 18:46:58 +02:00
|
|
|
}
|
|
|
|
$this->object = $host;
|
2014-09-24 07:16:33 +02:00
|
|
|
$this->createTabs();
|
|
|
|
$this->getTabs()->activate('host');
|
2014-09-16 18:46:58 +02:00
|
|
|
}
|
|
|
|
|
2015-01-14 11:01:39 +01:00
|
|
|
protected function getHostActions()
|
|
|
|
{
|
|
|
|
$urls = array();
|
|
|
|
|
|
|
|
foreach (Hook::all('Monitoring\\HostActions') as $hook) {
|
|
|
|
foreach ($hook->getActionsForHost($this->object) as $id => $url) {
|
|
|
|
$urls[$id] = $url;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $urls;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show a host
|
|
|
|
*/
|
|
|
|
public function showAction()
|
|
|
|
{
|
|
|
|
$this->view->hostActions = $this->getHostActions();
|
|
|
|
parent::showAction();
|
|
|
|
}
|
|
|
|
|
2014-09-16 18:46:58 +02:00
|
|
|
/**
|
|
|
|
* Acknowledge a host problem
|
|
|
|
*/
|
|
|
|
public function acknowledgeProblemAction()
|
|
|
|
{
|
2015-01-22 15:22:20 +01:00
|
|
|
$this->assertPermission('monitoring/command/acknowledge-problem');
|
|
|
|
|
2015-03-02 18:39:10 +01:00
|
|
|
$form = new AcknowledgeProblemCommandForm();
|
|
|
|
$form->setTitle($this->translate('Acknowledge Host Problem'));
|
|
|
|
$this->handleCommandForm($form);
|
2014-09-16 18:46:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a host comment
|
|
|
|
*/
|
|
|
|
public function addCommentAction()
|
|
|
|
{
|
2015-01-22 16:56:00 +01:00
|
|
|
$this->assertPermission('monitoring/command/comment/add');
|
2015-01-22 15:22:20 +01:00
|
|
|
|
2015-03-02 18:39:10 +01:00
|
|
|
$form = new AddCommentCommandForm();
|
|
|
|
$form->setTitle($this->translate('Add Host Comment'));
|
|
|
|
$this->handleCommandForm($form);
|
2014-09-16 18:46:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reschedule a host check
|
|
|
|
*/
|
|
|
|
public function rescheduleCheckAction()
|
|
|
|
{
|
2015-01-22 15:22:20 +01:00
|
|
|
$this->assertPermission('monitoring/command/schedule-check');
|
|
|
|
|
2015-03-02 18:39:10 +01:00
|
|
|
$form = new ScheduleHostCheckCommandForm();
|
|
|
|
$form->setTitle($this->translate('Reschedule Host Check'));
|
|
|
|
$this->handleCommandForm($form);
|
2014-09-16 18:46:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Schedule a host downtime
|
|
|
|
*/
|
|
|
|
public function scheduleDowntimeAction()
|
|
|
|
{
|
2015-01-22 16:56:00 +01:00
|
|
|
$this->assertPermission('monitoring/command/downtime/schedule');
|
2015-01-22 15:22:20 +01:00
|
|
|
|
2015-03-02 18:39:10 +01:00
|
|
|
$form = new ScheduleHostDowntimeCommandForm();
|
|
|
|
$form->setTitle($this->translate('Schedule Host Downtime'));
|
|
|
|
$this->handleCommandForm($form);
|
2014-09-16 18:46:58 +02:00
|
|
|
}
|
2014-12-11 15:52:23 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Submit a passive host check result
|
|
|
|
*/
|
|
|
|
public function processCheckResultAction()
|
|
|
|
{
|
2015-01-22 15:22:20 +01:00
|
|
|
$this->assertPermission('monitoring/command/process-check-result');
|
|
|
|
|
2015-03-02 18:39:10 +01:00
|
|
|
$form = new ProcessCheckResultCommandForm();
|
|
|
|
$form->setTitle($this->translate('Submit Passive Host 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 host
|
|
|
|
*/
|
|
|
|
public function sendCustomNotificationAction()
|
|
|
|
{
|
|
|
|
$this->assertPermission('monitoring/command/send-custom-notification');
|
|
|
|
|
|
|
|
$form = new SendCustomNotificationCommandForm();
|
|
|
|
$form->setTitle($this->translate('Send Custom Host Notification'));
|
|
|
|
$this->handleCommandForm($form);
|
|
|
|
}
|
2014-09-16 18:46:58 +02:00
|
|
|
}
|