Merge branch 'feature/performance-overview-4189'

resolves #4189
resolves #4136
fixes #4915
This commit is contained in:
Marius Hein 2013-10-18 11:38:51 +02:00
commit 3166e1a3ff
12 changed files with 746 additions and 1 deletions

View File

@ -31,3 +31,6 @@ Hostgroups.route = "/monitoring/list/hostgroups"
History.title = "History"
History.route = "/monitoring/list/eventhistory"
Performance.title = "Performance"
Performance.route ="/monitoring/process/performance"

View File

@ -0,0 +1,78 @@
<?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\Module\Monitoring\Controller as MonitoringController;
use Icinga\Module\Monitoring\Backend;
use Icinga\Module\Monitoring\DataView\Runtimevariables as RuntimevariablesView;
use Icinga\Module\Monitoring\DataView\Programstatus as ProgramstatusView;
use Icinga\Module\Monitoring\DataView\Runtimesummary as RuntimesummaryView;
/**
* Display process information and global commands
*/
class Monitoring_ProcessController extends MonitoringController
{
/**
* @var \Icinga\Module\Monitoring\Backend
*/
public $backend;
/**
* Retrieve backend and hooks for this controller
*
* @see ActionController::init
*/
public function init()
{
$this->backend = Backend::createBackend($this->_getParam('backend'));
}
public function performanceAction()
{
$this->view->runtimevariables = (object)RuntimevariablesView::fromRequest(
$this->_request,
array('varname', 'varvalue')
)->getQuery()->fetchPairs();
$this->view->programstatus = ProgramstatusView::fromRequest(
$this->_request
)->getQuery()->fetchRow();
$this->view->checkperformance = $query = RuntimesummaryView::fromRequest(
$this->_request
)->getQuery()->fetchAll();
$this->view->backendName = $this->backend->getDefaultBackendName();
}
}
// @codingStandardsIgnoreStop

View File

@ -0,0 +1,74 @@
<?php
// @codingStandardsIgnoreStart
// {{{ICINGA_LICENSE_HEADER}}}
/**
* Icinga 2 Web - Head for multiple monitoring frontends
* 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>
* @author Icinga Development Team <info@icinga.org>
*/
// {{{ICINGA_LICENSE_HEADER}}}
/**
* Convert check summary data into a simple usable stdClass
*/
class Zend_View_Helper_CheckPerformance extends Zend_View_Helper_Abstract
{
/**
* Create dispatch instance
*
* @return self
*/
public function checkPerformance()
{
return $this;
}
/**
* Create a condensed row of object data
*
* @param array $results Array of stdClass
*
* @return stdClass Condensed row
*/
public function create(array $results)
{
$out = new stdClass();
$out->host_passive_count = 0;
$out->host_passive_latency_avg = 0;
$out->host_passive_execution_avg = 0;
$out->service_passive_count = 0;
$out->service_passive_latency_avg = 0;
$out->service_passive_execution_avg = 0;
$out->service_active_count = 0;
$out->service_active_latency_avg = 0;
$out->service_active_execution_avg = 0;
$out->host_active_count = 0;
$out->host_active_latency_avg = 0;
$out->host_active_execution_avg = 0;
foreach ($results as $row) {
$key = $row->object_type . '_' . $row->check_type . '_';
$out->{$key . 'count'} = $row->object_count;
$out->{$key . 'latency_avg'} = $row->latency / $row->object_count;
$out->{$key . 'execution_avg'} = $row->execution_time / $row->object_count;
}
return $out;
}
}
// @codingStandardsIgnoreStop

View File

@ -0,0 +1,185 @@
<?php
$rv = $this->runtimevariables;
$ps = $this->programstatus;
$cp = $this->checkPerformance()->create($this->checkperformance);
?>
<h1>Process Information</h1>
<hr />
<div class="panel panel-default">
<div class="panel-body">
Backend <strong><?= $this->backendName; ?></strong> is
<?= $ps->is_currently_running === '1' ? 'running' : 'not running'; ?>
(pid <?= $ps->process_id; ?>)
since <?= $this->timeSince($ps->program_start_time); ?> ago
(<?= $this->dateFormat()->formatDateTime($ps->program_start_time); ?>).
</div>
</div>
<?php if ($ps->disable_notif_expire_time): ?>
<div class="alert alert-warning">
<h4>Notifications disabled with expiration time</h4>
<p>
Notifications automatically turned on again on the
<strong><?= $this->dateFormat()->formatDateTime($ps->disable_notif_expire_time); ?></strong>
</p>
</div>
<?php endif; ?>
<div class="row">
<div class="col-md-7">
<h4>Object summaries</h4>
<table class="table-bordered table">
<thead>
<tr>
<td style="width: 300px;">&nbsp;</td>
<td># overall / scheduled</td>
</tr>
</thead>
<tbody>
<tr>
<td>
<strong>Hosts</strong>
</td>
<td>
<?= $rv->total_hosts; ?>
/ <?= $rv->total_scheduled_hosts; ?>
</td>
</tr>
<tr>
<td>
<strong>Services</strong>
</td>
<td>
<?= $rv->total_services; ?>
/ <?= $rv->total_scheduled_services; ?>
</td>
</tr>
<tr>
<td>
<strong>Average services per host</strong>
</td>
<td>
<?= sprintf('%.2f', $rv->average_services_per_host); ?>
/ <?= sprintf('%.2f', $rv->average_scheduled_services_per_host); ?>
</td>
</tr>
</tbody>
</table>
<h4>Active checks</h4>
<table class="table-bordered table">
<thead>
<tr>
<td style="width: 300px;">&nbsp;</td>
<td>#</td>
<td>Latency</td>
<td>Execution time</td>
</tr>
</thead>
<tbody>
<tr>
<td>
<strong>Host Checks</strong>
</td>
<td><?= $cp->host_active_count; ?></td>
<td><?= sprintf('%.3f', $cp->host_active_latency_avg); ?>s</td>
<td><?= sprintf('%.3f', $cp->host_active_execution_avg); ?>s</td>
</tr>
<tr>
<td>
<strong>Service Checks</strong>
</td>
<td><?= $cp->service_active_count; ?></td>
<td><?= sprintf('%.3f', $cp->service_active_latency_avg); ?>s</td>
<td><?= sprintf('%.3f', $cp->service_active_execution_avg); ?>s</td>
</tr>
</tbody>
</table>
<h4>Passive checks</h4>
<table class="table-bordered table">
<thead>
<tr>
<td style="width: 300px;">&nbsp;</td>
<td>#</td>
</tr>
</thead>
<tbody>
<tr>
<td>
<strong>Host Checks</strong>
</td>
<td><?= $cp->host_passive_count; ?></td>
</tr>
<tr>
<td>
<strong>Service Checks</strong>
</td>
<td><?= $cp->service_passive_count; ?></td>
</tr>
</tbody>
</table>
<h4>Actuality</h4>
<table class="table-bordered table">
<tbody>
<tr>
<td style="width: 300px;">
<strong>Last status update</strong>
</td>
<td>
<?= $this->dateFormat()->formatDateTime($ps->status_update_time); ?>
(since <?= $this->timeSince($ps->status_update_time); ?> ago)
</td>
</tr>
<tr>
<td>
<strong>Last check command</strong>
</td>
<td>
<?= $this->dateFormat()->formatDateTime($ps->last_command_check); ?>
(since <?= $this->timeSince($ps->last_command_check); ?> ago)
</td>
</tr>
</tbody>
</table>
<h4>Configuration</h4>
<table class="table-bordered table">
<tbody>
<tr>
<td style="width: 300px;">
<strong>Global host event handler</strong>
</td>
<td>
<?php if ($ps->global_host_event_handler): ?>
<?= $ps->global_host_event_handler; ?>
<?php else: ?>
Not set
<?php endif; ?>
</td>
</tr>
<tr>
<td style="width: 300px;">
<strong>Global service event handler</strong>
</td>
<td>
<?php if ($ps->global_service_event_handler): ?>
<?= $ps->global_service_event_handler; ?>
<?php else: ?>
Not set
<?php endif; ?>
</td>
</tr>
</tbody>
</table>
</div>
<div class="col-md-5">
<h6>Global commands goes here</h6>
</div>
</div>

View File

@ -0,0 +1,62 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
/**
* Icinga 2 Web - Head for multiple monitoring frontends
* 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>
* @author Icinga Development Team <info@icinga.org>
*/
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
/**
* Query program status out of database
*/
class ProgramstatusQuery extends IdoQuery
{
protected $columnMap = array(
'programstatus' => array(
'id' => 'programstatus_id',
'status_update_time' => 'UNIX_TIMESTAMP(status_update_time)',
'program_start_time' => 'UNIX_TIMESTAMP(program_start_time)',
'program_end_time' => 'UNIX_TIMESTAMP(program_end_time)',
'is_currently_running' => 'is_currently_running',
'process_id' => 'process_id',
'daemon_mode' => 'daemon_mode',
'last_command_check' => 'UNIX_TIMESTAMP(last_command_check)',
'last_log_rotation' => 'UNIX_TIMESTAMP(last_log_rotation)',
'notifications_enabled' => 'notifications_enabled',
'disable_notif_expire_time' => 'UNIX_TIMESTAMP(disable_notif_expire_time)',
'active_service_checks_enabled' => 'active_service_checks_enabled',
'passive_service_checks_enabled' => 'passive_service_checks_enabled',
'active_host_checks_enabled' => 'active_host_checks_enabled',
'passive_host_checks_enabled' => 'passive_host_checks_enabled',
'event_handlers_enabled' => 'event_handlers_enabled',
'flap_detection_enabled' => 'flap_detection_enabled',
'failure_prediction_enabled' => 'failure_prediction_enabled',
'process_performance_data' => 'process_performance_data',
'obsess_over_hosts' => 'obsess_over_hosts',
'obsess_over_services' => 'obsess_over_services',
'modified_host_attributes' => 'modified_host_attributes',
'modified_service_attributes' => 'modified_service_attributes',
'global_host_event_handler' => 'global_host_event_handler',
'global_service_event_handler' => 'global_service_event_handler',
)
);
}

View File

@ -0,0 +1,96 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
/**
* Icinga 2 Web - Head for multiple monitoring frontends
* 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>
* @author Icinga Development Team <info@icinga.org>
*/
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
use \Zend_Db_Select;
/**
* Query check summaries out of database
*/
class RuntimesummaryQuery extends IdoQuery
{
protected $columnMap = array(
'runtimesummary' => array(
'check_type' => 'check_type',
'active_checks_enabled' => 'active_checks_enabled',
'passive_checks_enabled' => 'passive_checks_enabled',
'execution_time' => 'execution_time',
'latency' => 'latency',
'object_count' => 'object_count',
'object_type' => 'object_type'
)
);
protected function joinBaseTables()
{
$p = $this->prefix;
$hostColumns = array(
'check_type' => 'CASE '
. 'WHEN ' . $p
. 'hoststatus.active_checks_enabled = 0 AND '
. $p . 'hoststatus.passive_checks_enabled = 1 '
. 'THEN \'passive\' '
. 'WHEN ' . $p . 'hoststatus.active_checks_enabled = 1 THEN \'active\' END',
'active_checks_enabled' => 'active_checks_enabled',
'passive_checks_enabled' => 'passive_checks_enabled',
'execution_time' => 'SUM(execution_time)',
'latency' => 'SUM(latency)',
'object_count' => 'COUNT(*)',
'object_type' => "('host')"
);
$serviceColumns = array(
'check_type' => 'CASE '
. 'WHEN ' . $p
. 'servicestatus.active_checks_enabled = 0 AND ' . $p
. 'servicestatus.passive_checks_enabled = 1 '
. 'THEN \'passive\' '
. 'WHEN ' . $p . 'servicestatus.active_checks_enabled = 1 THEN \'active\' END',
'active_checks_enabled' => 'active_checks_enabled',
'passive_checks_enabled' => 'passive_checks_enabled',
'execution_time' => 'SUM(execution_time)',
'latency' => 'SUM(latency)',
'object_count' => 'COUNT(*)',
'object_type' => "('service')"
);
$hosts = $this->db->select()->from($this->prefix . 'hoststatus', $hostColumns)
->group('check_type')->group('active_checks_enabled')->group('passive_checks_enabled');
$services = $this->db->select()->from($this->prefix . 'servicestatus', $serviceColumns)
->group('check_type')->group('active_checks_enabled')->group('passive_checks_enabled');
$union = $this->db->select()->union(
array('s' => $services, 'h' => $hosts),
Zend_Db_Select::SQL_UNION_ALL
);
$this->baseQuery = $this->db->select()->from(array('hs' => $union));
$this->joinedVirtualTables = array('runtimesummary' => true);
}
}

View File

@ -0,0 +1,40 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
/**
* Icinga 2 Web - Head for multiple monitoring frontends
* 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>
* @author Icinga Development Team <info@icinga.org>
*/
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
/**
* Query for runtimevariables table
*/
class RuntimevariablesQuery extends IdoQuery
{
protected $columnMap = array(
'runtimevariables' => array(
'id' => 'runtimevariable_id',
'varname' => 'varname',
'varvalue' => 'varvalue'
)
);
}

View File

@ -0,0 +1,82 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
/**
* Icinga 2 Web - Head for multiple monitoring frontends
* 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>
* @author Icinga Development Team <info@icinga.org>
*/
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Module\Monitoring\DataView;
/**
* View for programstatus query
*/
class Programstatus extends DataView
{
/**
* Retrieve columns provided by this view
*
* @return array
*/
public function getColumns()
{
return array(
'id',
'status_update_time',
'program_start_time',
'program_end_time',
'is_currently_running',
'process_id',
'daemon_mode',
'last_command_check',
'last_log_rotation',
'notifications_enabled',
'disable_notif_expire_time',
'active_service_checks_enabled',
'passive_service_checks_enabled',
'active_host_checks_enabled',
'passive_host_checks_enabled',
'event_handlers_enabled',
'flap_detection_enabled',
'failure_prediction_enabled',
'process_performance_data',
'obsess_over_hosts',
'obsess_over_services',
'modified_host_attributes',
'modified_service_attributes',
'global_host_event_handler',
'global_service_event_handler',
);
}
/**
* Retrieve default sorting rules for particular columns. These involve sort order and potential additional to sort
*
* @return array
*/
public function getSortRules()
{
return array(
'id' => array(
'order' => self::SORT_DESC
)
);
}
}

View File

@ -0,0 +1,64 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
/**
* Icinga 2 Web - Head for multiple monitoring frontends
* 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>
* @author Icinga Development Team <info@icinga.org>
*/
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Module\Monitoring\DataView;
/**
* View for runtimesummary query
*/
class Runtimesummary extends DataView
{
/**
* Retrieve columns provided by this view
*
* @return array
*/
public function getColumns()
{
return array(
'check_type',
'active_checks_enabled',
'passive_checks_enabled',
'execution_time',
'latency',
'object_count',
'object_type'
);
}
/**
* Retrieve default sorting rules for particular columns. These involve sort order and potential additional to sort
*
* @return array
*/
public function getSortRules()
{
return array(
'active_checks_enabled' => array(
'order' => self::SORT_ASC
)
);
}
}

View File

@ -0,0 +1,60 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
/**
* Icinga 2 Web - Head for multiple monitoring frontends
* 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>
* @author Icinga Development Team <info@icinga.org>
*/
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Module\Monitoring\DataView;
/**
* View for runtimevariables query
*/
class Runtimevariables extends DataView
{
/**
* Retrieve columns provided by this view
*
* @return array
*/
public function getColumns()
{
return array(
'id',
'varname',
'varvalue'
);
}
/**
* Retrieve default sorting rules for particular columns. These involve sort order and potential additional to sort
*
* @return array
*/
public function getSortRules()
{
return array(
'id' => array(
'order' => self::SORT_ASC
)
);
}
}

View File

@ -411,5 +411,5 @@ select.input-sm {
}
.panel-body {
margin-bottom: 45px;
}

View File

@ -152,6 +152,7 @@ class TabTest extends PHPUnit_Framework_TestCase
)
);
$html = $tab->render(new ViewMock());
$this->assertEquals(
1,
preg_match(