Merge branch 'feature/provide-acknowledgement-view-10032'
This commit is contained in:
commit
1b7b0c7232
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||
|
||||
use Icinga\Module\Monitoring\Controller;
|
||||
use Icinga\Web\Url;
|
||||
use Icinga\Web\Widget\Tabextension\DashboardAction;
|
||||
use Icinga\Module\Monitoring\DataView\DataView;
|
||||
|
||||
class Monitoring_AcknowledgementController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create full report
|
||||
*/
|
||||
public function indexAction()
|
||||
{
|
||||
$this->getTabs()->add(
|
||||
'acknowledgement',
|
||||
array(
|
||||
'title' => $this->translate(
|
||||
'Show acknowledgements'
|
||||
),
|
||||
'label' => $this->translate('Acknowledgements'),
|
||||
'url' => Url::fromRequest()
|
||||
)
|
||||
)->extend(new DashboardAction())->activate('acknowledgement');
|
||||
$this->view->title = $this->translate('Acknowledgement');
|
||||
$this->setAutorefreshInterval(15);
|
||||
$query = $this->backend->select()->from(
|
||||
'acknowledgement',
|
||||
array(
|
||||
'acknowledgement_id',
|
||||
'instance_id',
|
||||
'entry_time',
|
||||
'object_id',
|
||||
'state',
|
||||
'author_name',
|
||||
'comment_data',
|
||||
'is_sticky',
|
||||
'persistent_comment',
|
||||
'acknowledgement_id',
|
||||
'notify_contacts',
|
||||
'end_time',
|
||||
'endpoint_object_id',
|
||||
'acknowledgement_is_service',
|
||||
'service',
|
||||
'host'
|
||||
)
|
||||
);
|
||||
|
||||
$this->applyRestriction('monitoring/filter/objects', $query);
|
||||
$this->filterQuery($query);
|
||||
$this->view->acknowledgements = $query;
|
||||
|
||||
$this->setupLimitControl()
|
||||
->setupPaginationControl($this->view->acknowledgements)
|
||||
->setupSortControl(array(
|
||||
'entry_time' => $this->translate('Entry Time'),
|
||||
'end_time' => $this->translate('End Time'),
|
||||
'state' => $this->translate('Object State'),
|
||||
'author_name' => $this->translate('Author Name')
|
||||
), $this->view->acknowledgements);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply filters on a DataView
|
||||
*
|
||||
* @param DataView $dataView The DataView to apply filters on
|
||||
*
|
||||
* @return DataView $dataView
|
||||
*/
|
||||
protected function filterQuery(DataView $dataView)
|
||||
{
|
||||
$this->setupFilterControl($dataView);
|
||||
$this->handleFormatRequest($dataView);
|
||||
return $dataView;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
use Icinga\Module\Monitoring\Object\Service;
|
||||
use Icinga\Module\Monitoring\Object\Host;
|
||||
?>
|
||||
|
||||
<?php if (! $this->compact): ?>
|
||||
<div class="controls">
|
||||
<?= $this->tabs; ?>
|
||||
<div class="dontprint">
|
||||
<?= $this->render('list/components/selectioninfo.phtml'); ?>
|
||||
</div>
|
||||
<h1><?= count($acknowledgements) ?> <?= $this->translate('Acknowledgements') ?></h1>
|
||||
<?= $this->sortBox; ?>
|
||||
<?= $this->limiter; ?>
|
||||
<?= $this->paginator; ?>
|
||||
<?= $this->filterEditor; ?>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
<div class="content">
|
||||
<table data-base-target="_next" class="action">
|
||||
<tbody>
|
||||
<?php foreach ($acknowledgements as $acknowledgement): ?>
|
||||
<?php
|
||||
$state = $acknowledgement->acknowledgement_is_service ?
|
||||
Service::getStateText($acknowledgement->state) : Host::getStateText($acknowledgement->state);
|
||||
?>
|
||||
<tr class="state handled <?= $state ?>" >
|
||||
<td class="state" style="width: 10em;">
|
||||
<?= $this->icon('ok') ?>
|
||||
<?= $this->timeAgo($acknowledgement->entry_time, $this->compact); ?>
|
||||
<br>
|
||||
<?= sprintf($this->translate(
|
||||
'State was %s.',
|
||||
'Describes the past host or service state when an acknowledgement was set.'
|
||||
), $state) ?>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<?php if ($acknowledgement->acknowledgement_is_service): ?>
|
||||
<?= $this->icon('service', $this->translate('Service Acknowledgement')) ?>
|
||||
<?= $this->qlink(
|
||||
$this->escape($acknowledgement->host) . ': ' . $this->escape($acknowledgement->service),
|
||||
'monitoring/service/show',
|
||||
array(
|
||||
'service' => $acknowledgement->service,
|
||||
'host' => $acknowledgement->host
|
||||
),
|
||||
array(
|
||||
'title' => sprintf(
|
||||
$this->translate(
|
||||
'Show detailed information for this acknowledgement about service %s on host %s'
|
||||
),
|
||||
$acknowledgement->service,
|
||||
$acknowledgement->host
|
||||
),
|
||||
'class' => 'rowaction'
|
||||
)
|
||||
); ?>
|
||||
<?php else: ?>
|
||||
<?= $this->icon('host', $this->translate('Host Acknowledgement')) ?>
|
||||
<?= $this->qlink(
|
||||
$this->escape($acknowledgement->host),
|
||||
'monitoring/host/show',
|
||||
array(
|
||||
'host' => $acknowledgement->host
|
||||
),
|
||||
array(
|
||||
'title' => sprintf(
|
||||
$this->translate('Show detailed information for this acknowledgement on host %s'),
|
||||
$acknowledgement->host
|
||||
),
|
||||
'class' => 'rowaction'
|
||||
)
|
||||
); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<br>
|
||||
<?= $this->icon('comment_data', $this->translate('Comment')); ?>
|
||||
<?= isset($acknowledgement->author_name) ? '[' . $this->escape($acknowledgement->author_name) . '] ' : ''; ?>
|
||||
<strong><?= $this->escape($acknowledgement->comment_data); ?></strong>
|
||||
|
||||
<br>
|
||||
<?= $acknowledgement->is_sticky ? $this->icon(
|
||||
'attach',
|
||||
$this->translate('Sticky, all notifications are disabled until the host or services recovers'
|
||||
)) : ''; ?>
|
||||
<?= $acknowledgement->notify_contacts ? $this->icon(
|
||||
'bell',
|
||||
$this->translate('Contacts are being notified about this acknowledgement.'
|
||||
)) : ''; ?>
|
||||
<?= $acknowledgement->end_time ? sprintf(
|
||||
$this->translate('Expires %s.'),
|
||||
'<strong>' . $this->timeUntil($acknowledgement->end_time) . '</strong>'
|
||||
) : $this->translate('Does not expire.'); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php if (! count($acknowledgements)): ?>
|
||||
<?= $this->translate('No comments found matching the filter'); ?>
|
||||
<?php endif ?>
|
||||
</div>
|
|
@ -184,7 +184,10 @@ $section->add($this->translate('Notifications'), array(
|
|||
'url' => 'monitoring/list/notifications',
|
||||
'priority' => 80
|
||||
));
|
||||
|
||||
$section->add($this->translate('Acknowledgements'), array(
|
||||
'url' => 'monitoring/acknowledgement',
|
||||
'priority' => 90
|
||||
));
|
||||
|
||||
/*
|
||||
* History Section
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||
|
||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||
|
||||
use Zend_Db_Select;
|
||||
|
||||
/**
|
||||
* Query for active acknowledgements
|
||||
*/
|
||||
class AcknowledgementQuery extends IdoQuery
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $columnMap = array(
|
||||
'acknowledgements' => array(
|
||||
'acknowledgement_id' => 'a.acknowledgement_id',
|
||||
'instance_id' => 'a.instance_id',
|
||||
'entry_time' => 'UNIX_TIMESTAMP(a.entry_time)',
|
||||
'object_id' => 'a.object_id',
|
||||
'state' => 'a.state',
|
||||
'author_name' => 'a.author_name',
|
||||
'comment_data' => 'a.comment_data',
|
||||
'is_sticky' => 'a.is_sticky',
|
||||
'persistent_comment' => 'a.persistent_comment',
|
||||
'acknowledgement_id' => 'a.acknowledgement_id',
|
||||
'notify_contacts' => 'a.notify_contacts',
|
||||
'end_time' => 'UNIX_TIMESTAMP(a.end_time)',
|
||||
'endpoint_object_id' => 'a.endpoint_object_id'
|
||||
),
|
||||
'objects' => array(
|
||||
'acknowledgement_is_service' => '(CASE WHEN o.objecttype_id = 2 THEN 1 ELSE 0 END)',
|
||||
'host' => 'o.name1',
|
||||
'service' => 'o.name2'
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* @var Zend_Db_Select
|
||||
*/
|
||||
protected $acknowledgementQuery;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function joinBaseTables()
|
||||
{
|
||||
$this->acknowledgementQuery = $this->db->select();
|
||||
$this->select->from(
|
||||
array('o' => $this->prefix . 'objects'),
|
||||
array()
|
||||
);
|
||||
$this->select->joinLeft(
|
||||
array('hs' => $this->prefix . 'hoststatus'),
|
||||
'hs.host_object_id = o.object_id AND o.is_active = 1',
|
||||
array()
|
||||
);
|
||||
$this->select->joinLeft(
|
||||
array('ss' => $this->prefix . 'servicestatus'),
|
||||
'ss.service_object_id = o.object_id AND o.is_active = 1',
|
||||
array()
|
||||
);
|
||||
$ackTable = $this->prefix . 'acknowledgements';
|
||||
$subQuery = '(SELECT MAX(acknowledgement_id) FROM ' . $ackTable . ' WHERE object_id = a.object_id)';
|
||||
$this->select->join(
|
||||
array('a' => $ackTable),
|
||||
'o.object_id = a.object_id ' .
|
||||
'AND ((o.objecttype_id = 2 AND ss.problem_has_been_acknowledged = 1 AND ss.acknowledgement_type = 2) ' .
|
||||
' OR (o.objecttype_id = 1 AND hs.problem_has_been_acknowledged = 1 AND hs.acknowledgement_type = 2)) ' .
|
||||
'AND o.is_active = 1 AND a.acknowledgement_id = ' . $subQuery,
|
||||
array()
|
||||
);
|
||||
|
||||
$this->joinedVirtualTables['objects'] = true;
|
||||
$this->joinedVirtualTables['acknowledgements'] = true;
|
||||
$this->joinedVirtualTables['hoststatus'] = true;
|
||||
$this->joinedVirtualTables['servicestatus'] = true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||
|
||||
namespace Icinga\Module\Monitoring\DataView;
|
||||
|
||||
/**
|
||||
* Host and service comments view
|
||||
*/
|
||||
class Acknowledgement extends DataView
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getColumns()
|
||||
{
|
||||
return array(
|
||||
'acknowledgement_id',
|
||||
'instance_id',
|
||||
'entry_time',
|
||||
'object_id',
|
||||
'state',
|
||||
'author_name',
|
||||
'comment_data',
|
||||
'is_sticky',
|
||||
'persistent_comment',
|
||||
'acknowledgement_id',
|
||||
'notify_contacts',
|
||||
'end_time',
|
||||
'acknowledgement_is_service'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getStaticFilterColumns()
|
||||
{
|
||||
return array(
|
||||
'acknowledgement_id',
|
||||
'entry_time',
|
||||
'state',
|
||||
'author_name',
|
||||
'comment_data',
|
||||
'is_sticky',
|
||||
'persistent_comment',
|
||||
'acknowledgement_id',
|
||||
'notify_contacts',
|
||||
'entry_time',
|
||||
'acknowledgement_is_service'
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue