monitoring/list: Introduce action servicegroup-grid

refs #1017
This commit is contained in:
Johannes Meyer 2018-05-14 15:23:01 +02:00 committed by Eric Lippmann
parent 917827a87b
commit 61103ae359
2 changed files with 250 additions and 0 deletions

View File

@ -494,6 +494,44 @@ class ListController extends Controller
$this->view->serviceGroups = $serviceGroups; $this->view->serviceGroups = $serviceGroups;
} }
/**
* List service groups
*/
public function servicegroupGridAction()
{
$this->addTitleTab(
'servicegroup-grid',
$this->translate('Service Group Grid'),
$this->translate('Show the Service Group Grid')
);
$this->setAutorefreshInterval(15);
$serviceGroups = $this->backend->select()->from('servicegroupsummary', array(
'servicegroup_alias',
'servicegroup_name',
'services_critical_handled',
'services_critical_unhandled',
'services_ok',
'services_pending',
'services_total',
'services_unknown_handled',
'services_unknown_unhandled',
'services_warning_handled',
'services_warning_unhandled'
));
$this->applyRestriction('monitoring/filter/objects', $serviceGroups);
$this->filterQuery($serviceGroups);
$this->setupSortControl(array(
'servicegroup_alias' => $this->translate('Service Group Name'),
'services_severity' => $this->translate('Severity'),
'services_total' => $this->translate('Total Services')
), $serviceGroups, ['services_severity' => 'desc']);
$this->view->serviceGroups = $serviceGroups;
}
/** /**
* List host groups * List host groups
*/ */

View File

@ -0,0 +1,212 @@
<?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\Servicegroup $serviceGroups */
if (! $serviceGroups->hasResult()): ?>
<p><?= $this->translate('No service groups found matching the filter.') ?></p>
</div>
<?php return; endif ?>
<div class="group-grid">
<?php foreach ($serviceGroups as $serviceGroup): ?>
<div class="group-grid-cell">
<?php if ($serviceGroup->services_critical_unhandled > 0): ?>
<?= $this->qlink(
$serviceGroup->services_critical_unhandled,
'monitoring/list/servicegrid',
[
'servicegroup_name' => $serviceGroup->servicegroup_name,
'service_handled' => 0,
'service_state' => 2
],
[
'class' => 'state-critical',
'title' => sprintf(
$this->translatePlural(
'List %s service that is currently in state CRITICAL in service group "%s"',
'List %s services which are currently in state CRITICAL in service group "%s"',
$serviceGroup->services_critical_unhandled
),
$serviceGroup->services_critical_unhandled,
$serviceGroup->servicegroup_alias
)
]
) ?>
<?php elseif ($serviceGroup->services_warning_unhandled > 0): ?>
<?= $this->qlink(
$serviceGroup->services_warning_unhandled,
'monitoring/list/servicegrid',
[
'servicegroup_name' => $serviceGroup->servicegroup_name,
'service_handled' => 0,
'service_state' => 1
],
[
'class' => 'state-warning',
'title' => sprintf(
$this->translatePlural(
'List %s service that is currently in state WARNING in service group "%s"',
'List %s services which are currently in state WARNING in service group "%s"',
$serviceGroup->services_warning_unhandled
),
$serviceGroup->services_warning_unhandled,
$serviceGroup->servicegroup_alias
)
]
) ?>
<?php elseif ($serviceGroup->services_unknown_unhandled > 0): ?>
<?= $this->qlink(
$serviceGroup->services_unknown_unhandled,
'monitoring/list/servicegrid',
[
'servicegroup_name' => $serviceGroup->servicegroup_name,
'service_handled' => 0,
'service_state' => 3
],
[
'class' => 'state-unknown',
'title' => sprintf(
$this->translatePlural(
'List %s service that is currently in state UNKNOWN in service group "%s"',
'List %s services which are currently in state UNKNOWN in service group "%s"',
$serviceGroup->services_unknown_unhandled
),
$serviceGroup->services_unknown_unhandled,
$serviceGroup->servicegroup_alias
)
]
) ?>
<?php elseif ($serviceGroup->services_critical_handled > 0): ?>
<?= $this->qlink(
$serviceGroup->services_critical_handled,
'monitoring/list/servicegrid',
[
'servicegroup_name' => $serviceGroup->servicegroup_name,
'service_handled' => 1,
'service_state' => 2
],
[
'class' => 'state-critical handled',
'title' => sprintf(
$this->translatePlural(
'List %s service that is currently in state CRITICAL (Acknowledged) in service group "%s"',
'List %s services which are currently in state CRITICAL (Acknowledged) in service group "%s"',
$serviceGroup->services_critical_handled
),
$serviceGroup->services_critical_handled,
$serviceGroup->servicegroup_alias
)
]
) ?>
<?php elseif ($serviceGroup->services_warning_handled > 0): ?>
<?= $this->qlink(
$serviceGroup->services_warning_handled,
'monitoring/list/servicegrid',
[
'servicegroup_name' => $serviceGroup->servicegroup_name,
'service_handled' => 1,
'service_state' => 1
],
[
'class' => 'state-warning handled',
'title' => sprintf(
$this->translatePlural(
'List %s service that is currently in state WARNING (Acknowledged) in service group "%s"',
'List %s services which are currently in state WARNING (Acknowledged) in service group "%s"',
$serviceGroup->services_warning_handled
),
$serviceGroup->services_warning_handled,
$serviceGroup->servicegroup_alias
)
]
) ?>
<?php elseif ($serviceGroup->services_unknown_handled > 0): ?>
<?= $this->qlink(
$serviceGroup->services_unknown_handled,
'monitoring/list/servicegrid',
[
'servicegroup_name' => $serviceGroup->servicegroup_name,
'service_handled' => 1,
'service_state' => 3
],
[
'class' => 'state-unknown handled',
'title' => sprintf(
$this->translatePlural(
'List %s service that is currently in state UNKNOWN (Acknowledged) in service group "%s"',
'List %s services which are currently in state UNKNOWN (Acknowledged) in service group "%s"',
$serviceGroup->services_unknown_handled
),
$serviceGroup->services_unknown_handled,
$serviceGroup->servicegroup_alias
)
]
) ?>
<?php elseif ($serviceGroup->services_pending > 0): ?>
<?= $this->qlink(
$serviceGroup->services_pending,
'monitoring/list/servicegrid',
[
'servicegroup_name' => $serviceGroup->servicegroup_name,
'service_state' => 99
],
[
'class' => 'state-pending',
'title' => sprintf(
$this->translatePlural(
'List %s service that is currenlty in state PENDING in service group "%s"',
'List %s services which are currently in state PENDING in service group "%s"',
$serviceGroup->services_pending
),
$serviceGroup->services_pending,
$serviceGroup->servicegroup_alias
)
]
) ?>
<?php elseif ($serviceGroup->services_ok > 0): ?>
<?= $this->qlink(
$serviceGroup->services_ok,
'monitoring/list/servicegrid',
[
'servicegroup_name' => $serviceGroup->servicegroup_name,
'service_state' => 0
],
[
'class' => 'state-ok',
'title' => sprintf(
$this->translatePlural(
'List %s service that is currently in state OK in service group "%s"',
'List %s services which are currently in state OK in service group "%s"',
$serviceGroup->services_ok
),
$serviceGroup->services_ok,
$serviceGroup->servicegroup_alias
)
]
) ?>
<?php else: ?>
<div class="state-none">
0
</div>
<?php endif ?>
<?= $this->qlink(
$serviceGroup->servicegroup_alias,
'monitoring/list/servicegrid',
['servicegroup_name' => $serviceGroup->servicegroup_name],
[
'title' => sprintf(
$this->translate('List all services in the group "%s"'),
$serviceGroup->servicegroup_alias
)
]
) ?>
</div>
<?php endforeach ?>
</div>
</div>