commit
2ade247dbb
|
@ -0,0 +1,117 @@
|
|||
<?php
|
||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||
|
||||
use Icinga\Module\Monitoring\Controller;
|
||||
use Icinga\Module\Monitoring\Object\Service;
|
||||
use Icinga\Module\Monitoring\Object\Host;
|
||||
use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeCommandForm;
|
||||
use Icinga\Web\Url;
|
||||
use Icinga\Web\Widget\Tabextension\DashboardAction;
|
||||
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Display detailed information about a downtime
|
||||
*/
|
||||
class Monitoring_DowntimeController extends Controller
|
||||
{
|
||||
protected $downtime;
|
||||
|
||||
protected $isService;
|
||||
|
||||
/**
|
||||
* Add tabs
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$downtimeId = $this->params->get('downtime_id');
|
||||
|
||||
$this->downtime = $this->backend->select()->from('downtime', array(
|
||||
'id' => 'downtime_internal_id',
|
||||
'objecttype' => 'downtime_objecttype',
|
||||
'comment' => 'downtime_comment',
|
||||
'author_name' => 'downtime_author_name',
|
||||
'start' => 'downtime_start',
|
||||
'scheduled_start' => 'downtime_scheduled_start',
|
||||
'scheduled_end' => 'downtime_scheduled_end',
|
||||
'end' => 'downtime_end',
|
||||
'duration' => 'downtime_duration',
|
||||
'is_flexible' => 'downtime_is_flexible',
|
||||
'is_fixed' => 'downtime_is_fixed',
|
||||
'is_in_effect' => 'downtime_is_in_effect',
|
||||
'entry_time' => 'downtime_entry_time',
|
||||
'host_state' => 'downtime_host_state',
|
||||
'service_state' => 'downtime_service_state',
|
||||
'host_name',
|
||||
'host',
|
||||
'service',
|
||||
'service_description',
|
||||
'host_display_name',
|
||||
'service_display_name'
|
||||
))->where('downtime_internal_id', $downtimeId)->getQuery()->fetchRow();
|
||||
|
||||
if (false === $this->downtime) {
|
||||
throw new Zend_Controller_Action_Exception($this->translate('Downtime not found'));
|
||||
}
|
||||
|
||||
if (isset($this->downtime->service_description)) {
|
||||
$this->isService = true;
|
||||
} else {
|
||||
$this->isService = false;
|
||||
}
|
||||
|
||||
$this->getTabs()
|
||||
->add(
|
||||
'downtime',
|
||||
array(
|
||||
'title' => $this->translate(
|
||||
'Display detailed information about a downtime.'
|
||||
),
|
||||
'icon' => 'plug',
|
||||
'label' => $this->translate('Downtime'),
|
||||
'url' =>'monitoring/downtimes/show'
|
||||
)
|
||||
)->activate('downtime')->extend(new DashboardAction());
|
||||
}
|
||||
|
||||
public function showAction()
|
||||
{
|
||||
$this->view->downtime = $this->downtime;
|
||||
$this->view->isService = $this->isService;
|
||||
$this->view->stateName = isset($this->downtime->service_description) ?
|
||||
Service::getStateText($this->downtime->service_state) :
|
||||
Host::getStateText($this->downtime->host_state);
|
||||
$this->view->listAllLink = Url::fromPath('monitoring/list/downtimes');
|
||||
$this->view->showHostLink = Url::fromPath('monitoring/host/show')
|
||||
->setParam('host', $this->downtime->host);
|
||||
$this->view->showServiceLink = Url::fromPath('monitoring/service/show')
|
||||
->setParam('host', $this->downtime->host)
|
||||
->setParam('service', $this->downtime->service_description);
|
||||
if ($this->hasPermission('monitoring/command/downtime/delete')) {
|
||||
$this->view->delDowntimeForm = $this->createDelDowntimeForm();
|
||||
}
|
||||
}
|
||||
|
||||
private function createDelDowntimeForm()
|
||||
{
|
||||
$this->assertPermission('monitoring/command/downtime/delete');
|
||||
|
||||
$delDowntimeForm = new DeleteDowntimeCommandForm();
|
||||
$delDowntimeForm->setAction(
|
||||
Url::fromPath('monitoring/downtime/show')
|
||||
->setParam('downtime_id', $this->downtime->id)
|
||||
);
|
||||
$delDowntimeForm->populate(
|
||||
array(
|
||||
'redirect' => Url::fromPath('monitoring/list/downtimes'),
|
||||
'downtime_id' => $this->downtime->id
|
||||
)
|
||||
);
|
||||
$delDowntimeForm->handleRequest();
|
||||
return $delDowntimeForm;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,121 @@
|
|||
<?php
|
||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||
|
||||
use Icinga\Data\Filter\Filter;
|
||||
use Icinga\Module\Monitoring\Controller;
|
||||
use Icinga\Module\Monitoring\Object\Service;
|
||||
use Icinga\Module\Monitoring\Object\Host;
|
||||
use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimesCommandForm;
|
||||
use Icinga\Web\Url;
|
||||
use Icinga\Web\Widget\Tabextension\DashboardAction;
|
||||
|
||||
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Display detailed information about a downtime
|
||||
*/
|
||||
class Monitoring_DowntimesController extends Controller
|
||||
{
|
||||
protected $downtimes;
|
||||
|
||||
protected $filter;
|
||||
|
||||
/**
|
||||
* Add tabs
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$this->filter = Filter::fromQueryString(str_replace(
|
||||
'downtime_id',
|
||||
'downtime_internal_id',
|
||||
(string)$this->params
|
||||
));
|
||||
$this->downtimes = $this->backend->select()->from('downtime', array(
|
||||
'id' => 'downtime_internal_id',
|
||||
'objecttype' => 'downtime_objecttype',
|
||||
'comment' => 'downtime_comment',
|
||||
'author_name' => 'downtime_author_name',
|
||||
'start' => 'downtime_start',
|
||||
'scheduled_start' => 'downtime_scheduled_start',
|
||||
'scheduled_end' => 'downtime_scheduled_end',
|
||||
'end' => 'downtime_end',
|
||||
'duration' => 'downtime_duration',
|
||||
'is_flexible' => 'downtime_is_flexible',
|
||||
'is_fixed' => 'downtime_is_fixed',
|
||||
'is_in_effect' => 'downtime_is_in_effect',
|
||||
'entry_time' => 'downtime_entry_time',
|
||||
'host_state' => 'downtime_host_state',
|
||||
'service_state' => 'downtime_service_state',
|
||||
'host_name',
|
||||
'host',
|
||||
'service',
|
||||
'service_description',
|
||||
'host_display_name',
|
||||
'service_display_name'
|
||||
))->addFilter($this->filter)->getQuery()->fetchAll();
|
||||
if (false === $this->downtimes) {
|
||||
throw new Zend_Controller_Action_Exception(
|
||||
$this->translate('Downtime not found')
|
||||
);
|
||||
}
|
||||
|
||||
$this->getTabs()
|
||||
->add(
|
||||
'downtimes',
|
||||
array(
|
||||
'title' => $this->translate(
|
||||
'Display detailed information about multiple downtimes.'
|
||||
),
|
||||
'icon' => 'plug',
|
||||
'label' => $this->translate('Downtimes'),
|
||||
'url' =>'monitoring/downtimes/show'
|
||||
)
|
||||
)->activate('downtimes')->extend(new DashboardAction());
|
||||
|
||||
foreach ($this->downtimes as $downtime) {
|
||||
if (isset($downtime->service_description)) {
|
||||
$downtime->isService = true;
|
||||
} else {
|
||||
$downtime->isService = false;
|
||||
}
|
||||
|
||||
if ($downtime->isService) {
|
||||
$downtime->stateText = Service::getStateText($downtime->service_state);
|
||||
} else {
|
||||
$downtime->stateText = Host::getStateText($downtime->host_state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function showAction()
|
||||
{
|
||||
$this->view->downtimes = $this->downtimes;
|
||||
$this->view->listAllLink = Url::fromPath('monitoring/list/downtimes')
|
||||
->setQueryString($this->filter->toQueryString());
|
||||
$this->view->removeAllLink = Url::fromPath('monitoring/downtimes/remove-all')
|
||||
->setParams($this->params);
|
||||
}
|
||||
|
||||
public function removeAllAction()
|
||||
{
|
||||
$this->assertPermission('monitoring/command/downtime/delete');
|
||||
$this->view->downtimes = $this->downtimes;
|
||||
$this->view->listAllLink = Url::fromPath('monitoring/list/downtimes')
|
||||
->setQueryString($this->filter->toQueryString());
|
||||
$delDowntimeForm = new DeleteDowntimesCommandForm();
|
||||
$delDowntimeForm->setTitle($this->view->translate('Remove all Downtimes'));
|
||||
$delDowntimeForm->addDescription(sprintf(
|
||||
$this->translate('Confirm removal of %d downtimes.'),
|
||||
count($this->downtimes)
|
||||
));
|
||||
$delDowntimeForm->setDowntimes($this->downtimes)
|
||||
->setRedirectUrl(Url::fromPath('monitoring/list/downtimes'))
|
||||
->handleRequest();
|
||||
$this->view->delDowntimeForm = $delDowntimeForm;
|
||||
}
|
||||
}
|
|
@ -4,12 +4,13 @@
|
|||
namespace Icinga\Module\Monitoring\Forms\Command\Object;
|
||||
|
||||
use Icinga\Module\Monitoring\Command\Object\DeleteDowntimeCommand;
|
||||
use \Icinga\Module\Monitoring\Forms\Command\CommandForm;
|
||||
use Icinga\Web\Notification;
|
||||
|
||||
/**
|
||||
* Form for deleting host or service downtimes
|
||||
*/
|
||||
class DeleteDowntimeCommandForm extends ObjectsCommandForm
|
||||
class DeleteDowntimeCommandForm extends CommandForm
|
||||
{
|
||||
/**
|
||||
* (non-PHPDoc)
|
||||
|
@ -20,29 +21,30 @@ class DeleteDowntimeCommandForm extends ObjectsCommandForm
|
|||
$this->setAttrib('class', 'inline');
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* (non-PHPDoc)
|
||||
* @see \Icinga\Web\Form::createElements() For the method documentation.
|
||||
*/
|
||||
public function createElements(array $formData = array())
|
||||
{
|
||||
$this->addElements(array(
|
||||
$this->addElements(
|
||||
array(
|
||||
'hidden',
|
||||
'downtime_id',
|
||||
array(
|
||||
'required' => true,
|
||||
'decorators' => array('ViewHelper')
|
||||
)
|
||||
),
|
||||
array(
|
||||
'hidden',
|
||||
'redirect',
|
||||
'hidden',
|
||||
'downtime_id',
|
||||
array(
|
||||
'decorators' => array('ViewHelper')
|
||||
)
|
||||
),
|
||||
array(
|
||||
'decorators' => array('ViewHelper')
|
||||
'hidden',
|
||||
'redirect',
|
||||
array(
|
||||
'decorators' => array('ViewHelper')
|
||||
)
|
||||
)
|
||||
)
|
||||
));
|
||||
);
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -70,23 +72,29 @@ class DeleteDowntimeCommandForm extends ObjectsCommandForm
|
|||
|
||||
/**
|
||||
* (non-PHPDoc)
|
||||
* @see \Icinga\Web\Form::onSuccess() For the method documentation.
|
||||
* @see \Icinga\Web\Form::onSuccess() For the method documentation.
|
||||
*/
|
||||
public function onSuccess()
|
||||
{
|
||||
foreach ($this->objects as $object) {
|
||||
/** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
|
||||
$delDowntime = new DeleteDowntimeCommand();
|
||||
$delDowntime
|
||||
->setObject($object)
|
||||
->setDowntimeId($this->getElement('downtime_id')->getValue());
|
||||
$this->getTransport($this->request)->send($delDowntime);
|
||||
}
|
||||
$id = $this->getElement('downtime_id')->getValue();
|
||||
|
||||
// Presence of downtime id, only delete this specific downtime
|
||||
$firstDowntime = $this->downtimes[0];
|
||||
|
||||
$delDowntime = new DeleteDowntimeCommand();
|
||||
$delDowntime->setDowntimeId($id);
|
||||
$delDowntime->setDowntimeType(
|
||||
isset($firstDowntime->service_description) ?
|
||||
DeleteDowntimeCommand::DOWNTIME_TYPE_SERVICE :
|
||||
DeleteDowntimeCommand::DOWNTIME_TYPE_HOST
|
||||
);
|
||||
$this->getTransport($this->request)->send($delDowntime);
|
||||
|
||||
$redirect = $this->getElement('redirect')->getValue();
|
||||
if (! empty($redirect)) {
|
||||
$this->setRedirectUrl($redirect);
|
||||
}
|
||||
Notification::success($this->translate('Deleting downtime..'));
|
||||
Notification::success($this->translate('Deleting downtime.'));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||
|
||||
namespace Icinga\Module\Monitoring\Forms\Command\Object;
|
||||
|
||||
use Icinga\Module\Monitoring\Command\Object\DeleteDowntimeCommand;
|
||||
use \Icinga\Module\Monitoring\Forms\Command\CommandForm;
|
||||
use Icinga\Web\Notification;
|
||||
|
||||
/**
|
||||
* Form for deleting host or service downtimes
|
||||
*/
|
||||
class DeleteDowntimesCommandForm extends CommandForm
|
||||
{
|
||||
protected $downtimes;
|
||||
|
||||
/**
|
||||
* (non-PHPDoc)
|
||||
* @see \Zend_Form::init() For the method documentation.
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$this->setAttrib('class', 'inline');
|
||||
}
|
||||
|
||||
/**
|
||||
* (non-PHPDoc)
|
||||
* @see \Icinga\Web\Form::createElements() For the method documentation.
|
||||
*/
|
||||
public function createElements(array $formData = array())
|
||||
{
|
||||
$this->addElements(array(
|
||||
array(
|
||||
'hidden',
|
||||
'redirect',
|
||||
array(
|
||||
'decorators' => array('ViewHelper')
|
||||
)
|
||||
)
|
||||
));
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* (non-PHPDoc)
|
||||
* @see \Icinga\Web\Form::getSubmitLabel() For the method documentation.
|
||||
*/
|
||||
public function getSubmitLabel()
|
||||
{
|
||||
return $this->translatePlural('Remove', 'Remove All', count($this->downtimes));
|
||||
}
|
||||
|
||||
/**
|
||||
* (non-PHPDoc)
|
||||
* @see \Icinga\Web\Form::onSuccess() For the method documentation.
|
||||
*/
|
||||
public function onSuccess()
|
||||
{
|
||||
foreach ($this->downtimes as $downtime) {
|
||||
$delDowntime = new DeleteDowntimeCommand();
|
||||
$delDowntime->setDowntimeId($downtime->id);
|
||||
$delDowntime->setDowntimeType(
|
||||
isset($downtime->service_description) ?
|
||||
DeleteDowntimeCommand::DOWNTIME_TYPE_SERVICE :
|
||||
DeleteDowntimeCommand::DOWNTIME_TYPE_HOST
|
||||
);
|
||||
$this->getTransport($this->request)->send($delDowntime);
|
||||
}
|
||||
$redirect = $this->getElement('redirect')->getValue();
|
||||
if (! empty($redirect)) {
|
||||
$this->setRedirectUrl($redirect);
|
||||
}
|
||||
Notification::success($this->translate('Deleting downtime.'));
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the downtimes to be deleted upon success
|
||||
*
|
||||
* @param type $downtimes
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDowntimes($downtimes)
|
||||
{
|
||||
$this->downtimes = $downtimes;
|
||||
return $this;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
<div class="controls">
|
||||
|
||||
<?php if (! $this->compact): ?>
|
||||
<?= $this->tabs; ?>
|
||||
<?php endif ?>
|
||||
|
||||
<?= $this->render('partials/downtime/downtime-header.phtml'); ?>
|
||||
</div>
|
||||
<div class="content object-command">
|
||||
<?= $delDowntimeForm; ?>
|
||||
</div>
|
|
@ -0,0 +1,121 @@
|
|||
<div class="controls">
|
||||
<?php if (! $this->compact): ?>
|
||||
<?= $this->tabs; ?>
|
||||
<?php endif ?>
|
||||
|
||||
<?= $this->render('partials/downtime/downtime-header.phtml'); ?>
|
||||
</div>
|
||||
<div class="content">
|
||||
<h3><?= $this->translate('Downtime detail information') ?></h3>
|
||||
<table class="avp">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>
|
||||
<?= $this->isService ? $this->translate('Service') : $this->translate('Host') ?>
|
||||
</th>
|
||||
<td data-base-target="_next">
|
||||
<?php if ($this->isService): ?>
|
||||
<?php
|
||||
$link = $this->link()->service(
|
||||
$downtime->service_description,
|
||||
$downtime->service_display_name,
|
||||
$downtime->host_name,
|
||||
$downtime->host_display_name
|
||||
);
|
||||
$icon = $this->icon('service', $this->translate('Service'));
|
||||
?>
|
||||
<?php else: ?>
|
||||
<?php
|
||||
$icon = $this->icon('host', $this->translate('Host'));
|
||||
$link = $this->link()->host($downtime->host_name, $downtime->host_display_name)
|
||||
?>
|
||||
<?php endif ?>
|
||||
<?= $icon ?>
|
||||
<?= $link ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr title="<?= $this->translate('The name of the person who scheduled this downtime'); ?>">
|
||||
<th><?= $this->translate('Author') ?></th>
|
||||
<td><?= $this->icon('user', $this->translate('User')) ?> <?= $this->escape($this->downtime->author_name) ?></td>
|
||||
</tr>
|
||||
<tr title="<?= $this->translate('A comment, as entered by the author, associated with the scheduled downtime'); ?>">
|
||||
<th><?= $this->translate('Comment') ?></th>
|
||||
<td><?= $this->icon('comment', $this->translate('Comment')) ?> <?= $this->escape($this->downtime->comment) ?></td>
|
||||
</tr>
|
||||
<tr title="<?= $this->translate('Date and time this downtime was entered'); ?>">
|
||||
<th><?= $this->translate('Entry Time') ?></th>
|
||||
<td> <?= date('d.m.y H:i' ,$this->escape($this->downtime->entry_time)) ?></td>
|
||||
</tr>
|
||||
<tr class="newsection">
|
||||
<th><?= $this->escape(
|
||||
$this->downtime->is_flexible ?
|
||||
$this->translate('Flexible') : $this->translate('Fixed')
|
||||
); ?></th>
|
||||
<td>
|
||||
<?= $this->escape(
|
||||
$this->downtime->is_flexible ?
|
||||
$this->translate('Flexible downtimes have a hard start and end time,'
|
||||
. ' but also an additional restriction on the duration in which '
|
||||
. ' the host or service may actually be down.') :
|
||||
$this->translate('Fixed downtimes have a static start and end time.')
|
||||
); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr title="<?= $this->translate('The date/time the scheduled downtime is'
|
||||
. ' supposed to start. If this is a flexible (non-fixed) downtime, '
|
||||
. 'this refers to the earliest possible time that the downtime'
|
||||
. ' can start'); ?>">
|
||||
<th><?= $this->translate('Scheduled start') ?></th>
|
||||
<td><?= date('d.m.y H:i', $this->downtime->scheduled_start) ?></td>
|
||||
</tr>
|
||||
<tr title="<?= $this->translate('The date/time the scheduled downtime is '
|
||||
. 'supposed to end. If this is a flexible (non-fixed) downtime, '
|
||||
. 'this refers to the last possible time that the downtime can '
|
||||
. 'start'); ?>">
|
||||
<th><?= $this->translate('Scheduled end') ?></th>
|
||||
<td><?= date('d.m.y H:i', $this->downtime->scheduled_end) ?></td>
|
||||
</tr>
|
||||
<?php if ($this->downtime->is_flexible): ?>
|
||||
<tr title="<?= $this->translate('Indicates the number of seconds that the '
|
||||
. 'scheduled downtime should last. This is usually only needed if'
|
||||
. ' this is a flexible downtime, which can start at a variable '
|
||||
. 'time, but lasts for the specified duration'); ?>">
|
||||
<th tit><?= $this->translate('Duration') ?></th>
|
||||
<td><?= $this->format()->duration($this->escape($this->downtime->duration)); ?></td>
|
||||
</tr>
|
||||
<tr title="<?= $this->translate('he date/time the scheduled downtime was'
|
||||
. ' actually started'); ?>">
|
||||
<th><?= $this->translate('Actual start time') ?></th>
|
||||
<td><?= date('d.m.y H:i', $downtime->start); ?></td>
|
||||
</tr>
|
||||
<tr title="<?= $this->translate('The date/time the scheduled downtime '
|
||||
. 'actually ended'); ?>">
|
||||
<th><?= $this->translate('Actual end time') ?></th>
|
||||
<td><?= date('d.m.y H:i', $downtime->end); ?></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
|
||||
<tr class="newsection">
|
||||
<th><?= $this->translate('In effect') ?></th>
|
||||
<td>
|
||||
<?= $this->escape(
|
||||
$this->downtime->is_in_effect ?
|
||||
$this->translate('Yes') : $this->translate('No')
|
||||
);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php if (isset($delDowntimeForm)): // Form is unset if the current user lacks the respective permission ?>
|
||||
<tr class="newsection">
|
||||
<th><?= $this->translate('Commands') ?></th>
|
||||
<td>
|
||||
<?= $delDowntimeForm ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<div class="controls">
|
||||
|
||||
<?php if (! $this->compact): ?>
|
||||
<?= $this->tabs; ?>
|
||||
<?php endif ?>
|
||||
|
||||
<?= $this->render('partials/downtime/downtimes-header.phtml'); ?>
|
||||
</div>
|
||||
|
||||
<div class="content object-command">
|
||||
<?= $delDowntimeForm ?>
|
||||
</div>
|
|
@ -0,0 +1,33 @@
|
|||
<div class="controls">
|
||||
|
||||
<?php if (! $this->compact): ?>
|
||||
<?= $this->tabs; ?>
|
||||
<?php endif ?>
|
||||
|
||||
<?= $this->render('partials/downtime/downtimes-header.phtml'); ?>
|
||||
</p>
|
||||
</div>
|
||||
<div class="content">
|
||||
<h3><?= $this->icon('reschedule') ?> <?= $this->translate('Commands') ?> </h3>
|
||||
<p>
|
||||
<?= sprintf(
|
||||
$this->translate('Issue commands to all %s selected downtimes.'),
|
||||
'<b>' . count($downtimes) . '</b>'
|
||||
)
|
||||
?>
|
||||
<div>
|
||||
<?= $this->qlink(
|
||||
sprintf(
|
||||
$this->translate('Remove all %d scheduled downtimes'),
|
||||
count($downtimes)
|
||||
),
|
||||
$removeAllLink,
|
||||
null,
|
||||
array(
|
||||
'icon' => 'trash',
|
||||
'title' => $this->translate('Remove all selected downtimes.')
|
||||
)
|
||||
) ?>
|
||||
</div>
|
||||
</p>
|
||||
</div>
|
|
@ -15,12 +15,15 @@ if (! $this->compact): ?>
|
|||
<?php
|
||||
|
||||
if (count($downtimes) === 0) {
|
||||
echo $this->translate('No downtimes found matching the filter') . '</div>';
|
||||
echo $this->translate('No downtimes found matching the filter,'
|
||||
. ' maybe the downtime already expired.') . '</div>';
|
||||
return;
|
||||
}
|
||||
?>
|
||||
|
||||
<table data-base-target="_next" class="action">
|
||||
<table data-base-target="_next"
|
||||
class="action multiselect"
|
||||
data-icinga-multiselect-url="/icingaweb2/monitoring/downtimes/show"
|
||||
data-icinga-multiselect-data="downtime_id">
|
||||
<tbody>
|
||||
<?php foreach ($downtimes as $downtime): ?>
|
||||
<?php
|
||||
|
@ -48,15 +51,22 @@ if (count($downtimes) === 0) {
|
|||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php if ($isService): ?>
|
||||
<?= $this->icon('service', $this->translate('Service')); ?>
|
||||
<?= $this->link()->service(
|
||||
$downtime->service_description, $downtime->service_display_name, $downtime->host_name, $downtime->host_display_name
|
||||
) ?>
|
||||
<?php else: ?>
|
||||
<?= $this->icon('host', $this->translate('Host')); ?>
|
||||
<?= $this->link()->host($downtime->host_name, $downtime->host_display_name) ?>
|
||||
<?php endif ?>
|
||||
<?php
|
||||
if ($isService) {
|
||||
echo $this->icon('service');
|
||||
} else {
|
||||
echo $this->icon('host');
|
||||
}
|
||||
?>
|
||||
<?= $this->qlink(
|
||||
sprintf($this->translate('%s on %s', 'Service running on host'), $downtime->service_display_name, $downtime->host_display_name),
|
||||
'monitoring/downtime/show',
|
||||
array('downtime_id' => $downtime->id),
|
||||
array('title' => sprintf(
|
||||
$this->translate('Show detailed information for downtime on %s for %s'),
|
||||
$downtime->service_display_name,
|
||||
$downtime->host_display_name
|
||||
))) ?>
|
||||
<br>
|
||||
<?= $this->icon('comment', $this->translate('Comment')); ?> [<?= $this->escape($downtime->author_name) ?>] <?= $this->escape($downtime->comment) ?>
|
||||
<br>
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
<table class="action">
|
||||
<tr class="state <?= $stateName; ?><?= $downtime->is_in_effect ? ' handled' : ''; ?>">
|
||||
<td class="state">
|
||||
<strong><?= $downtime->is_in_effect ? $this->translate('Expires') : $this->translate('Starts'); ?></strong>
|
||||
<br>
|
||||
<?=
|
||||
$this->dateTimeRenderer(
|
||||
($downtime->is_in_effect ? $downtime->end : $downtime->start),
|
||||
true
|
||||
)->render(
|
||||
$this->translate('on %s', 'datetime'),
|
||||
$this->translate('at %s', 'time'),
|
||||
$this->translate('in %s', 'timespan')
|
||||
);
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<small>
|
||||
<?php if ($downtime->is_flexible): ?>
|
||||
<?php if ($downtime->is_in_effect): ?>
|
||||
<?= sprintf(
|
||||
$this->isService
|
||||
? $this->translate('This flexible service downtime was started on %s at %s and lasts for %s until %s at %s.')
|
||||
: $this->translate('This flexible host downtime was started on %s at %s and lasts for %s until %s at %s.'),
|
||||
date('d.m.y', $downtime->start),
|
||||
date('H:i', $downtime->start),
|
||||
$this->format()->duration($downtime->duration),
|
||||
date('d.m.y', $downtime->end),
|
||||
date('H:i', $downtime->end)
|
||||
); ?>
|
||||
<?php else: ?>
|
||||
<?= sprintf(
|
||||
$this->isService
|
||||
? $this->translate('This flexible service downtime has been scheduled to start between %s - %s and to last for %s.')
|
||||
: $this->translate('This flexible host downtime has been scheduled to start between %s - %s and to last for %s.'),
|
||||
date('d.m.y H:i', $downtime->scheduled_start),
|
||||
date('d.m.y H:i', $downtime->scheduled_end),
|
||||
$this->format()->duration($downtime->duration)
|
||||
); ?>
|
||||
<?php endif ?>
|
||||
<?php else: ?>
|
||||
<?php if ($downtime->is_in_effect): ?>
|
||||
<?= sprintf(
|
||||
$this->isService
|
||||
? $this->translate('This fixed service downtime was started on %s at %s and expires on %s at %s.')
|
||||
: $this->translate('This fixed host downtime was started on %s at %s and expires on %s at %s.'),
|
||||
date('d.m.y', $downtime->start),
|
||||
date('H:i', $downtime->start),
|
||||
date('d.m.y', $downtime->end),
|
||||
date('H:i', $downtime->end)
|
||||
); ?>
|
||||
<?php else: ?>
|
||||
<?= sprintf(
|
||||
$this->isService
|
||||
? $this->translate('This fixed service downtime has been scheduled to start on %s at %s and to end on %s at %s.')
|
||||
: $this->translate('This fixed host downtime has been scheduled to start on %s at %s and to end on %s at %s.'),
|
||||
date('d.m.y', $downtime->scheduled_start),
|
||||
date('H:i', $downtime->scheduled_start),
|
||||
date('d.m.y', $downtime->scheduled_end),
|
||||
date('H:i', $downtime->scheduled_end)
|
||||
); ?>
|
||||
<?php endif ?>
|
||||
<?php endif ?>
|
||||
</small>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
|
@ -0,0 +1,92 @@
|
|||
<table class="action">
|
||||
<tbody>
|
||||
<?php $i = 0; foreach ($downtimes as $downtime):
|
||||
if (++ $i > 5) {
|
||||
continue;
|
||||
} ?>
|
||||
<tr class="state <?= $downtime->stateText ?>">
|
||||
<td class="state">
|
||||
<strong><?= $downtime->is_in_effect ? $this->translate('Expires') : $this->translate('Starts'); ?></strong>
|
||||
<br>
|
||||
<?=
|
||||
$this->dateTimeRenderer(
|
||||
($downtime->is_in_effect ? $downtime->end : $downtime->start),
|
||||
true
|
||||
)->render(
|
||||
$this->translate('on %s', 'datetime'),
|
||||
$this->translate('at %s', 'time'),
|
||||
$this->translate('in %s', 'timespan')
|
||||
);
|
||||
?>
|
||||
</td>
|
||||
<td class="name oneline">
|
||||
<?php if ($downtime->isService): ?>
|
||||
<?= $this->icon('service', $this->translate('Service')) ?>
|
||||
<b><?= $downtime->service ?> on <?= $downtime->host_name ?>.</b>
|
||||
<?php else: ?>
|
||||
<?= $this->icon('host', $this->translate('Host')) ?>
|
||||
<b><?= $downtime->host_name ?>.</b>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($downtime->is_flexible): ?>
|
||||
<?php if ($downtime->is_in_effect): ?>
|
||||
<?= sprintf(
|
||||
$this->isService
|
||||
? $this->translate('This flexible service downtime was started on %s at %s and lasts for %s until %s at %s.')
|
||||
: $this->translate('This flexible host downtime was started on %s at %s and lasts for %s until %s at %s.'),
|
||||
date('d.m.y', $downtime->start),
|
||||
date('H:i', $downtime->start),
|
||||
$this->format()->duration($downtime->duration),
|
||||
date('d.m.y', $downtime->end),
|
||||
date('H:i', $downtime->end)
|
||||
); ?>
|
||||
<?php else: ?>
|
||||
<?= sprintf(
|
||||
$this->isService
|
||||
? $this->translate('This flexible service downtime has been scheduled to start between %s - %s and to last for %s.')
|
||||
: $this->translate('This flexible host downtime has been scheduled to start between %s - %s and to last for %s.'),
|
||||
date('d.m.y H:i', $downtime->scheduled_start),
|
||||
date('d.m.y H:i', $downtime->scheduled_end),
|
||||
$this->format()->duration($downtime->duration)
|
||||
); ?>
|
||||
<?php endif ?>
|
||||
<?php else: ?>
|
||||
<?php if ($downtime->is_in_effect): ?>
|
||||
<?= sprintf(
|
||||
$this->isService
|
||||
? $this->translate('This fixed service downtime was started on %s at %s and expires on %s at %s.')
|
||||
: $this->translate('This fixed host downtime was started on %s at %s and expires on %s at %s.'),
|
||||
date('d.m.y', $downtime->start),
|
||||
date('H:i', $downtime->start),
|
||||
date('d.m.y', $downtime->end),
|
||||
date('H:i', $downtime->end)
|
||||
); ?>
|
||||
<?php else: ?>
|
||||
<?= sprintf(
|
||||
$this->isService
|
||||
? $this->translate('This fixed service downtime has been scheduled to start on %s at %s and to end on %s at %s.')
|
||||
: $this->translate('This fixed host downtime has been scheduled to start on %s at %s and to end on %s at %s.'),
|
||||
date('d.m.y', $downtime->scheduled_start),
|
||||
date('H:i', $downtime->scheduled_start),
|
||||
date('d.m.y', $downtime->scheduled_end),
|
||||
date('H:i', $downtime->scheduled_end)
|
||||
); ?>
|
||||
<?php endif ?>
|
||||
<?php endif ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
<?= $this->qlink(
|
||||
sprintf($this->translate('List all %d downtimes …'), count($downtimes)),
|
||||
$listAllLink,
|
||||
null,
|
||||
array(
|
||||
'title' => $this->translate('List all'),
|
||||
'data-base-target' => "_next"
|
||||
)
|
||||
) ?>
|
||||
</p>
|
|
@ -47,12 +47,15 @@ foreach ($object->downtimes as $downtime) {
|
|||
) : $this->escape($downtime->comment);
|
||||
|
||||
if ((bool) $downtime->is_in_effect) {
|
||||
$state = 'in downtime since ' . $this->timeSince($downtime->start);
|
||||
$state = 'in downtime since ';
|
||||
$time = $this->timeSince($downtime->start);
|
||||
} else {
|
||||
if ((bool) $downtime->is_fixed) {
|
||||
$state = 'scheduled ' . $this->timeUntil($downtime->start);
|
||||
$state = 'scheduled ';
|
||||
$time = $this->timeUntil($downtime->start);
|
||||
} else {
|
||||
$state = 'scheduled flexible ' . $this->timeUntil($downtime->start);
|
||||
$state = 'scheduled flexible ';
|
||||
$time = $this->timeUntil($downtime->start);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,7 +68,14 @@ foreach ($object->downtimes as $downtime) {
|
|||
$delDowntimeForm->populate(array('downtime_id' => $downtime->id));
|
||||
echo $delDowntimeForm;
|
||||
} ?>
|
||||
<span class="sr-only"><?= $this->translate('Downtime'); ?></span><?= $state; ?> - <?= str_replace(array('\r\n', '\n'), '<br>', $commentText); ?>
|
||||
<span class="sr-only"><?= $this->translate('Downtime'); ?></span>
|
||||
<?=
|
||||
$this->qlink(
|
||||
$state,
|
||||
'monitoring/downtime/show',
|
||||
array('downtime_id' => $downtime->id),
|
||||
array('data-base-target' => '_next')
|
||||
) . $time ; ?> - <?= str_replace(array('\r\n', '\n'), '<br>', $commentText); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } // endforeach ?>
|
||||
|
|
|
@ -3,19 +3,22 @@
|
|||
|
||||
namespace Icinga\Module\Monitoring\Command\Object;
|
||||
|
||||
use Icinga\Module\Monitoring\Command\IcingaCommand;
|
||||
|
||||
/**
|
||||
* Delete a host or service downtime
|
||||
*/
|
||||
class DeleteDowntimeCommand extends ObjectCommand
|
||||
class DeleteDowntimeCommand extends IcingaCommand
|
||||
{
|
||||
/**
|
||||
* (non-PHPDoc)
|
||||
* @see \Icinga\Module\Monitoring\Command\Object\ObjectCommand::$allowedObjects For the property documentation.
|
||||
* Downtime for a host
|
||||
*/
|
||||
protected $allowedObjects = array(
|
||||
self::TYPE_HOST,
|
||||
self::TYPE_SERVICE
|
||||
);
|
||||
const DOWNTIME_TYPE_HOST = 'host';
|
||||
|
||||
/**
|
||||
* Downtime for a service
|
||||
*/
|
||||
const DOWNTIME_TYPE_SERVICE = 'service';
|
||||
|
||||
/**
|
||||
* ID of the downtime that is to be deleted
|
||||
|
@ -24,6 +27,31 @@ class DeleteDowntimeCommand extends ObjectCommand
|
|||
*/
|
||||
protected $downtimeId;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var type
|
||||
*/
|
||||
protected $downtimeType = self::DOWNTIME_TYPE_HOST;
|
||||
|
||||
/**
|
||||
* Set the downtime type, either host or service
|
||||
*
|
||||
* @param string $type the downtime type
|
||||
*/
|
||||
public function setDowntimeType($type)
|
||||
{
|
||||
$this->downtimeType = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function getDowntimeType()
|
||||
{
|
||||
return $this->downtimeType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the ID of the downtime that is to be deleted
|
||||
*
|
||||
|
|
|
@ -337,7 +337,7 @@ class IcingaCommandFileCommandRenderer implements IcingaCommandRendererInterface
|
|||
|
||||
public function renderDeleteDowntime(DeleteDowntimeCommand $command)
|
||||
{
|
||||
if ($command->getObject()->getType() === $command::TYPE_HOST) {
|
||||
if ($command->getDowntimeType() === 'host') {
|
||||
$commandString = 'DEL_HOST_DOWNTIME';
|
||||
} else {
|
||||
$commandString = 'DEL_SVC_DOWNTIME';
|
||||
|
|
|
@ -89,9 +89,7 @@ abstract class MonitoredObjectController extends Controller
|
|||
}
|
||||
if (! empty($this->object->downtimes) && $auth->hasPermission('monitoring/command/downtime/delete')) {
|
||||
$delDowntimeForm = new DeleteDowntimeCommandForm();
|
||||
$delDowntimeForm
|
||||
->setObjects($this->object)
|
||||
->handleRequest();
|
||||
$delDowntimeForm->handleRequest();
|
||||
$this->view->delDowntimeForm = $delDowntimeForm;
|
||||
}
|
||||
$this->view->object = $this->object;
|
||||
|
@ -147,16 +145,6 @@ abstract class MonitoredObjectController extends Controller
|
|||
$this->handleCommandForm(new DeleteCommentCommandForm());
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a downtime
|
||||
*/
|
||||
public function deleteDowntimeAction()
|
||||
{
|
||||
$this->assertHttpMethod('POST');
|
||||
$this->assertPermission('monitoring/command/downtime/delete');
|
||||
$this->handleCommandForm(new DeleteDowntimeCommandForm());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create tabs
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue