mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-26 23:34:08 +02:00
commit
da5f1bb9e7
@ -28,3 +28,6 @@ Servicegroups.route = "/monitoring/list/servicegroups"
|
|||||||
|
|
||||||
Hostgroups.title = "Hostgroups"
|
Hostgroups.title = "Hostgroups"
|
||||||
Hostgroups.route = "/monitoring/list/hostgroups"
|
Hostgroups.route = "/monitoring/list/hostgroups"
|
||||||
|
|
||||||
|
History.title = "History"
|
||||||
|
History.route = "/monitoring/list/eventhistory"
|
||||||
|
@ -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\HostAndServiceStatus as HostAndServiceStatusView;
|
||||||
use Icinga\Module\Monitoring\DataView\Comment as CommentView;
|
use Icinga\Module\Monitoring\DataView\Comment as CommentView;
|
||||||
use Icinga\Module\Monitoring\DataView\Groupsummary as GroupsummaryView;
|
use Icinga\Module\Monitoring\DataView\Groupsummary as GroupsummaryView;
|
||||||
|
use Icinga\Module\Monitoring\DataView\EventHistory as EventHistoryView;
|
||||||
|
|
||||||
class Monitoring_ListController extends MonitoringController
|
class Monitoring_ListController extends MonitoringController
|
||||||
{
|
{
|
||||||
@ -366,6 +367,17 @@ class Monitoring_ListController extends MonitoringController
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function eventhistoryAction()
|
||||||
|
{
|
||||||
|
$query = EventHistoryView::fromRequest($this->_request)->getQuery();
|
||||||
|
$this->handleFormatRequest($query);
|
||||||
|
$this->view->history = $query->paginate();
|
||||||
|
$this->setupSortControl(
|
||||||
|
array(
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle the 'format' and 'view' parameter
|
* Handle the 'format' and 'view' parameter
|
||||||
*
|
*
|
||||||
|
@ -0,0 +1,104 @@
|
|||||||
|
<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): ?>
|
||||||
|
<?php
|
||||||
|
$class = null;
|
||||||
|
$isService = false;
|
||||||
|
?>
|
||||||
|
<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>
|
||||||
|
<small>
|
||||||
|
on <?= $event->host ?>
|
||||||
|
</small>
|
||||||
|
<?php $isService = true; ?>
|
||||||
|
<?php else: ?>
|
||||||
|
<a href="<?= $this->href('monitoring/show/host', array(
|
||||||
|
'host' => $event->host
|
||||||
|
)); ?>">
|
||||||
|
<?= $event->host ?>
|
||||||
|
</a>
|
||||||
|
<?php endif; ?>
|
||||||
|
<br />
|
||||||
|
<?php
|
||||||
|
switch ($event->type) {
|
||||||
|
case 'notify':
|
||||||
|
$icon = 'notification';
|
||||||
|
$title = 'Notification';
|
||||||
|
$msg = $event->output;
|
||||||
|
break;
|
||||||
|
case 'comment':
|
||||||
|
$icon = 'comment';
|
||||||
|
$title = 'Comment';
|
||||||
|
$msg = $event->output;
|
||||||
|
break;
|
||||||
|
case 'ack':
|
||||||
|
$icon = 'acknowledgement';
|
||||||
|
$title = 'Acknowledgement';
|
||||||
|
$msg = $event->output;
|
||||||
|
break;
|
||||||
|
case 'dt_comment':
|
||||||
|
$icon = 'in-downtime';
|
||||||
|
$title = 'In Downtime';
|
||||||
|
$msg = $event->output;
|
||||||
|
break;
|
||||||
|
case 'flapping':
|
||||||
|
$icon = 'flapping';
|
||||||
|
$title = 'Flapping';
|
||||||
|
$msg = $event->output;
|
||||||
|
break;
|
||||||
|
case 'hard_state':
|
||||||
|
$icon = '{{HARDSTATE_ICON}}';
|
||||||
|
$title = 'Hard State';
|
||||||
|
$msg = $event->output . '<br /><small>Attempt ' . $event->attempt . '/' . $event->max_attempts . ' (Hard)</small>';
|
||||||
|
$class = 'border-status-' . (
|
||||||
|
$isService ?
|
||||||
|
strtolower($this->util()->getServiceStateName($event->state)) :
|
||||||
|
strtolower($this->util()->getHostStateName($event->state))
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case 'soft_state':
|
||||||
|
$icon = '{{SOFTSTATE_ICON}}';
|
||||||
|
$title = 'Soft State';
|
||||||
|
$msg = $event->output . '<br /><small>Attempt ' . $event->attempt . '/' . $event->max_attempts . ' (Soft)</small>';
|
||||||
|
$class = 'border-status-' . (
|
||||||
|
$isService ?
|
||||||
|
strtolower($this->util()->getServiceStateName($event->state)) :
|
||||||
|
strtolower($this->util()->getHostStateName($event->state))
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case 'dt_start':
|
||||||
|
$icon = 'downtime-start';
|
||||||
|
$title = 'Downtime Start';
|
||||||
|
$msg = $event->output;
|
||||||
|
break;
|
||||||
|
case 'dt_end':
|
||||||
|
$icon = 'downtime-end';
|
||||||
|
$title = 'Downtime End';
|
||||||
|
$msg = $event->output;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<div<?php if (!empty($class)): ?> class="<?= $class ?>"<?php endif; ?>>
|
||||||
|
<i title="<?= $title ?>" class="icinga-icon-<?= $icon ?>"></i>
|
||||||
|
<?php if (!empty($msg)) { echo $msg; } ?>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<? endforeach; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<?= $this->paginationControl($history, null, null, array('preserve' => $this->preserve)); ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
@ -90,13 +90,13 @@
|
|||||||
'host' => $object->host_name,
|
'host' => $object->host_name,
|
||||||
'service' => $object->service_description
|
'service' => $object->service_description
|
||||||
)); ?>">
|
)); ?>">
|
||||||
All events for <?= $event->service_description ?>
|
All events for <?= $object->service_description ?>
|
||||||
</a>
|
</a>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<a href="<?= $this->href('monitoring/list/eventhistory', array(
|
<a href="<?= $this->href('monitoring/list/eventhistory', array(
|
||||||
'host' => $object->host_name
|
'host' => $object->host_name
|
||||||
)); ?>">
|
)); ?>">
|
||||||
All events for <?= $event->host_name ?>
|
All events for <?= $object->host_name ?>
|
||||||
</a>
|
</a>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
@ -30,9 +30,7 @@ class EventHistoryQuery extends AbstractQuery
|
|||||||
'max_attempts' => 'eh.max_attempts',
|
'max_attempts' => 'eh.max_attempts',
|
||||||
'output' => 'eh.output', // we do not want long_output
|
'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',
|
//'problems' => 'CASE WHEN eh.state = 0 OR eh.state IS NULL THEN 0 ELSE 1 END',
|
||||||
'type' => 'eh.type',
|
'type' => 'eh.type'
|
||||||
'service_host_name' => 'eho.name1 COLLATE latin1_general_ci',
|
|
||||||
'service_description' => 'eho.name2 COLLATE latin1_general_ci'
|
|
||||||
),
|
),
|
||||||
'hostgroups' => array(
|
'hostgroups' => array(
|
||||||
'hostgroup' => 'hgo.name1 COLLATE latin1_general_ci',
|
'hostgroup' => 'hgo.name1 COLLATE latin1_general_ci',
|
||||||
|
@ -21,46 +21,29 @@ class NotificationhistoryQuery extends AbstractQuery
|
|||||||
|
|
||||||
protected function joinBaseTables()
|
protected function joinBaseTables()
|
||||||
{
|
{
|
||||||
//"('[' || cndetails.contacts || '] ' || n.output)"
|
|
||||||
// This is one of the db-specific workarounds that could be abstracted
|
|
||||||
// in a better way:
|
|
||||||
switch ($this->ds->getDbType()) {
|
switch ($this->ds->getDbType()) {
|
||||||
case 'mysql':
|
case 'mysql':
|
||||||
$concat_contacts = "GROUP_CONCAT(c.alias ORDER BY c.alias SEPARATOR ', ')";
|
$concattedContacts = "GROUP_CONCAT(c.alias ORDER BY c.alias SEPARATOR ', ')";
|
||||||
break;
|
break;
|
||||||
case 'pgsql':
|
case 'pgsql':
|
||||||
// TODO: Find a way to "ORDER" these:
|
// TODO: Find a way to order the contact alias list:
|
||||||
$concat_contacts = "ARRAY_TO_STRING(ARRAY_AGG(c.alias), ', ')";
|
$concattedContacts = "ARRAY_TO_STRING(ARRAY_AGG(c.alias), ', ')";
|
||||||
break;
|
break;
|
||||||
case 'oracle':
|
case 'oracle':
|
||||||
// TODO: This is only valid for Oracle >= 11g Release 2.
|
// TODO: This is only valid for Oracle >= 11g Release 2
|
||||||
$concat_contacts = "LISTAGG(c.alias, ', ') WITHIN GROUP (ORDER BY c.alias)";
|
$concattedContacts = "LISTAGG(c.alias, ', ') WITHIN GROUP (ORDER BY c.alias)";
|
||||||
// Alternatives:
|
// Alternatives:
|
||||||
//
|
//
|
||||||
// RTRIM(XMLAGG(XMLELEMENT(e, column_name, ',').EXTRACT('//text()')),
|
// RTRIM(XMLAGG(XMLELEMENT(e, column_name, ',').EXTRACT('//text()')),
|
||||||
//
|
//
|
||||||
// not supported and not documented but works since 10.1,
|
// not supported and not documented but works since 10.1,
|
||||||
// however it is NOT always present;
|
// however it is NOT always present:
|
||||||
// WM_CONCAT(c.alias)
|
// WM_CONCAT(c.alias)
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
die('Not yet'); // TODO: Proper Exception
|
|
||||||
}
|
}
|
||||||
$this->columnMap['history']['output'] = "('[' || $concat_contacts || '] ' || n.output)";
|
|
||||||
/*
|
$this->columnMap['history']['output'] = "('[' || $concattedContacts || '] ' || n.output)";
|
||||||
$cndetails = $this->db->select()->from(
|
|
||||||
array('cn' => $this->prefix . 'contactnotifications'),
|
|
||||||
array(
|
|
||||||
'notification_id' => 'notification_id',
|
|
||||||
'cnt' => 'COUNT(*)',
|
|
||||||
'contacts' => $concat_contacts
|
|
||||||
)
|
|
||||||
)->join(
|
|
||||||
array('c' => $this->prefix . 'contacts'),
|
|
||||||
'cn.contact_object_id = c.contact_object_id',
|
|
||||||
array()
|
|
||||||
)->group('notification_id');
|
|
||||||
*/
|
|
||||||
$this->baseQuery = $this->db->select()->from(
|
$this->baseQuery = $this->db->select()->from(
|
||||||
array('n' => $this->prefix . 'notifications'),
|
array('n' => $this->prefix . 'notifications'),
|
||||||
array()
|
array()
|
||||||
@ -72,14 +55,14 @@ $this->columnMap['history']['output'] = "('[' || $concat_contacts || '] ' || n.o
|
|||||||
array('c' => $this->prefix . 'contacts'),
|
array('c' => $this->prefix . 'contacts'),
|
||||||
'cn.contact_object_id = c.contact_object_id',
|
'cn.contact_object_id = c.contact_object_id',
|
||||||
array()
|
array()
|
||||||
)->group('cn.notification_id')
|
)->group('cn.notification_id');
|
||||||
|
|
||||||
/*->join(
|
if ($this->ds->getDbType() === 'pgsql') {
|
||||||
array('cndetails' => $cndetails),
|
$this->baseQuery->group('n.object_id')
|
||||||
'cndetails.notification_id = n.notification_id',
|
->group('n.start_time')
|
||||||
array()
|
->group('n.output')
|
||||||
)*/
|
->group('n.state');
|
||||||
;
|
}
|
||||||
|
|
||||||
$this->joinedVirtualTables = array('history' => true);
|
$this->joinedVirtualTables = array('history' => true);
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ abstract class DataView
|
|||||||
public static function getTableName()
|
public static function getTableName()
|
||||||
{
|
{
|
||||||
$tableName = explode('\\', get_called_class());
|
$tableName = explode('\\', get_called_class());
|
||||||
$tableName = strtolower(end($tableName));
|
$tableName = end($tableName);
|
||||||
return $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…
x
Reference in New Issue
Block a user