monitoring: Use state badge widget for service states in the host group overview

refs #5543
This commit is contained in:
Eric Lippmann 2015-09-27 14:18:41 +02:00
parent d59b09ca48
commit a3d3ba229d

View File

@ -146,35 +146,24 @@ if (! $this->compact): ?>
) ?> ) ?>
</td> </td>
<td> <td>
<?php if ($hostgroup->services_ok): ?> <?php
<span class="state ok"> $stateBadges = new StateBadges();
<?= $this->qlink( $stateBadges
$hostgroup->services_ok, ->setUrl('monitoring/list/services')
'monitoring/list/services', ->add(
StateBadges::STATE_OK,
array( array(
'service_state' => 0, 'service_state' => 0,
'hostgroup_name' => $hostgroup->hostgroup_name, 'hostgroup_name' => $hostgroup->hostgroup_name,
'sort' => 'service_severity' 'sort' => 'service_severity'
), ),
array( $hostgroup->services_ok,
'title' => sprintf(
$this->translatePlural(
'List %u service that is currently in state OK on hosts in the host group "%s"', 'List %u service that is currently in state OK on hosts in the host group "%s"',
'List %u services which are currently in state OK on hosts in the host group "%s"', 'List %u services which are currently in state OK on hosts in the host group "%s"',
$hostgroup->services_ok array($hostgroup->services_ok, $hostgroup->hostgroup_alias)
),
$hostgroup->services_ok,
$hostgroup->hostgroup_alias
) )
) ->add(
) ?> StateBadges::STATE_CRITICAL,
</span>
<?php endif ?>
<?php if ($hostgroup->services_critical_unhandled): ?>
<span class="state critical">
<?= $this->qlink(
$hostgroup->services_critical_unhandled,
'monitoring/list/services',
array( array(
'service_state' => 2, 'service_state' => 2,
'service_acknowledged' => 0, 'service_acknowledged' => 0,
@ -183,52 +172,26 @@ if (! $this->compact): ?>
'hostgroup_name' => $hostgroup->hostgroup_name, 'hostgroup_name' => $hostgroup->hostgroup_name,
'sort' => 'service_severity' 'sort' => 'service_severity'
), ),
array( $hostgroup->services_critical_unhandled,
'title' => sprintf(
$this->translatePlural(
'List %u service that is currently in state CRITICAL on hosts in the host group "%s"', 'List %u service that is currently in state CRITICAL on hosts in the host group "%s"',
'List %u services which are currently in state CRITICAL on hosts in the host group "%s"', 'List %u services which are currently in state CRITICAL on hosts in the host group "%s"',
$hostgroup->services_critical_unhandled array($hostgroup->services_critical_unhandled, $hostgroup->hostgroup_alias)
),
$hostgroup->services_critical_unhandled,
$hostgroup->hostgroup_alias
) )
) ->add(
) ?> StateBadges::STATE_CRITICAL_HANDLED,
<?php endif ?>
<?php if ($hostgroup->services_critical_handled): ?>
<span class="state critical handled">
<?= $this->qlink(
$hostgroup->services_critical_handled,
'monitoring/list/services',
array( array(
'service_state' => 2, 'service_state' => 2,
'service_handled' => 1, 'service_handled' => 1,
'hostgroup_name' => $hostgroup->hostgroup_name, 'hostgroup_name' => $hostgroup->hostgroup_name,
'sort' => 'service_severity' 'sort' => 'service_severity'
), ),
array( $hostgroup->services_critical_handled,
'title' => sprintf(
$this->translatePlural(
'List %u service that is currently in state CRITICAL (Acknowledged) on hosts in the host group "%s"', 'List %u service that is currently in state CRITICAL (Acknowledged) on hosts in the host group "%s"',
'List %u services which are currently in state CRITICAL (Acknowledged) on hosts in the host group "%s"', 'List %u services which are currently in state CRITICAL (Acknowledged) on hosts in the host group "%s"',
$hostgroup->services_critical_handled array($hostgroup->services_critical_unhandled, $hostgroup->hostgroup_alias)
),
$hostgroup->services_critical_handled,
$hostgroup->hostgroup_alias
) )
) ->add(
) ?> StateBadges::STATE_UNKNOWN,
</span>
<?php endif ?>
<?php if ($hostgroup->services_critical_unhandled): ?>
</span>
<?php endif ?>
<?php if ($hostgroup->services_unknown_unhandled): ?>
<span class="state unknown">
<?= $this->qlink(
$hostgroup->services_unknown_unhandled,
'monitoring/list/services',
array( array(
'service_state' => 3, 'service_state' => 3,
'service_acknowledged' => 0, 'service_acknowledged' => 0,
@ -237,52 +200,27 @@ if (! $this->compact): ?>
'hostgroup_name' => $hostgroup->hostgroup_name, 'hostgroup_name' => $hostgroup->hostgroup_name,
'sort' => 'service_severity' 'sort' => 'service_severity'
), ),
array( $hostgroup->services_unknown_unhandled,
'title' => sprintf(
$this->translatePlural(
'List %u service that is currently in state UNKNOWN on hosts in the host group "%s"', 'List %u service that is currently in state UNKNOWN on hosts in the host group "%s"',
'List %u services which are currently in state UNKNOWN on hosts in the host group "%s"', 'List %u services which are currently in state UNKNOWN on hosts in the host group "%s"',
$hostgroup->services_unknown_unhandled array($hostgroup->services_unknown_unhandled, $hostgroup->hostgroup_alias)
),
$hostgroup->services_unknown_unhandled,
$hostgroup->hostgroup_alias
) )
) ->add(
) ?> StateBadges::STATE_UNKNOWN_HANDLED,
<?php endif ?>
<?php if ($hostgroup->services_unknown_handled): ?>
<span class="state unknown handled">
<?= $this->qlink(
$hostgroup->services_unknown_handled,
'monitoring/list/services',
array( array(
'service_state' => 3, 'service_state' => 3,
'service_handled' => 1, 'service_handled' => 1,
'hostgroup_name' => $hostgroup->hostgroup_name, 'hostgroup_name' => $hostgroup->hostgroup_name,
'sort' => 'service_severity' 'sort' => 'service_severity'
), ),
array( $hostgroup->services_unknown_handled,
'title' => sprintf(
$this->translatePlural(
'List %u service that is currently in state UNKNOWN (Acknowledged) on hosts in the host group "%s"', 'List %u service that is currently in state UNKNOWN (Acknowledged) on hosts in the host group "%s"',
'List %u services which are currently in state UNKNOWN (Acknowledged) on hosts in the host group "%s"', 'List %u services which are currently in state UNKNOWN (Acknowledged) on hosts in the host group "%s"',
$hostgroup->services_unknown_handled array($hostgroup->services_unknown_handled, $hostgroup->hostgroup_alias)
),
$hostgroup->services_unknown_handled,
$hostgroup->hostgroup_alias
) )
) ->add(
) ?> StateBadges::STATE_WARNING,
</span>
<?php endif ?>
<?php if ($hostgroup->services_unknown_unhandled): ?>
</span>
<?php endif ?>
<?php if ($hostgroup->services_warning_unhandled): ?>
<span class="state warning">
<?= $this->qlink(
$hostgroup->services_warning_unhandled,
'monitoring/list/services',
array( array(
'service_state' => 1, 'service_state' => 1,
'service_acknowledged' => 0, 'service_acknowledged' => 0,
@ -291,71 +229,38 @@ if (! $this->compact): ?>
'hostgroup_name' => $hostgroup->hostgroup_name, 'hostgroup_name' => $hostgroup->hostgroup_name,
'sort' => 'service_severity' 'sort' => 'service_severity'
), ),
array( $hostgroup->services_warning_unhandled,
'title' => sprintf(
$this->translatePlural(
'List %u service that is currently in state WARNING on hosts in the host group "%s"', 'List %u service that is currently in state WARNING on hosts in the host group "%s"',
'List %u services which are currently in state WARNING on hosts in the host group "%s"', 'List %u services which are currently in state WARNING on hosts in the host group "%s"',
$hostgroup->services_warning_unhandled array($hostgroup->services_warning_unhandled, $hostgroup->hostgroup_alias)
),
$hostgroup->services_warning_unhandled,
$hostgroup->hostgroup_alias
) )
) ->add(
) ?> StateBadges::STATE_WARNING_HANDLED,
<?php endif ?>
<?php if ($hostgroup->services_warning_handled): ?>
<span class="state warning handled">
<?= $this->qlink(
$hostgroup->services_warning_handled,
'monitoring/list/services',
array( array(
'service_state' => 1, 'service_state' => 1,
'service_handled' => 1, 'service_handled' => 1,
'hostgroup_name' => $hostgroup->hostgroup_name, 'hostgroup_name' => $hostgroup->hostgroup_name,
'sort' => 'service_severity' 'sort' => 'service_severity'
), ),
array( $hostgroup->services_warning_handled,
'title' => sprintf(
$this->translatePlural(
'List %u service that is currently in state WARNING (Acknowledged) on hosts in the host group "%s"', 'List %u service that is currently in state WARNING (Acknowledged) on hosts in the host group "%s"',
'List %u services which are currently in state WARNING (Acknowledged) on hosts in the host group "%s"', 'List %u services which are currently in state WARNING (Acknowledged) on hosts in the host group "%s"',
$hostgroup->services_warning_handled array($hostgroup->services_warning_handled, $hostgroup->hostgroup_alias)
),
$hostgroup->services_warning_handled,
$hostgroup->hostgroup_alias
) )
) ->add(
) ?> StateBadges::STATE_PENDING,
</span>
<?php endif ?>
<?php if ($hostgroup->services_warning_unhandled): ?>
</span>
<?php endif ?>
<?php if ($hostgroup->services_pending): ?>
<span class="state pending">
<?= $this->qlink(
$hostgroup->services_pending,
'monitoring/list/services',
array( array(
'service_state' => 99, 'service_state' => 99,
'hostgroup_name' => $hostgroup->hostgroup_name, 'hostgroup_name' => $hostgroup->hostgroup_name,
'sort' => 'service_severity' 'sort' => 'service_severity'
), ),
array( $hostgroup->services_pending,
'title' => sprintf(
$this->translatePlural(
'List %u service that is currently in state PENDING on hosts in the host group "%s"', 'List %u service that is currently in state PENDING on hosts in the host group "%s"',
'List %u services which are currently in state PENDING on hosts in the host group "%s"', 'List %u services which are currently in state PENDING on hosts in the host group "%s"',
$hostgroup->services_pending array($hostgroup->services_pending, $hostgroup->hostgroup_alias)
), );
$hostgroup->services_pending, echo $stateBadges->render();
$hostgroup->hostgroup_alias ?>
)
)
) ?>
</span>
<?php endif ?>
</td> </td>
</tr> </tr>
<?php endforeach ?> <?php endforeach ?>