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,160 +49,90 @@ 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(
array( StateBadges::STATE_OK,
'host_state' => 0, array(
'hostgroup_name' => $hostgroup->hostgroup_name, 'host_state' => 0,
'sort' => 'host_severity' 'hostgroup_name' => $hostgroup->hostgroup_name,
), 'sort' => 'host_severity'
array( ),
'title' => sprintf( $hostgroup->hosts_up,
$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> array(
<?php endif ?> 'host_state' => 1,
<?php if ($hostgroup->hosts_down_unhandled): ?> 'host_acknowledged' => 0,
<span class="state critical"> 'host_in_downtime' => 0,
<?= $this->qlink( 'hostgroup_name' => $hostgroup->hostgroup_name,
$hostgroup->hosts_down_unhandled, 'sort' => 'host_severity'
'monitoring/list/hosts', ),
array( $hostgroup->hosts_down_unhandled,
'host_state' => 1,
'host_acknowledged' => 0,
'host_in_downtime' => 0,
'hostgroup_name' => $hostgroup->hostgroup_name,
'sort' => 'host_severity'
),
array(
'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 ?> array(
<?php if ($hostgroup->hosts_down_handled): ?> 'host_state' => 1,
<span class="state critical handled"> 'host_handled' => 1,
<?= $this->qlink( 'hostgroup_name' => $hostgroup->hostgroup_name,
$hostgroup->hosts_down_handled, 'sort' => 'host_severity'
'monitoring/list/hosts',
array(
'host_state' => 1,
'host_handled' => 1,
'hostgroup_name' => $hostgroup->hostgroup_name,
'sort' => 'host_severity'
),
array(
'title' => sprintf(
$this->translatePlural(
'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"',
$hostgroup->hosts_down_handled
), ),
$hostgroup->hosts_down_handled, $hostgroup->hosts_down_handled,
$hostgroup->hostgroup_alias '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"',
array($hostgroup->hosts_down_handled, $hostgroup->hostgroup_alias)
) )
) ?> ->add(
</span> StateBadges::STATE_UNREACHABLE,
<?php endif ?> array(
<?php if ($hostgroup->hosts_down_unhandled): ?> 'host_state' => 2,
</span> 'host_acknowledged' => 0,
<?php endif ?> 'host_in_downtime' => 0,
<?php if ($hostgroup->hosts_unreachable_unhandled): ?> 'hostgroup_name' => $hostgroup->hostgroup_name,
<span class="state unknown"> 'sort' => 'host_severity'
<?= $this->qlink( ),
$hostgroup->hosts_unreachable_unhandled, $hostgroup->hosts_unreachable_unhandled,
'monitoring/list/hosts',
array(
'host_state' => 2,
'host_acknowledged' => 0,
'host_in_downtime' => 0,
'hostgroup_name' => $hostgroup->hostgroup_name,
'sort' => 'host_severity'
),
array(
'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 ?> array(
<?php if ($hostgroup->hosts_unreachable_handled): ?> 'host_state' => 2,
<span class="state unknown handled"> 'host_handled' => 1,
<?= $this->qlink( 'hostgroup_name' => $hostgroup->hostgroup_name,
$hostgroup->hosts_unreachable_handled, 'sort' => 'host_severity'
'monitoring/list/hosts',
array(
'host_state' => 2,
'host_handled' => 1,
'hostgroup_name' => $hostgroup->hostgroup_name,
'sort' => 'host_severity'
),
array(
'title' => sprintf(
$this->translatePlural(
'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"',
$hostgroup->hosts_unreachable_handled
), ),
$hostgroup->hosts_unreachable_handled, $hostgroup->hosts_unreachable_handled,
$hostgroup->hostgroup_alias '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"',
array($hostgroup->hosts_unreachable_handled, $hostgroup->hostgroup_alias)
) )
) ?> ->add(
</span> StateBadges::STATE_PENDING,
<?php endif ?> array(
<?php if ($hostgroup->hosts_unreachable_unhandled): ?> 'host_state' => 99,
</span> 'hostgroup_name' => $hostgroup->hostgroup_name,
<?php endif ?> 'sort' => 'host_severity'
<?php if ($hostgroup->hosts_pending): ?> ),
<span class="state pending"> $hostgroup->hosts_pending,
<?= $this->qlink(
$hostgroup->hosts_pending,
'monitoring/list/hosts',
array(
'host_state' => 99,
'hostgroup_name' => $hostgroup->hostgroup_name,
'sort' => 'host_severity'
),
array(
'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(