icingaweb2/modules/monitoring/application/views/scripts/show/history.phtml

148 lines
3.8 KiB
PHTML
Raw Normal View History

2014-02-18 20:17:33 +01:00
<?php
use Icinga\Module\Monitoring\Object\Service;
if ($object instanceof Service) {
$title = $object->service_description;
$params = array(
'host' => $object->host_name,
'service' => $object->service_description
);
} else {
$title = $object->host_name;
$params = array('host' => $object->host_name);
}
2014-02-18 20:17:33 +01:00
// TODO: Remove this once we have better helpers
$states = array(
'service' => array(
'ok',
'warning',
'critical',
'unknown',
99 => 'pending',
),
'host' => array(
'up',
'down',
'unreachable',
99 => 'pending',
)
);
?><div class="controls">
<?= $this->render('show/components/header.phtml') ?>
<h1><?= $this->translate("This object's event history") ?></h1>
<?= $this->paginationControl($this->history, null, null, array('preserve' => $this->preserve)); ?>
2014-02-18 20:17:33 +01:00
</div>
<?php if($this->history->count() === 0): ?>
2014-05-28 00:16:45 +02:00
<?= $this->translate('No History Available For This Object') ?>
2014-02-18 20:17:33 +01:00
</div>
<?php return; endif ?>
<div class="content">
<table data-base-target="_next" class="action objecthistory">
2014-02-18 20:17:33 +01:00
<tbody>
<?php foreach ($this->history as $event):
2014-02-18 20:17:33 +01:00
if (array_key_exists($event->state, $states[$event->object_type])) {
$state_class = $states[$event->object_type][$event->state];
} else {
$state_class = 'invalid';
}
2014-02-18 20:17:33 +01:00
switch ($event->type) {
case 'notify':
$icon = 'notification';
$title = $this->translate('Notification');
$state = $this->translate('ACK');
2014-02-18 20:17:33 +01:00
break;
case 'comment':
$icon = 'comment';
$title = $this->translate('Comment');
break;
case 'comment_deleted':
$icon = 'remove';
$title = $this->translate('Comment deleted');
2014-02-18 20:17:33 +01:00
break;
case 'ack':
$icon = 'acknowledgement';
$title = $this->translate('Acknowledge');
break;
case 'ack_deleted':
$icon = 'remove';
$title = $this->translate('Ack removed');
2014-02-18 20:17:33 +01:00
break;
case 'dt_comment':
$icon = 'in_downtime';
$title = $this->translate('In Downtime');
break;
case 'dt_comment_deleted':
$icon = 'remove';
$title = $this->translate('Downtime removed');
2014-02-18 20:17:33 +01:00
break;
case 'flapping':
$icon = 'flapping';
$title = $this->translate('Flapping');
break;
case 'flapping_deleted':
$icon = 'remove';
$title = $this->translate('Flapping stopped');
2014-02-18 20:17:33 +01:00
break;
case 'hard_state':
$icon = 'submit';
$title = $this->translate('Hard State');
2014-02-18 20:17:33 +01:00
break;
case 'soft_state':
$icon = 'softstate';
$title = $this->translate('Soft State');
$state_class .= ' handled';
2014-02-18 20:17:33 +01:00
break;
case 'dt_start':
$icon = 'downtime_start';
$title = $this->translate('Downtime Start');
2014-02-18 20:17:33 +01:00
break;
case 'dt_end':
$icon = 'downtime_end';
$title = $this->translate('Downtime End');
2014-02-18 20:17:33 +01:00
break;
}
?>
<tr class="state <?= $state_class ?>">
<td class="state"><?= $this->timeSince($event->timestamp) ?><br /><strong><?= $this->escape($title) ?></strong></td>
<td>
<?php
$output = $this->tickets ? preg_replace_callback(
$this->tickets->getPattern(),
array($this->tickets, 'createLink'),
$this->escape($event->output)
) : $this->escape($event->output);
echo $this->icon($icon . '.png', $title) . ' ';
2014-02-18 20:17:33 +01:00
if ($object instanceof Host): ?>
<?= $this->escape($event->service_description) ?>
<?php elseif ($object instanceof Service): ?>
2014-02-18 20:17:33 +01:00
<?php else: ?>
<?= $this->escape($event->service_description) ?> on <?= $this->escape($event->host_name) ?>
2014-02-18 20:17:33 +01:00
<?php endif;
2014-02-18 20:17:33 +01:00
if ($event->attempt !== null) {
printf('[ %d/%d ] ', $event->attempt, $event->max_attempts);
}
echo $output;
2014-02-18 20:17:33 +01:00
?>
</td>
</tr>
<? endforeach; ?>
</tbody>
</table>
</div>