monitoring: Reduce complexity of the checkstatistics view script

This commit is contained in:
Eric Lippmann 2015-09-04 15:42:02 +02:00
parent 3401d09b59
commit e64c2947ea

View File

@ -1,17 +1,5 @@
<?php <?php
/** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */ /** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
if ($object->getType() === $object::TYPE_HOST) {
$isService = false;
$checkAttempts = $object->host_current_check_attempt . '/' . $object->host_max_check_attempts;
$stateType = (int) $object->host_state_type;
} else {
$isService = true;
$checkAttempts = $object->service_attempt;
$stateType = (int) $object->service_state_type;
}
?> ?>
<tr> <tr>
@ -21,15 +9,16 @@ if ($object->getType() === $object::TYPE_HOST) {
echo $checkNowForm; echo $checkNowForm;
} ?> } ?>
<?php if ((int) $object->state !== 99) { <?php if ((int) $object->state !== 99) {
echo $this->timeUntil($object->last_check); echo $this->timeAgo($object->last_check);
} ?> } ?>
</td> </td>
</tr> </tr>
<tr> <tr>
<th><?= $this->translate('Next check') ?></th> <th><?= $this->translate('Next check') ?></th>
<td> <td>
<?php if ($this->hasPermission('monitoring/command/schedule-check')) { <?php if ($this->hasPermission('monitoring/command/schedule-check')) {
if ($isService) { if ($object->getType() === $object::TYPE_SERVICE) {
echo $this->qlink( echo $this->qlink(
$this->translate('Reschedule'), $this->translate('Reschedule'),
'monitoring/service/reschedule-check', 'monitoring/service/reschedule-check',
@ -62,22 +51,22 @@ if ($object->getType() === $object::TYPE_HOST) {
} ?> } ?>
</td> </td>
</tr> </tr>
<tr> <tr>
<th><?= $this->translate('Check attempts') ?></th> <th><?= $this->translate('Check attempts') ?></th>
<?php if ($stateType === 0): ?> <td>
<td><?= $checkAttempts ?> (<?= $this->translate('soft state') ?>)</td> <?= $object->attempt ?>
<?php else: ?> (<?= (int) $object->state_type === 0 ? $this->translate('soft state') : $this->translate('hard state') ?>)
<td><?= $checkAttempts ?> (<?= $this->translate('hard state') ?>)</td> </td>
<?php endif; ?>
</tr> </tr>
<?php if ($object->check_execution_time): ?> <?php if ($object->check_execution_time): ?>
<tr> <tr>
<th><?= $this->translate('Check execution time') ?></th> <th><?= $this->translate('Check execution time') ?></th>
<td><?= $object->check_execution_time === null <td><?= round((float) $object->check_execution_time, 3) ?>s</td>
? '-' : round((float) $object->check_execution_time, 3)
?>s</td>
</tr> </tr>
<?php endif ?> <?php endif ?>
<?php if ($object->check_latency): ?> <?php if ($object->check_latency): ?>
<tr> <tr>
<th><?= $this->translate('Check latency') ?></th> <th><?= $this->translate('Check latency') ?></th>