parent
ff1ed128ef
commit
df864d2738
|
@ -1,94 +0,0 @@
|
||||||
<?php
|
|
||||||
// @codingStandardsIgnoreStart
|
|
||||||
// {{{ICINGA_LICENSE_HEADER}}}
|
|
||||||
/**
|
|
||||||
* This file is part of Icinga 2 Web.
|
|
||||||
*
|
|
||||||
* Icinga 2 Web - Head for multiple monitoring backends.
|
|
||||||
* Copyright (C) 2013 Icinga Development Team
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*
|
|
||||||
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
|
||||||
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
|
||||||
* @author Icinga Development Team <info@icinga.org>
|
|
||||||
*/
|
|
||||||
// {{{ICINGA_LICENSE_HEADER}}}
|
|
||||||
use Icinga\Web\Controller\ModuleActionController;
|
|
||||||
use Icinga\Backend;
|
|
||||||
|
|
||||||
class Monitoring_SummaryController extends ModuleActionController
|
|
||||||
{
|
|
||||||
protected $backend;
|
|
||||||
protected $host;
|
|
||||||
protected $service;
|
|
||||||
|
|
||||||
public function init()
|
|
||||||
{
|
|
||||||
$this->backend = Backend::getInstance($this->_getParam('backend'));
|
|
||||||
$this->view->tabs = $this->getTabs();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function createTabs()
|
|
||||||
{
|
|
||||||
$tabs = $this->getTabs();
|
|
||||||
$tabs->add('hostgroup', array(
|
|
||||||
'title' => 'Hostgroups',
|
|
||||||
'url' => 'monitoring/summary/group',
|
|
||||||
'urlParams' => array('by' => 'hostgroup'),
|
|
||||||
));
|
|
||||||
$tabs->add('servicegroup', array(
|
|
||||||
'title' => 'Servicegroups',
|
|
||||||
'url' => 'monitoring/summary/group',
|
|
||||||
'urlParams' => array('by' => 'servicegroup'),
|
|
||||||
));
|
|
||||||
$tabs->activate($this->_getParam('by', 'hostgroup'));
|
|
||||||
return $tabs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function historyAction()
|
|
||||||
{
|
|
||||||
$this->_helper->viewRenderer('history');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function groupAction()
|
|
||||||
{
|
|
||||||
if ($this->_getParam('by') === 'servicegroup') {
|
|
||||||
$view = 'servicegroupsummary';
|
|
||||||
} else {
|
|
||||||
$view = 'hostgroupsummary';
|
|
||||||
}
|
|
||||||
if (! $this->backend->hasView($view)) {
|
|
||||||
$this->view->backend = $this->backend;
|
|
||||||
$this->view->view_name = $view;
|
|
||||||
$this->_helper->viewRenderer('backend-is-missing');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->view->preserve = array(
|
|
||||||
'problems' => $this->_getParam('problems') ? 'true' : 'false',
|
|
||||||
'search' => $this->_getParam('search')
|
|
||||||
);
|
|
||||||
$query = $this->backend->select()->from($view);
|
|
||||||
$query->where('problems', $this->_getParam('problems') ? 'true' : 'false');
|
|
||||||
//$query->where('ss.current_state > 0');
|
|
||||||
$query->where('search', $this->_getParam('search'));
|
|
||||||
|
|
||||||
// echo '<pre>' . $query->dump() . '</pre>'; exit;
|
|
||||||
$this->view->summary = $query->paginate();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// @codingStandardsIgnoreEnd
|
|
|
@ -1,167 +0,0 @@
|
||||||
<? if (! $this->compact): ?>
|
|
||||||
<?= $this->tabs ?>
|
|
||||||
<? endif ?>
|
|
||||||
<? if (empty($this->summary)): ?>
|
|
||||||
There are no such services right now
|
|
||||||
<? else: ?>
|
|
||||||
<?php
|
|
||||||
|
|
||||||
$now = time();
|
|
||||||
|
|
||||||
?>
|
|
||||||
<? if (! $this->compact && $this->summary instanceof \Zend_Paginator): ?>
|
|
||||||
<?= $this->paginationControl($this->summary, null, null, array('preserve' => $this->preserve)); ?>
|
|
||||||
<? endif ?>
|
|
||||||
<table class="pivot action">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<!-- <th style="width: 6em;"> </th>-->
|
|
||||||
<th style="text-align: left;"> </th>
|
|
||||||
<th style="width: 5em;">Critical</th>
|
|
||||||
<th style="width: 5em;">Unknown</th>
|
|
||||||
<th style="width: 5em;">Warning</th>
|
|
||||||
<? if (! $this->compact): ?> <th style="width: 9%;">OK</th><? endif ?>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<? foreach ($this->summary as $row): ?>
|
|
||||||
<?php
|
|
||||||
|
|
||||||
$class_ok = '';
|
|
||||||
$class_warning = '';
|
|
||||||
$class_critical = '';
|
|
||||||
$class_unknown = '';
|
|
||||||
|
|
||||||
$html_ok = '-';
|
|
||||||
$html_warning = '-';
|
|
||||||
$html_critical = '-';
|
|
||||||
$html_unknown = '-';
|
|
||||||
|
|
||||||
$name_class = null;
|
|
||||||
|
|
||||||
if ($row->critical > 0) {
|
|
||||||
$class_critical = 'critical';
|
|
||||||
$html_critical = $row->critical;
|
|
||||||
if ($row->critical_ack + $row->critical_dt > 0) {
|
|
||||||
$html_critical = sprintf(
|
|
||||||
'%s <span class="critical handled">(%s/%s)</span>',
|
|
||||||
$row->critical,
|
|
||||||
$row->critical_ack,
|
|
||||||
$row->critical_dt
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if ($name_class === null) $name_class = 'critical';
|
|
||||||
} elseif ($row->critical_dt + $row->critical_ack > 0) {
|
|
||||||
$class_critical = 'critical handled';
|
|
||||||
$html_critical = sprintf(
|
|
||||||
'%s / %s',
|
|
||||||
$row->critical_ack,
|
|
||||||
$row->critical_dt
|
|
||||||
);
|
|
||||||
if ($name_class === null) $name_class = 'critical handled';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($row->unknown > 0) {
|
|
||||||
$class_unknown = 'unknown';
|
|
||||||
$html_unknown = $row->unknown;
|
|
||||||
if ($row->unknown_ack + $row->unknown_dt > 0) {
|
|
||||||
$html_unknown .= sprintf(
|
|
||||||
' <span class="unknown handled">(%s/%s)</span>',
|
|
||||||
$row->unknown,
|
|
||||||
$row->unknown_ack,
|
|
||||||
$row->unknown_dt
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if ($name_class === null) $name_class = 'unknown';
|
|
||||||
} elseif ($row->unknown_dt + $row->unknown_ack > 0) {
|
|
||||||
$class_unknown = 'unknown handled';
|
|
||||||
$html_unknown = sprintf(
|
|
||||||
'%s / %s',
|
|
||||||
$row->unknown_ack,
|
|
||||||
$row->unknown_dt
|
|
||||||
);
|
|
||||||
if ($name_class === null) $name_class = 'unknown handled';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($row->warning > 0) {
|
|
||||||
$class_warning = 'warning';
|
|
||||||
$html_warning = $row->warning;
|
|
||||||
if ($row->warning_ack + $row->warning_dt > 0) {
|
|
||||||
$html_warning .= sprintf(
|
|
||||||
' <span class="warning handled">(%s/%s)</span>',
|
|
||||||
$row->warning,
|
|
||||||
$row->warning_ack,
|
|
||||||
$row->warning_dt
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if ($name_class === null) $name_class = 'warning';
|
|
||||||
} elseif ($row->warning_dt + $row->warning_ack > 0) {
|
|
||||||
$class_warning = 'warning handled';
|
|
||||||
$html_warning = sprintf(
|
|
||||||
'%s / %s',
|
|
||||||
$row->warning_ack,
|
|
||||||
$row->warning_dt
|
|
||||||
);
|
|
||||||
if ($name_class === null) $name_class = 'warning handled';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if ($row->ok > 0) {
|
|
||||||
$class_ok = 'ok';
|
|
||||||
if (isset($row->hostgroup_name)) {
|
|
||||||
$html_ok = $this->qlink($row->ok, 'monitoring/list/services', array(
|
|
||||||
'hostgroups' => $row->hostgroup_name
|
|
||||||
));
|
|
||||||
} else {
|
|
||||||
$html_ok = $this->qlink($row->ok, 'monitoring/list/services', array(
|
|
||||||
'servicegroups' => $row->servicegroup_name
|
|
||||||
));
|
|
||||||
}
|
|
||||||
if ($name_class === null) $name_class = 'ok';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (isset($row->hostgroup_name)) {
|
|
||||||
if ($name_class === 'ok') {
|
|
||||||
$name_html = $this->qlink($row->hostgroup_name, 'monitoring/list/services', array(
|
|
||||||
'hostgroups' => $row->hostgroup_name
|
|
||||||
));
|
|
||||||
} else {
|
|
||||||
$name_html = $this->qlink($row->hostgroup_name, 'monitoring/list/services', array(
|
|
||||||
'hostgroups' => $row->hostgroup_name,
|
|
||||||
'problems' => '1',
|
|
||||||
'sort' => 'severity'
|
|
||||||
));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ($name_class === 'ok') {
|
|
||||||
$name_html = $this->qlink($row->servicegroup_name, 'monitoring/list/services', array(
|
|
||||||
'servicegroups' => $row->servicegroup_name
|
|
||||||
));
|
|
||||||
} else {
|
|
||||||
$name_html = $this->qlink($row->servicegroup_name, 'monitoring/list/services', array(
|
|
||||||
'servicegroups' => $row->servicegroup_name,
|
|
||||||
'problems' => '1',
|
|
||||||
'sort' => 'severity'
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<tr>
|
|
||||||
<!-- <td class="<?= $name_class ?>"><? if ($row->last_state_change + 600 > $now): ?>
|
|
||||||
<blink><?= $this->timeSince($row->last_state_change) ?></blink>
|
|
||||||
<? else: ?>
|
|
||||||
<?= $this->timeSince($row->last_state_change) ?>
|
|
||||||
<? endif ?></td>-->
|
|
||||||
<td style="text-align: left;"><?= $name_html ?></td>
|
|
||||||
<td class="<?= $class_critical ?>"><?= $html_critical ?></td>
|
|
||||||
<td class="<?= $class_unknown ?>"><?= $html_unknown ?></td>
|
|
||||||
<td class="<?= $class_warning ?>"><?= $html_warning ?></td>
|
|
||||||
<? if (! $this->compact): ?><td class="ok"><?= $html_ok ?></td><? endif ?>
|
|
||||||
</tr>
|
|
||||||
<? endforeach ?>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<? endif ?>
|
|
||||||
<? if ($this->compact): ?><a href="<?= $this->baseUrl('monitoring/summary/group') ?>">more</a><? endif ?>
|
|
Loading…
Reference in New Issue