mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 07:44:04 +02:00
Add tinystatesummary for hosts overview
This commit is contained in:
parent
11bb8dbab0
commit
038964a325
@ -156,6 +156,18 @@ class Monitoring_ListController extends Controller
|
|||||||
'host_state' => $this->translate('Hard State')
|
'host_state' => $this->translate('Hard State')
|
||||||
));
|
));
|
||||||
$this->view->hosts = $query->paginate();
|
$this->view->hosts = $query->paginate();
|
||||||
|
|
||||||
|
$this->view->stats = $this->backend->select()->from('statusSummary', array(
|
||||||
|
'hosts_total',
|
||||||
|
'hosts_up',
|
||||||
|
'hosts_down',
|
||||||
|
'hosts_down_handled',
|
||||||
|
'hosts_down_unhandled',
|
||||||
|
'hosts_unreachable',
|
||||||
|
'hosts_unreachable_handled',
|
||||||
|
'hosts_unreachable_unhandled',
|
||||||
|
'hosts_pending',
|
||||||
|
))->getQuery()->fetchRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -0,0 +1,83 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Icinga\Web\Url;
|
||||||
|
|
||||||
|
$selfUrl = 'monitoring/list/hosts';
|
||||||
|
$currentUrl = Url::fromRequest()->getRelativeUrl();
|
||||||
|
|
||||||
|
?>
|
||||||
|
<h3 class="tinystatesummary" <?= $this->compact ? ' data-base-target="col1"' : '' ?>>
|
||||||
|
<?= $this->qlink(sprintf($this->translate('%s hosts:'), $this->stats->hosts_total), $selfUrl); ?>
|
||||||
|
|
||||||
|
<?php if($this->stats->hosts_up): ?>
|
||||||
|
<span class="state ok<?= $currentUrl === Url::fromPath($selfUrl, array('host_state' => 0))->getRelativeUrl() ? ' active' : '' ?>">
|
||||||
|
<?= $this->qlink(
|
||||||
|
$this->stats->hosts_up,
|
||||||
|
$selfUrl,
|
||||||
|
array('host_state' => 0),
|
||||||
|
array('title' => $this->translate('Hosts with state UP'))
|
||||||
|
) ?>
|
||||||
|
</span>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php if($this->stats->hosts_down_unhandled): ?>
|
||||||
|
<span class="state critical<?= $currentUrl === Url::fromPath($selfUrl, array('host_state' => 1, 'host_unhandled' => 1))->getRelativeUrl() ? ' active' : '' ?>">
|
||||||
|
<?= $this->qlink(
|
||||||
|
$this->stats->hosts_down_unhandled,
|
||||||
|
$selfUrl,
|
||||||
|
array('host_state' => 1, 'host_unhandled' => 1),
|
||||||
|
array('title' => $this->translate('Unhandled hosts with state DOWN'))
|
||||||
|
) ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php if($this->stats->hosts_down_handled > 0): ?>
|
||||||
|
<span class="state handled critical<?= $currentUrl === Url::fromPath($selfUrl, array('host_state' => 1, 'host_unhandled' =>0))->getRelativeUrl() ? ' active' : '' ?>">
|
||||||
|
<?= $this->qlink(
|
||||||
|
$this->stats->hosts_down_handled,
|
||||||
|
$selfUrl,
|
||||||
|
array('host_state' => 1, 'host_unhandled' => 0),
|
||||||
|
array('title' => $this->translate('Handled hosts with state DOWN'))
|
||||||
|
) ?>
|
||||||
|
</span>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php if($this->stats->hosts_down): ?>
|
||||||
|
</span>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php if($this->stats->hosts_unreachable_unhandled): ?>
|
||||||
|
<span class="state unknown<?= $currentUrl === Url::fromPath($selfUrl, array('host_state' => 2, 'host_unhandled' => 1))->getRelativeUrl() ? ' active' : '' ?>">
|
||||||
|
<?= $this->qlink(
|
||||||
|
$this->stats->hosts_unreachable_unhandled,
|
||||||
|
$selfUrl,
|
||||||
|
array('host_state' => 2, 'host_unhandled' => 1),
|
||||||
|
array('title' => $this->translate('Unhandled hosts with state UNREACHABLE'))
|
||||||
|
) ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php if($this->stats->hosts_unreachable_handled > 0): ?>
|
||||||
|
<span class="state handled unknown<?= $currentUrl === Url::fromPath($selfUrl, array('host_state' => 2, 'host_unhandled' => 0))->getRelativeUrl() ? ' active' : '' ?>">
|
||||||
|
<?= $this->qlink(
|
||||||
|
$this->stats->hosts_unreachable_handled,
|
||||||
|
$selfUrl,
|
||||||
|
array('host_state' => 2, 'host_unhandled' => 0),
|
||||||
|
array('title' => $this->translate('Handled hosts with state UNREACHABLE'))
|
||||||
|
) ?>
|
||||||
|
</span>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php if($this->stats->hosts_unreachable): ?>
|
||||||
|
</span>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php if($this->stats->hosts_pending): ?>
|
||||||
|
<span class="state pending<?= $currentUrl === Url::fromPath($selfUrl, array('host_state' => 99))->getRelativeUrl() ? ' active' : '' ?>">
|
||||||
|
<?= $this->qlink(
|
||||||
|
$this->stats->hosts_pending,
|
||||||
|
$selfUrl,
|
||||||
|
array('host_state' => 99),
|
||||||
|
array('title' => $this->translate('Hosts with state PENDING'))
|
||||||
|
) ?>
|
||||||
|
</span>
|
||||||
|
<?php endif; ?>
|
||||||
|
</h3>
|
@ -7,6 +7,7 @@ if ($this->compact): ?>
|
|||||||
<div class="controls">
|
<div class="controls">
|
||||||
<?= $this->tabs ?>
|
<?= $this->tabs ?>
|
||||||
<div style="margin: 1em;" class="dontprint">
|
<div style="margin: 1em;" class="dontprint">
|
||||||
|
<?= $this->render('list/components/hostssummary.phtml') ?>
|
||||||
<?= $this->translate('Sort by') ?> <?= $this->sortControl->render($this) ?>
|
<?= $this->translate('Sort by') ?> <?= $this->sortControl->render($this) ?>
|
||||||
<?php if (! $this->filterEditor): ?>
|
<?php if (! $this->filterEditor): ?>
|
||||||
<?= $this->filterPreview ?>
|
<?= $this->filterPreview ?>
|
||||||
|
@ -18,6 +18,7 @@ class StatusSummaryQuery extends IdoQuery
|
|||||||
'service_description' => 'so.name2',
|
'service_description' => 'so.name2',
|
||||||
),
|
),
|
||||||
'hoststatussummary' => array(
|
'hoststatussummary' => array(
|
||||||
|
'hosts_total' => 'SUM(CASE WHEN object_type = \'host\' THEN 1 ELSE 0 END)',
|
||||||
'hosts_up' => 'SUM(CASE WHEN object_type = \'host\' AND state = 0 THEN 1 ELSE 0 END)',
|
'hosts_up' => 'SUM(CASE WHEN object_type = \'host\' AND state = 0 THEN 1 ELSE 0 END)',
|
||||||
'hosts_up_not_checked' => 'SUM(CASE WHEN object_type = \'host\' AND state = 0 AND is_active_checked = 0 AND is_passive_checked = 0 THEN 1 ELSE 0 END)',
|
'hosts_up_not_checked' => 'SUM(CASE WHEN object_type = \'host\' AND state = 0 AND is_active_checked = 0 AND is_passive_checked = 0 THEN 1 ELSE 0 END)',
|
||||||
'hosts_pending' => 'SUM(CASE WHEN object_type = \'host\' AND state = 99 THEN 1 ELSE 0 END)',
|
'hosts_pending' => 'SUM(CASE WHEN object_type = \'host\' AND state = 99 THEN 1 ELSE 0 END)',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user