parent
0a6f4745e4
commit
bb8cad2a85
|
@ -47,6 +47,7 @@ use Icinga\Module\Monitoring\DataView\Contactgroup as ContactgroupView;
|
|||
use Icinga\Module\Monitoring\DataView\HostAndServiceStatus as HostAndServiceStatusView;
|
||||
use Icinga\Module\Monitoring\DataView\Comment as CommentView;
|
||||
use Icinga\Module\Monitoring\DataView\Groupsummary as GroupsummaryView;
|
||||
use Icinga\Module\Monitoring\DataView\EventHistory as EventHistoryView;
|
||||
|
||||
class Monitoring_ListController extends MonitoringController
|
||||
{
|
||||
|
@ -366,6 +367,21 @@ class Monitoring_ListController extends MonitoringController
|
|||
));
|
||||
}
|
||||
|
||||
public function eventhistoryAction()
|
||||
{
|
||||
$query = EventHistoryView::fromRequest(
|
||||
$this->_request
|
||||
)->getQuery();
|
||||
|
||||
$this->view->history = $query->paginate();
|
||||
|
||||
$this->setupSortControl(
|
||||
array(
|
||||
)
|
||||
);
|
||||
$this->handleFormatRequest($query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the 'format' and 'view' parameter
|
||||
*
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
<h1>History</h1>
|
||||
|
||||
<?php if (!empty($history)): ?>
|
||||
<div data-icinga-component="app/mainDetailGrid">
|
||||
<?= $this->paginationControl($history, null, null, array('preserve' => $this->preserve)); ?>
|
||||
<table class="table table-condensed">
|
||||
<tbody>
|
||||
<?php foreach ($history as $event): ?>
|
||||
<tr>
|
||||
<td><?= date('d.m. H:i', $event->timestamp); ?></td>
|
||||
|
||||
<td>
|
||||
<?php if (isset($event->service)): ?>
|
||||
<a href="<?= $this->href('monitoring/show/service', array(
|
||||
'host' => $event->host,
|
||||
'service' => $event->service
|
||||
)); ?>">
|
||||
<?= $event->service ?>
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<a href="<?= $this->href('monitoring/show/host', array(
|
||||
'host' => $event->host
|
||||
)); ?>">
|
||||
<?= $event->host ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<?php
|
||||
switch ($event->type) {
|
||||
case 'notify':
|
||||
$icon = '{{NOTIFICATION_ICON}}';
|
||||
$title = 'Notification';
|
||||
$msg = $event->output;
|
||||
break;
|
||||
case 'comment':
|
||||
$icon = '{{COMMENT_ICON}}';
|
||||
$title = 'Comment';
|
||||
$msg = $event->output;
|
||||
break;
|
||||
case 'ack':
|
||||
$icon = '{{ACKNOWLEDGEMENT_ICON}}';
|
||||
$title = 'Acknowledgement';
|
||||
$msg = $event->output;
|
||||
break;
|
||||
case 'dt_comment':
|
||||
$icon = '{{IN_DOWNTIME_ICON}}';
|
||||
$title = 'In Downtime';
|
||||
$msg = $event->output;
|
||||
break;
|
||||
case 'flapping':
|
||||
$icon = '{{FLAPPING_ICON}}';
|
||||
$title = 'Flapping';
|
||||
$msg = $event->output;
|
||||
break;
|
||||
case 'hard_state':
|
||||
$icon = '{{HARDSTATE_ICON}}';
|
||||
$title = 'Hard State';
|
||||
$msg = '[' . $event->attempt . '/' . $event->max_attempts . ']';
|
||||
break;
|
||||
case 'soft_state':
|
||||
$icon = '{{SOFTSTATE_ICON}}';
|
||||
$title = 'Soft State';
|
||||
$msg = '[' . $event->attempt . '/' . $event->max_attempts . ']';
|
||||
break;
|
||||
case 'dt_start':
|
||||
$icon = '{{DOWNTIME_START_ICON}}';
|
||||
$title = 'Downtime Start';
|
||||
$msg = $event->output;
|
||||
break;
|
||||
case 'dt_end':
|
||||
$icon = '{{DOWNTIME_END_ICON}}';
|
||||
$title = 'Downtime End';
|
||||
$msg = $event->output;
|
||||
break;
|
||||
}
|
||||
?>
|
||||
<a href="#" title="<?= $title ?>"><i><?= $icon ?></i></a>
|
||||
<?php if (!empty($msg)) { echo $msg; } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<? endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php endif; ?>
|
|
@ -90,13 +90,13 @@
|
|||
'host' => $object->host_name,
|
||||
'service' => $object->service_description
|
||||
)); ?>">
|
||||
All events for <?= $event->service_description ?>
|
||||
All events for <?= $object->service_description ?>
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<a href="<?= $this->href('monitoring/list/eventhistory', array(
|
||||
'host' => $object->host_name
|
||||
)); ?>">
|
||||
All events for <?= $event->host_name ?>
|
||||
All events for <?= $object->host_name ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
|
|
@ -30,9 +30,7 @@ class EventHistoryQuery extends AbstractQuery
|
|||
'max_attempts' => 'eh.max_attempts',
|
||||
'output' => 'eh.output', // we do not want long_output
|
||||
//'problems' => 'CASE WHEN eh.state = 0 OR eh.state IS NULL THEN 0 ELSE 1 END',
|
||||
'type' => 'eh.type',
|
||||
'service_host_name' => 'eho.name1 COLLATE latin1_general_ci',
|
||||
'service_description' => 'eho.name2 COLLATE latin1_general_ci'
|
||||
'type' => 'eh.type'
|
||||
),
|
||||
'hostgroups' => array(
|
||||
'hostgroup' => 'hgo.name1 COLLATE latin1_general_ci',
|
||||
|
|
|
@ -49,7 +49,7 @@ abstract class DataView
|
|||
public static function getTableName()
|
||||
{
|
||||
$tableName = explode('\\', get_called_class());
|
||||
$tableName = strtolower(end($tableName));
|
||||
$tableName = end($tableName);
|
||||
return $tableName;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Icinga\Module\Monitoring\DataView;
|
||||
|
||||
class EventHistory extends DataView
|
||||
{
|
||||
/**
|
||||
* Retrieve columns provided by this view
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getColumns()
|
||||
{
|
||||
return array(
|
||||
'raw_timestamp',
|
||||
'timestamp',
|
||||
'host',
|
||||
'service',
|
||||
'host_name',
|
||||
'state',
|
||||
'attempt',
|
||||
'max_attempts',
|
||||
'output',
|
||||
'type'
|
||||
);
|
||||
}
|
||||
|
||||
public function getSortRules()
|
||||
{
|
||||
return array(
|
||||
'raw_timestamp' => array(
|
||||
'default_dir' => self::SORT_DESC
|
||||
),
|
||||
'timestamp' => array(
|
||||
'default_dir' => self::SORT_DESC
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function getFilterColumns()
|
||||
{
|
||||
return array(
|
||||
'hostgroups'
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue