monitoring/list: Introduce action hostgroup-grid

refs #1017
This commit is contained in:
Johannes Meyer 2018-05-14 15:25:54 +02:00 committed by Eric Lippmann
parent c633c86db7
commit 917827a87b
3 changed files with 240 additions and 0 deletions

View File

@ -542,6 +542,43 @@ class ListController extends Controller
$this->view->hostGroups = $hostGroups; $this->view->hostGroups = $hostGroups;
} }
/**
* List host groups
*/
public function hostgroupGridAction()
{
$this->addTitleTab(
'hostgroup-grid',
$this->translate('Host Group Grid'),
$this->translate('Show the Host Group Grid')
);
$this->setAutorefreshInterval(15);
$hostGroups = $this->backend->select()->from('hostgroupsummary', [
'hostgroup_alias',
'hostgroup_name',
'hosts_down_handled',
'hosts_down_unhandled',
'hosts_pending',
'hosts_total',
'hosts_unreachable_handled',
'hosts_unreachable_unhandled',
'hosts_up'
]);
$this->applyRestriction('monitoring/filter/objects', $hostGroups);
$this->filterQuery($hostGroups);
$this->setupSortControl([
'hosts_severity' => $this->translate('Severity'),
'hostgroup_alias' => $this->translate('Host Group Name'),
'hosts_total' => $this->translate('Total Hosts'),
'services_total' => $this->translate('Total Services')
], $hostGroups, ['hosts_severity' => 'desc']);
$this->view->hostGroups = $hostGroups;
}
public function eventhistoryAction() public function eventhistoryAction()
{ {
$this->addTitleTab( $this->addTitleTab(

View File

@ -0,0 +1,168 @@
<?php if (! $this->compact): ?>
<div class="controls">
<?= $this->tabs ?>
<div class="sort-controls-container">
<?= $this->sortBox ?>
</div>
<?= $this->filterEditor ?>
</div>
<?php endif ?>
<div class="content" data-base-target="_next">
<?php /** @var \Icinga\Module\Monitoring\DataView\Hostgroup $hostGroups */
if (! $hostGroups->hasResult()): ?>
<p><?= $this->translate('No host groups found matching the filter.') ?></p>
</div>
<?php return; endif ?>
<div class="group-grid">
<?php foreach ($hostGroups as $hostGroup): ?>
<div class="group-grid-cell">
<?php if ($hostGroup->hosts_down_unhandled > 0): ?>
<?= $this->qlink(
$hostGroup->hosts_down_unhandled,
'monitoring/list/hosts',
[
'hostgroup_name' => $hostGroup->hostgroup_name,
'host_handled' => 0,
'host_state' => 1
],
[
'class' => 'state-down',
'title' => sprintf(
$this->translatePlural(
'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"',
$hostGroup->hosts_down_unhandled
),
$hostGroup->hosts_down_unhandled,
$hostGroup->hostgroup_alias
)
]
) ?>
<?php elseif ($hostGroup->hosts_unreachable_unhandled > 0): ?>
<?= $this->qlink(
$hostGroup->hosts_unreachable_unhandled,
'monitoring/list/hosts',
[
'hostgroup_name' => $hostGroup->hostgroup_name,
'host_handled' => 0,
'host_state' => 2
],
[
'class' => 'state-unreachable',
'title' => sprintf(
$this->translatePlural(
'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"',
$hostGroup->hosts_unreachable_unhandled
),
$hostGroup->hosts_unreachable_unhandled,
$hostGroup->hostgroup_alias
)
]
) ?>
<?php elseif ($hostGroup->hosts_down_handled > 0): ?>
<?= $this->qlink(
$hostGroup->hosts_down_handled,
'monitoring/list/hosts',
[
'hostgroup_name' => $hostGroup->hostgroup_name,
'host_handled' => 1,
'host_state' => 1
],
[
'class' => 'state-down handled',
'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->hostgroup_alias
)
]
) ?>
<?php elseif ($hostGroup->hosts_unreachable_handled > 0): ?>
<?= $this->qlink(
$hostGroup->hosts_unreachable_handled,
'monitoring/list/hosts',
[
'hostgroup_name' => $hostGroup->hostgroup_name,
'host_handled' => 0,
'host_state' => 2
],
[
'class' => 'state-unreachable handled',
'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->hostgroup_alias
)
]
) ?>
<?php elseif ($hostGroup->hosts_pending > 0): ?>
<?= $this->qlink(
$hostGroup->hosts_pending,
'monitoring/list/hosts',
[
'hostgroup_name' => $hostGroup->hostgroup_name,
'host_state' => 99
],
[
'class' => 'state-pending',
'title' => sprintf(
$this->translatePlural(
'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"',
$hostGroup->hosts_pending
),
$hostGroup->hosts_pending,
$hostGroup->hostgroup_alias
)
]
) ?>
<?php elseif ($hostGroup->hosts_up > 0): ?>
<?= $this->qlink(
$hostGroup->hosts_up,
'monitoring/list/hosts',
[
'hostgroup_name' => $hostGroup->hostgroup_name,
'host_state' => 0
],
[
'class' => 'state-up',
'title' => sprintf(
$this->translatePlural(
'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"',
$hostGroup->hosts_up
),
$hostGroup->hosts_up,
$hostGroup->hostgroup_alias
)
]
) ?>
<?php else: ?>
<div class="state-none">
0
</div>
<?php endif ?>
<?= $this->qlink(
$hostGroup->hostgroup_alias,
'monitoring/list/hosts',
['hostgroup_name' => $hostGroup->hostgroup_name],
[
'title' => sprintf(
$this->translate('List all hosts in the group "%s"'),
$hostGroup->hostgroup_alias
)
]
) ?>
</div>
<?php endforeach ?>
</div>
</div>

View File

@ -41,6 +41,41 @@
} }
} }
// Hostgroup- and servicegroup-grid styles
.group-grid {
display: grid;
grid-gap: 1em 3em;
grid-template-columns: repeat(auto-fit, 14em);
.group-grid-cell > a:last-child {
display: inline-block;
max-width: 10em;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
text-align: center;
vertical-align: middle;
}
.group-grid-cell > a:first-child,
.group-grid-cell > div.state-none {
.bg-stateful();
.rounded-corners();
display: inline-block;
margin-right: 1em;
padding: .5em;
height: 2.5em;
width: 2.5em;
text-align: center;
vertical-align: middle;
color: white;
}
.group-grid-cell > div.state-none {
background-color: @gray-light;
}
}
// Styles for the icon displayed if a check result is late // Styles for the icon displayed if a check result is late
.check-result-late { .check-result-late {
&:before { &:before {