diff --git a/config/modules/monitoring/menu.ini b/config/modules/monitoring/menu.ini index 6367e88f9..d00282a3e 100755 --- a/config/modules/monitoring/menu.ini +++ b/config/modules/monitoring/menu.ini @@ -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" diff --git a/modules/monitoring/application/controllers/ProcessController.php b/modules/monitoring/application/controllers/ProcessController.php new file mode 100644 index 000000000..f554d8cb7 --- /dev/null +++ b/modules/monitoring/application/controllers/ProcessController.php @@ -0,0 +1,78 @@ + + * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 + * @author Icinga Development Team + */ +// {{{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 \ No newline at end of file diff --git a/modules/monitoring/application/views/helpers/CheckPerformance.php b/modules/monitoring/application/views/helpers/CheckPerformance.php new file mode 100644 index 000000000..6082224c5 --- /dev/null +++ b/modules/monitoring/application/views/helpers/CheckPerformance.php @@ -0,0 +1,74 @@ + + * @author Icinga Development Team + */ +// {{{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 \ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/process/performance.phtml b/modules/monitoring/application/views/scripts/process/performance.phtml new file mode 100644 index 000000000..46cdfa4e9 --- /dev/null +++ b/modules/monitoring/application/views/scripts/process/performance.phtml @@ -0,0 +1,185 @@ +runtimevariables; + $ps = $this->programstatus; + + $cp = $this->checkPerformance()->create($this->checkperformance); +?> +

Process Information

+ +
+ +
+
+ Backend backendName; ?> is + is_currently_running === '1' ? 'running' : 'not running'; ?> + (pid process_id; ?>) + since timeSince($ps->program_start_time); ?> ago + (dateFormat()->formatDateTime($ps->program_start_time); ?>). +
+
+ +disable_notif_expire_time): ?> +
+

Notifications disabled with expiration time

+

+ Notifications automatically turned on again on the + dateFormat()->formatDateTime($ps->disable_notif_expire_time); ?> +

+
+ + +
+
+

Object summaries

+ + + + + + + + + + + + + + + + + + + + + + + +
 # overall / scheduled
+ Hosts + + total_hosts; ?> + / total_scheduled_hosts; ?> +
+ Services + + total_services; ?> + / total_scheduled_services; ?> +
+ Average services per host + + average_services_per_host); ?> + / average_scheduled_services_per_host); ?> +
+ +

Active checks

+ + + + + + + + + + + + + + + + + + + + + + + +
 #LatencyExecution time
+ Host Checks + host_active_count; ?>host_active_latency_avg); ?>shost_active_execution_avg); ?>s
+ Service Checks + service_active_count; ?>service_active_latency_avg); ?>sservice_active_execution_avg); ?>s
+ +

Passive checks

+ + + + + + + + + + + + + + + + + +
 #
+ Host Checks + host_passive_count; ?>
+ Service Checks + service_passive_count; ?>
+ +

Actuality

+ + + + + + + + + + + +
+ Last status update + + dateFormat()->formatDateTime($ps->status_update_time); ?> + (since timeSince($ps->status_update_time); ?> ago) +
+ Last check command + + dateFormat()->formatDateTime($ps->last_command_check); ?> + (since timeSince($ps->last_command_check); ?> ago) +
+ +

Configuration

+ + + + + + + + + + + +
+ Global host event handler + + global_host_event_handler): ?> + global_host_event_handler; ?> + + Not set + +
+ Global service event handler + + global_service_event_handler): ?> + global_service_event_handler; ?> + + Not set + +
+
+
+
Global commands goes here
+
+
\ No newline at end of file diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ProgramstatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ProgramstatusQuery.php new file mode 100644 index 000000000..5c5bd6c98 --- /dev/null +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ProgramstatusQuery.php @@ -0,0 +1,62 @@ + + * @author Icinga Development Team + */ +// {{{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', + ) + ); +} diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/RuntimesummaryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/RuntimesummaryQuery.php new file mode 100644 index 000000000..019d5caaf --- /dev/null +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/RuntimesummaryQuery.php @@ -0,0 +1,96 @@ + + * @author Icinga Development Team + */ +// {{{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); + } +} diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/RuntimevariablesQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/RuntimevariablesQuery.php new file mode 100644 index 000000000..4602bca2b --- /dev/null +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/RuntimevariablesQuery.php @@ -0,0 +1,40 @@ + + * @author Icinga Development Team + */ +// {{{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' + ) + ); +} diff --git a/modules/monitoring/library/Monitoring/DataView/Programstatus.php b/modules/monitoring/library/Monitoring/DataView/Programstatus.php new file mode 100644 index 000000000..f3fa78310 --- /dev/null +++ b/modules/monitoring/library/Monitoring/DataView/Programstatus.php @@ -0,0 +1,82 @@ + + * @author Icinga Development Team + */ +// {{{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 + ) + ); + } +} diff --git a/modules/monitoring/library/Monitoring/DataView/Runtimesummary.php b/modules/monitoring/library/Monitoring/DataView/Runtimesummary.php new file mode 100644 index 000000000..6470b5044 --- /dev/null +++ b/modules/monitoring/library/Monitoring/DataView/Runtimesummary.php @@ -0,0 +1,64 @@ + + * @author Icinga Development Team + */ +// {{{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 + ) + ); + } +} diff --git a/modules/monitoring/library/Monitoring/DataView/Runtimevariables.php b/modules/monitoring/library/Monitoring/DataView/Runtimevariables.php new file mode 100644 index 000000000..149aae14a --- /dev/null +++ b/modules/monitoring/library/Monitoring/DataView/Runtimevariables.php @@ -0,0 +1,60 @@ + + * @author Icinga Development Team + */ +// {{{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 + ) + ); + } +} diff --git a/public/css/icinga/main.less b/public/css/icinga/main.less index 71b09a43b..b86bb206d 100644 --- a/public/css/icinga/main.less +++ b/public/css/icinga/main.less @@ -411,5 +411,5 @@ select.input-sm { } .panel-body { - margin-bottom: 45px; + } \ No newline at end of file diff --git a/test/php/library/Icinga/Web/Widget/TabTest.php b/test/php/library/Icinga/Web/Widget/TabTest.php index edbe83504..c84b478b0 100644 --- a/test/php/library/Icinga/Web/Widget/TabTest.php +++ b/test/php/library/Icinga/Web/Widget/TabTest.php @@ -152,6 +152,7 @@ class TabTest extends PHPUnit_Framework_TestCase ) ); $html = $tab->render(new ViewMock()); + $this->assertEquals( 1, preg_match(