monitoring: Use StateBadges widget for host states in the hostgroups overview

refs #5543
This commit is contained in:
Eric Lippmann 2015-09-27 12:23:22 +02:00
parent fb79caab48
commit 8ead6c73df
1 changed files with 68 additions and 137 deletions

View File

@ -1,5 +1,6 @@
<?php <?php
use Icinga\Module\Monitoring\Object\Host; use Icinga\Module\Monitoring\Object\Host;
use Icinga\Module\Monitoring\Web\Widget\StateBadges;
if (! $this->compact): ?> if (! $this->compact): ?>
<div class="controls"> <div class="controls">
@ -48,35 +49,24 @@ if (! $this->compact): ?>
) ?> ) ?>
</td> </td>
<td> <td>
<?php if ($hostgroup->hosts_up): ?> <?php
<span class="state ok"> $stateBadges = new StateBadges();
<?= $this->qlink( $stateBadges
$hostgroup->hosts_up, ->setUrl('monitoring/list/hosts')
'monitoring/list/hosts', ->add(
StateBadges::STATE_OK,
array( array(
'host_state' => 0, 'host_state' => 0,
'hostgroup_name' => $hostgroup->hostgroup_name, 'hostgroup_name' => $hostgroup->hostgroup_name,
'sort' => 'host_severity' 'sort' => 'host_severity'
), ),
array( $hostgroup->hosts_up,
'title' => sprintf(
$this->translatePlural(
'List %u host that is currently in state UP in the host group "%s"', 'List %u host that is currently in state UP in the host group "%s"',
'List %u hosts which are currently in state UP in the host group "%s"', 'List %u hosts which are currently in state UP in the host group "%s"',
$hostgroup->hosts_up array($hostgroup->hosts_up, $hostgroup->hostgroup_alias)
),
$hostgroup->hosts_up,
$hostgroup->hostgroup_alias
) )
) ->add(
) ?> StateBadges::STATE_CRITICAL,
</span>
<?php endif ?>
<?php if ($hostgroup->hosts_down_unhandled): ?>
<span class="state critical">
<?= $this->qlink(
$hostgroup->hosts_down_unhandled,
'monitoring/list/hosts',
array( array(
'host_state' => 1, 'host_state' => 1,
'host_acknowledged' => 0, 'host_acknowledged' => 0,
@ -84,52 +74,26 @@ if (! $this->compact): ?>
'hostgroup_name' => $hostgroup->hostgroup_name, 'hostgroup_name' => $hostgroup->hostgroup_name,
'sort' => 'host_severity' 'sort' => 'host_severity'
), ),
array( $hostgroup->hosts_down_unhandled,
'title' => sprintf(
$this->translatePlural(
'List %u host that is currently in state DOWN in the host group "%s"', 'List %u host that is currently in state DOWN in the host group "%s"',
'List %u hosts which are currently in state DOWN in the host group "%s"', 'List %u hosts which are currently in state DOWN in the host group "%s"',
$hostgroup->hosts_down_unhandled array($hostgroup->hosts_down_unhandled, $hostgroup->hostgroup_alias)
),
$hostgroup->hosts_down_unhandled,
$hostgroup->hostgroup_alias
) )
) ->add(
) ?> StateBadges::STATE_CRITICAL_HANDLED,
<?php endif ?>
<?php if ($hostgroup->hosts_down_handled): ?>
<span class="state critical handled">
<?= $this->qlink(
$hostgroup->hosts_down_handled,
'monitoring/list/hosts',
array( array(
'host_state' => 1, 'host_state' => 1,
'host_handled' => 1, 'host_handled' => 1,
'hostgroup_name' => $hostgroup->hostgroup_name, 'hostgroup_name' => $hostgroup->hostgroup_name,
'sort' => 'host_severity' 'sort' => 'host_severity'
), ),
array( $hostgroup->hosts_down_handled,
'title' => sprintf(
$this->translatePlural(
'List %u host that is currently in state DOWN (Acknowledged) in the host group "%s"', 'List %u host that is currently in state DOWN (Acknowledged) in the host group "%s"',
'List %u hosts which are currently in state DOWN (Acknowledged) in the host group "%s"', 'List %u hosts which are currently in state DOWN (Acknowledged) in the host group "%s"',
$hostgroup->hosts_down_handled array($hostgroup->hosts_down_handled, $hostgroup->hostgroup_alias)
),
$hostgroup->hosts_down_handled,
$hostgroup->hostgroup_alias
) )
) ->add(
) ?> StateBadges::STATE_UNREACHABLE,
</span>
<?php endif ?>
<?php if ($hostgroup->hosts_down_unhandled): ?>
</span>
<?php endif ?>
<?php if ($hostgroup->hosts_unreachable_unhandled): ?>
<span class="state unknown">
<?= $this->qlink(
$hostgroup->hosts_unreachable_unhandled,
'monitoring/list/hosts',
array( array(
'host_state' => 2, 'host_state' => 2,
'host_acknowledged' => 0, 'host_acknowledged' => 0,
@ -137,71 +101,38 @@ if (! $this->compact): ?>
'hostgroup_name' => $hostgroup->hostgroup_name, 'hostgroup_name' => $hostgroup->hostgroup_name,
'sort' => 'host_severity' 'sort' => 'host_severity'
), ),
array( $hostgroup->hosts_unreachable_unhandled,
'title' => sprintf(
$this->translatePlural(
'List %u host that is currently in state UNREACHABLE in the host group "%s"', 'List %u host that is currently in state UNREACHABLE in the host group "%s"',
'List %u hosts which are currently in state UNREACHABLE in the host group "%s"', 'List %u hosts which are currently in state UNREACHABLE in the host group "%s"',
$hostgroup->hosts_unreachable_unhandled array($hostgroup->hosts_unreachable_unhandled, $hostgroup->hostgroup_alias)
),
$hostgroup->hosts_unreachable_unhandled,
$hostgroup->hostgroup_alias
) )
) ->add(
) ?> StateBadges::STATE_UNREACHABLE_HANDLED,
<?php endif ?>
<?php if ($hostgroup->hosts_unreachable_handled): ?>
<span class="state unknown handled">
<?= $this->qlink(
$hostgroup->hosts_unreachable_handled,
'monitoring/list/hosts',
array( array(
'host_state' => 2, 'host_state' => 2,
'host_handled' => 1, 'host_handled' => 1,
'hostgroup_name' => $hostgroup->hostgroup_name, 'hostgroup_name' => $hostgroup->hostgroup_name,
'sort' => 'host_severity' 'sort' => 'host_severity'
), ),
array( $hostgroup->hosts_unreachable_handled,
'title' => sprintf(
$this->translatePlural(
'List %u host that is currently in state UNREACHABLE (Acknowledged) in the host group "%s"', 'List %u host that is currently in state UNREACHABLE (Acknowledged) in the host group "%s"',
'List %u hosts which are currently in state UNREACHABLE (Acknowledged) in the host group "%s"', 'List %u hosts which are currently in state UNREACHABLE (Acknowledged) in the host group "%s"',
$hostgroup->hosts_unreachable_handled array($hostgroup->hosts_unreachable_handled, $hostgroup->hostgroup_alias)
),
$hostgroup->hosts_unreachable_handled,
$hostgroup->hostgroup_alias
) )
) ->add(
) ?> StateBadges::STATE_PENDING,
</span>
<?php endif ?>
<?php if ($hostgroup->hosts_unreachable_unhandled): ?>
</span>
<?php endif ?>
<?php if ($hostgroup->hosts_pending): ?>
<span class="state pending">
<?= $this->qlink(
$hostgroup->hosts_pending,
'monitoring/list/hosts',
array( array(
'host_state' => 99, 'host_state' => 99,
'hostgroup_name' => $hostgroup->hostgroup_name, 'hostgroup_name' => $hostgroup->hostgroup_name,
'sort' => 'host_severity' 'sort' => 'host_severity'
), ),
array( $hostgroup->hosts_pending,
'title' => sprintf(
$this->translatePlural(
'List %u host that is currently in state PENDING in the host group "%s"', 'List %u host that is currently in state PENDING in the host group "%s"',
'List %u hosts which are currently in state PENDING in the host group "%s"', 'List %u hosts which are currently in state PENDING in the host group "%s"',
$hostgroup->hosts_pending array($hostgroup->hosts_pending, $hostgroup->hostgroup_alias)
), );
$hostgroup->hosts_pending, echo $stateBadges->render();
$hostgroup->hostgroup_alias ?>
)
)
) ?>
</span>
<?php endif ?>
</td> </td>
<td class="total"> <td class="total">
<?= $this->qlink( <?= $this->qlink(