2013-06-27 10:14:41 +02:00
|
|
|
<?php
|
2015-02-04 10:46:36 +01:00
|
|
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
2013-08-20 11:44:05 +02:00
|
|
|
|
2014-03-08 18:49:31 +01:00
|
|
|
use Icinga\Module\Monitoring\Controller;
|
2014-06-06 09:37:37 +02:00
|
|
|
use Icinga\Module\Monitoring\Backend;
|
2015-05-07 16:20:59 +02:00
|
|
|
use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm;
|
2014-11-14 11:17:22 +01:00
|
|
|
use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeCommandForm;
|
2014-06-06 09:37:37 +02:00
|
|
|
use Icinga\Web\Url;
|
2013-10-09 16:38:46 +02:00
|
|
|
use Icinga\Web\Widget\Tabextension\DashboardAction;
|
|
|
|
use Icinga\Web\Widget\Tabextension\OutputFormat;
|
|
|
|
use Icinga\Web\Widget\Tabs;
|
2014-06-06 09:37:37 +02:00
|
|
|
use Icinga\Data\Filter\Filter;
|
|
|
|
use Icinga\Web\Widget;
|
2014-11-14 11:17:22 +01:00
|
|
|
use Icinga\Module\Monitoring\Forms\StatehistoryForm;
|
2013-09-24 15:26:10 +02:00
|
|
|
|
2014-03-08 18:49:31 +01:00
|
|
|
class Monitoring_ListController extends Controller
|
2013-06-27 10:14:41 +02:00
|
|
|
{
|
2013-08-14 12:42:32 +02:00
|
|
|
/**
|
|
|
|
* @see ActionController::init
|
|
|
|
*/
|
2013-06-27 10:14:41 +02:00
|
|
|
public function init()
|
|
|
|
{
|
2015-05-11 13:36:58 +02:00
|
|
|
parent::init();
|
2013-08-08 16:22:22 +02:00
|
|
|
$this->createTabs();
|
2013-06-27 10:14:41 +02:00
|
|
|
}
|
|
|
|
|
2014-11-20 17:19:26 +01:00
|
|
|
/**
|
|
|
|
* @deprecated DO NOT USE. THIS IS A HACK. This is removed once we fix the eventhistory action w/ filters.
|
|
|
|
*/
|
|
|
|
protected function applyFilter($query)
|
|
|
|
{
|
|
|
|
$params = clone $this->params;
|
|
|
|
$params->shift('format');
|
|
|
|
$params->shift('limit');
|
|
|
|
$params->shift('page');
|
|
|
|
$params->shift('view');
|
|
|
|
if ($sort = $params->shift('sort')) {
|
|
|
|
$query->order($sort, $params->shift('dir'));
|
|
|
|
}
|
|
|
|
$query->applyFilter(Filter::fromQuerystring((string) $params));
|
|
|
|
$this->handleFormatRequest($query);
|
|
|
|
return $query;
|
|
|
|
}
|
|
|
|
|
2013-08-30 15:50:49 +02:00
|
|
|
/**
|
|
|
|
* Overwrite the backend to use (used for testing)
|
|
|
|
*
|
|
|
|
* @param Backend $backend The Backend that should be used for querying
|
|
|
|
*/
|
|
|
|
public function setBackend($backend)
|
|
|
|
{
|
|
|
|
$this->backend = $backend;
|
|
|
|
}
|
|
|
|
|
2013-08-14 12:42:32 +02:00
|
|
|
/**
|
|
|
|
* Display host list
|
|
|
|
*/
|
2013-06-27 10:14:41 +02:00
|
|
|
public function hostsAction()
|
|
|
|
{
|
2014-06-26 00:42:38 +02:00
|
|
|
// Handle soft and hard states
|
2015-01-20 16:14:56 +01:00
|
|
|
if (strtolower($this->params->shift('stateType', 'soft')) === 'hard') {
|
2014-06-26 00:42:38 +02:00
|
|
|
$stateColumn = 'host_hard_state';
|
|
|
|
$stateChangeColumn = 'host_last_hard_state_change';
|
|
|
|
} else {
|
|
|
|
$stateColumn = 'host_state';
|
|
|
|
$stateChangeColumn = 'host_last_state_change';
|
|
|
|
}
|
|
|
|
|
2015-02-23 17:00:30 +01:00
|
|
|
$this->addTitleTab('hosts', $this->translate('Hosts'), $this->translate('List hosts'));
|
2014-03-04 13:33:02 +01:00
|
|
|
$this->setAutorefreshInterval(10);
|
2014-06-24 21:12:55 +02:00
|
|
|
$query = $this->backend->select()->from('hostStatus', array_merge(array(
|
2014-06-06 09:37:37 +02:00
|
|
|
'host_icon_image',
|
|
|
|
'host_name',
|
2015-01-20 16:23:12 +01:00
|
|
|
'host_display_name',
|
2014-06-26 00:42:38 +02:00
|
|
|
'host_state' => $stateColumn,
|
2014-06-06 09:37:37 +02:00
|
|
|
'host_address',
|
|
|
|
'host_acknowledged',
|
|
|
|
'host_output',
|
2014-08-22 11:23:45 +02:00
|
|
|
'host_attempt',
|
2014-06-06 09:37:37 +02:00
|
|
|
'host_in_downtime',
|
|
|
|
'host_is_flapping',
|
|
|
|
'host_state_type',
|
|
|
|
'host_handled',
|
|
|
|
'host_last_check',
|
2014-06-26 00:42:38 +02:00
|
|
|
'host_last_state_change' => $stateChangeColumn,
|
2014-06-06 09:37:37 +02:00
|
|
|
'host_notifications_enabled',
|
2014-06-25 21:38:55 +02:00
|
|
|
'host_unhandled_services',
|
2014-06-06 09:37:37 +02:00
|
|
|
'host_action_url',
|
|
|
|
'host_notes_url',
|
2014-06-25 21:38:55 +02:00
|
|
|
'host_last_comment',
|
|
|
|
'host_last_ack',
|
|
|
|
'host_last_downtime',
|
2014-06-06 09:37:37 +02:00
|
|
|
'host_active_checks_enabled',
|
|
|
|
'host_passive_checks_enabled',
|
|
|
|
'host_current_check_attempt',
|
|
|
|
'host_max_check_attempts'
|
2015-05-18 16:29:33 +02:00
|
|
|
), $this->addColumns()));
|
2014-11-16 00:20:12 +01:00
|
|
|
$this->filterQuery($query);
|
2015-01-27 13:51:15 +01:00
|
|
|
$this->applyRestriction('monitoring/hosts/filter', $query);
|
2015-05-15 14:32:58 +02:00
|
|
|
$this->view->hosts = $query;
|
2014-11-14 16:50:34 +01:00
|
|
|
|
|
|
|
$this->view->stats = $this->backend->select()->from('statusSummary', array(
|
|
|
|
'hosts_total',
|
|
|
|
'hosts_up',
|
|
|
|
'hosts_down',
|
|
|
|
'hosts_down_handled',
|
|
|
|
'hosts_down_unhandled',
|
|
|
|
'hosts_unreachable',
|
|
|
|
'hosts_unreachable_handled',
|
|
|
|
'hosts_unreachable_unhandled',
|
|
|
|
'hosts_pending',
|
|
|
|
))->getQuery()->fetchRow();
|
2015-04-17 16:12:35 +02:00
|
|
|
|
|
|
|
$this->setupLimitControl();
|
|
|
|
$this->setupPaginationControl($this->view->hosts);
|
2015-05-15 10:56:52 +02:00
|
|
|
$this->setupSortControl(array(
|
|
|
|
'host_severity' => $this->translate('Severity'),
|
|
|
|
'host_state' => $this->translate('Current State'),
|
|
|
|
'host_display_name' => $this->translate('Hostname'),
|
|
|
|
'host_address' => $this->translate('Address'),
|
|
|
|
'host_last_check' => $this->translate('Last Check')
|
|
|
|
), $query);
|
2013-06-27 10:14:41 +02:00
|
|
|
}
|
|
|
|
|
2013-08-14 12:42:32 +02:00
|
|
|
/**
|
|
|
|
* Display service list
|
|
|
|
*/
|
2013-06-27 10:14:41 +02:00
|
|
|
public function servicesAction()
|
|
|
|
{
|
2014-06-26 00:42:38 +02:00
|
|
|
// Handle soft and hard states
|
2015-01-20 16:14:56 +01:00
|
|
|
if (strtolower($this->params->shift('stateType', 'soft')) === 'hard') {
|
2014-06-26 00:42:38 +02:00
|
|
|
$stateColumn = 'service_hard_state';
|
|
|
|
$stateChangeColumn = 'service_last_hard_state_change';
|
|
|
|
} else {
|
|
|
|
$stateColumn = 'service_state';
|
|
|
|
$stateChangeColumn = 'service_last_state_change';
|
|
|
|
}
|
|
|
|
|
2015-02-23 17:00:30 +01:00
|
|
|
$this->addTitleTab('services', $this->translate('Services'), $this->translate('List services'));
|
2014-03-08 01:00:21 +01:00
|
|
|
$this->view->showHost = true;
|
2015-04-09 11:12:09 +02:00
|
|
|
if (strpos($this->params->get('host_name', '*'), '*') === false) {
|
|
|
|
$this->view->showHost = false;
|
2014-03-08 01:00:21 +01:00
|
|
|
}
|
2014-03-04 13:33:02 +01:00
|
|
|
$this->setAutorefreshInterval(10);
|
2014-07-16 17:49:25 +02:00
|
|
|
|
2014-06-06 09:37:37 +02:00
|
|
|
$columns = array_merge(array(
|
|
|
|
'host_name',
|
2015-01-21 09:41:52 +01:00
|
|
|
'host_display_name',
|
2014-06-06 09:37:37 +02:00
|
|
|
'host_state',
|
|
|
|
'host_state_type',
|
|
|
|
'host_last_state_change',
|
|
|
|
'host_address',
|
|
|
|
'host_handled',
|
|
|
|
'service_description',
|
|
|
|
'service_display_name',
|
2014-06-26 00:42:38 +02:00
|
|
|
'service_state' => $stateColumn,
|
2014-06-06 09:37:37 +02:00
|
|
|
'service_in_downtime',
|
|
|
|
'service_acknowledged',
|
|
|
|
'service_handled',
|
|
|
|
'service_output',
|
|
|
|
'service_perfdata',
|
|
|
|
'service_attempt',
|
2014-06-26 00:42:38 +02:00
|
|
|
'service_last_state_change' => $stateChangeColumn,
|
2014-06-06 09:37:37 +02:00
|
|
|
'service_icon_image',
|
|
|
|
'service_is_flapping',
|
|
|
|
'service_state_type',
|
|
|
|
'service_handled',
|
|
|
|
'service_severity',
|
|
|
|
'service_last_check',
|
|
|
|
'service_notifications_enabled',
|
|
|
|
'service_action_url',
|
|
|
|
'service_notes_url',
|
2014-06-25 21:38:55 +02:00
|
|
|
'service_last_comment',
|
|
|
|
'service_last_ack',
|
|
|
|
'service_last_downtime',
|
2014-06-06 09:37:37 +02:00
|
|
|
'service_active_checks_enabled',
|
|
|
|
'service_passive_checks_enabled',
|
|
|
|
'current_check_attempt' => 'service_current_check_attempt',
|
|
|
|
'max_check_attempts' => 'service_max_check_attempts'
|
2015-05-18 16:29:33 +02:00
|
|
|
), $this->addColumns());
|
2014-06-06 09:37:37 +02:00
|
|
|
$query = $this->backend->select()->from('serviceStatus', $columns);
|
2014-11-15 23:53:57 +01:00
|
|
|
$this->filterQuery($query);
|
2015-01-27 13:49:51 +01:00
|
|
|
$this->applyRestriction('monitoring/services/filter', $query);
|
2015-05-15 14:32:58 +02:00
|
|
|
$this->view->services = $query;
|
2015-05-15 10:56:52 +02:00
|
|
|
|
|
|
|
$this->setupLimitControl();
|
|
|
|
$this->setupPaginationControl($this->view->services);
|
2013-09-03 18:43:17 +02:00
|
|
|
$this->setupSortControl(array(
|
2015-01-21 09:35:33 +01:00
|
|
|
'service_severity' => $this->translate('Service Severity'),
|
2014-09-29 15:20:19 +02:00
|
|
|
'service_state' => $this->translate('Current Service State'),
|
2015-01-21 09:22:44 +01:00
|
|
|
'service_display_name' => $this->translate('Service Name'),
|
2015-01-21 09:35:33 +01:00
|
|
|
'service_last_check' => $this->translate('Last Service Check'),
|
2014-09-29 15:20:19 +02:00
|
|
|
'host_severity' => $this->translate('Host Severity'),
|
|
|
|
'host_state' => $this->translate('Current Host State'),
|
2015-01-21 09:22:44 +01:00
|
|
|
'host_display_name' => $this->translate('Hostname'),
|
2014-09-29 15:20:19 +02:00
|
|
|
'host_address' => $this->translate('Host Address'),
|
|
|
|
'host_last_check' => $this->translate('Last Host Check')
|
2015-05-12 10:16:51 +02:00
|
|
|
), $query);
|
2014-09-05 17:40:57 +02:00
|
|
|
|
|
|
|
$this->view->stats = $this->backend->select()->from('statusSummary', array(
|
|
|
|
'services_total',
|
|
|
|
'services_ok',
|
|
|
|
'services_problem',
|
|
|
|
'services_problem_handled',
|
|
|
|
'services_problem_unhandled',
|
|
|
|
'services_critical',
|
|
|
|
'services_critical_unhandled',
|
|
|
|
'services_critical_handled',
|
|
|
|
'services_warning',
|
|
|
|
'services_warning_unhandled',
|
|
|
|
'services_warning_handled',
|
|
|
|
'services_unknown',
|
|
|
|
'services_unknown_unhandled',
|
|
|
|
'services_unknown_handled',
|
|
|
|
'services_pending',
|
|
|
|
))->getQuery()->fetchRow();
|
2013-06-27 10:14:41 +02:00
|
|
|
}
|
|
|
|
|
2013-07-30 17:17:19 +02:00
|
|
|
/**
|
2013-08-20 11:44:05 +02:00
|
|
|
* Fetch the current downtimes and put them into the view property `downtimes`
|
2013-07-30 17:17:19 +02:00
|
|
|
*/
|
|
|
|
public function downtimesAction()
|
|
|
|
{
|
2015-02-23 17:00:30 +01:00
|
|
|
$this->addTitleTab('downtimes', $this->translate('Downtimes'), $this->translate('List downtimes'));
|
2014-03-09 21:58:01 +01:00
|
|
|
$this->setAutorefreshInterval(12);
|
2015-04-17 16:13:22 +02:00
|
|
|
|
2014-06-06 09:37:37 +02:00
|
|
|
$query = $this->backend->select()->from('downtime', array(
|
|
|
|
'id' => 'downtime_internal_id',
|
|
|
|
'objecttype' => 'downtime_objecttype',
|
|
|
|
'comment' => 'downtime_comment',
|
2015-04-10 14:23:05 +02:00
|
|
|
'author_name' => 'downtime_author_name',
|
2014-06-06 09:37:37 +02:00
|
|
|
'start' => 'downtime_start',
|
|
|
|
'scheduled_start' => 'downtime_scheduled_start',
|
2014-08-19 17:03:35 +02:00
|
|
|
'scheduled_end' => 'downtime_scheduled_end',
|
2014-06-06 09:37:37 +02:00
|
|
|
'end' => 'downtime_end',
|
|
|
|
'duration' => 'downtime_duration',
|
|
|
|
'is_flexible' => 'downtime_is_flexible',
|
|
|
|
'is_fixed' => 'downtime_is_fixed',
|
|
|
|
'is_in_effect' => 'downtime_is_in_effect',
|
|
|
|
'entry_time' => 'downtime_entry_time',
|
2014-08-19 17:03:35 +02:00
|
|
|
'host_state' => 'downtime_host_state',
|
2015-01-21 12:53:26 +01:00
|
|
|
'service_state' => 'downtime_service_state',
|
2015-04-10 14:19:38 +02:00
|
|
|
'host_name',
|
|
|
|
'service_description',
|
2015-01-21 12:53:26 +01:00
|
|
|
'host_display_name',
|
|
|
|
'service_display_name'
|
2015-01-21 12:55:41 +01:00
|
|
|
));
|
2014-11-16 00:20:12 +01:00
|
|
|
$this->filterQuery($query);
|
2015-05-15 14:32:58 +02:00
|
|
|
$this->view->downtimes = $query;
|
2015-05-15 10:56:52 +02:00
|
|
|
|
|
|
|
$this->setupLimitControl();
|
|
|
|
$this->setupPaginationControl($this->view->downtimes);
|
2013-09-03 18:43:17 +02:00
|
|
|
$this->setupSortControl(array(
|
2015-01-21 10:33:05 +01:00
|
|
|
'downtime_is_in_effect' => $this->translate('Is In Effect'),
|
2015-01-21 13:06:32 +01:00
|
|
|
'host_display_name' => $this->translate('Host'),
|
|
|
|
'service_display_name' => $this->translate('Service'),
|
2015-01-21 10:33:05 +01:00
|
|
|
'downtime_entry_time' => $this->translate('Entry Time'),
|
|
|
|
'downtime_author' => $this->translate('Author'),
|
|
|
|
'downtime_start' => $this->translate('Start Time'),
|
|
|
|
'downtime_end' => $this->translate('End Time'),
|
|
|
|
'downtime_scheduled_start' => $this->translate('Scheduled Start'),
|
|
|
|
'downtime_scheduled_end' => $this->translate('Scheduled End'),
|
|
|
|
'downtime_duration' => $this->translate('Duration')
|
2015-05-12 10:16:51 +02:00
|
|
|
), $query);
|
2014-11-06 13:22:38 +01:00
|
|
|
|
2015-01-23 09:16:30 +01:00
|
|
|
if ($this->Auth()->hasPermission('monitoring/command/downtime/delete')) {
|
|
|
|
$this->view->delDowntimeForm = new DeleteDowntimeCommandForm();
|
2015-05-07 16:20:59 +02:00
|
|
|
$this->view->delDowntimeForm->handleRequest();
|
2015-01-23 09:16:30 +01:00
|
|
|
}
|
2013-07-30 17:17:19 +02:00
|
|
|
}
|
|
|
|
|
2013-08-14 12:42:32 +02:00
|
|
|
/**
|
2013-08-09 11:23:42 +02:00
|
|
|
* Display notification overview
|
2013-08-14 12:42:32 +02:00
|
|
|
*/
|
2013-08-09 11:23:42 +02:00
|
|
|
public function notificationsAction()
|
|
|
|
{
|
2015-02-23 17:00:30 +01:00
|
|
|
$this->addTitleTab(
|
|
|
|
'notifications',
|
|
|
|
$this->translate('Notifications'),
|
|
|
|
$this->translate('List notifications')
|
|
|
|
);
|
2014-05-09 18:01:47 +02:00
|
|
|
$this->setAutorefreshInterval(15);
|
2015-04-17 16:13:36 +02:00
|
|
|
|
2014-06-20 19:12:10 +02:00
|
|
|
$query = $this->backend->select()->from('notification', array(
|
2015-04-13 15:24:15 +02:00
|
|
|
'host_name',
|
2015-04-13 15:25:10 +02:00
|
|
|
'service_description',
|
2014-06-20 19:12:10 +02:00
|
|
|
'notification_output',
|
2015-04-13 15:26:06 +02:00
|
|
|
'notification_contact_name',
|
2014-06-20 19:12:10 +02:00
|
|
|
'notification_start_time',
|
2015-01-21 15:48:04 +01:00
|
|
|
'notification_state',
|
|
|
|
'host_display_name',
|
|
|
|
'service_display_name'
|
2014-06-20 19:12:10 +02:00
|
|
|
));
|
2014-11-16 00:20:12 +01:00
|
|
|
$this->filterQuery($query);
|
2015-05-15 14:32:58 +02:00
|
|
|
$this->view->notifications = $query;
|
2015-04-17 16:13:36 +02:00
|
|
|
|
|
|
|
$this->setupLimitControl();
|
|
|
|
$this->setupPaginationControl($this->view->notifications);
|
2015-05-15 10:56:52 +02:00
|
|
|
$this->setupSortControl(array(
|
|
|
|
'notification_start_time' => $this->translate('Notification Start')
|
|
|
|
), $query);
|
2013-10-04 10:09:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function contactsAction()
|
|
|
|
{
|
2015-02-23 17:00:30 +01:00
|
|
|
$this->addTitleTab('contacts', $this->translate('Contacts'), $this->translate('List contacts'));
|
2015-04-17 16:13:56 +02:00
|
|
|
|
2014-06-06 09:37:37 +02:00
|
|
|
$query = $this->backend->select()->from('contact', array(
|
|
|
|
'contact_name',
|
|
|
|
'contact_id',
|
2015-04-10 12:23:35 +02:00
|
|
|
'contact_alias',
|
|
|
|
'contact_email',
|
2014-06-06 09:37:37 +02:00
|
|
|
'contact_pager',
|
|
|
|
'contact_notify_service_timeperiod',
|
|
|
|
'contact_notify_service_recovery',
|
|
|
|
'contact_notify_service_warning',
|
|
|
|
'contact_notify_service_critical',
|
|
|
|
'contact_notify_service_unknown',
|
|
|
|
'contact_notify_service_flapping',
|
|
|
|
'contact_notify_service_downtime',
|
|
|
|
'contact_notify_host_timeperiod',
|
|
|
|
'contact_notify_host_recovery',
|
|
|
|
'contact_notify_host_down',
|
|
|
|
'contact_notify_host_unreachable',
|
|
|
|
'contact_notify_host_flapping',
|
2015-04-10 12:23:35 +02:00
|
|
|
'contact_notify_host_downtime',
|
2014-06-06 09:37:37 +02:00
|
|
|
));
|
2014-11-16 00:20:12 +01:00
|
|
|
$this->filterQuery($query);
|
2015-05-15 14:32:58 +02:00
|
|
|
$this->view->contacts = $query;
|
2015-05-15 10:56:52 +02:00
|
|
|
|
|
|
|
$this->setupLimitControl();
|
|
|
|
$this->setupPaginationControl($this->view->contacts);
|
2013-10-04 10:09:00 +02:00
|
|
|
$this->setupSortControl(array(
|
2015-04-10 12:23:35 +02:00
|
|
|
'contact_name' => $this->translate('Name'),
|
|
|
|
'contact_alias' => $this->translate('Alias'),
|
|
|
|
'contact_email' => $this->translate('Email'),
|
|
|
|
'contact_pager' => $this->translate('Pager Address / Number'),
|
2014-09-29 15:20:19 +02:00
|
|
|
'contact_notify_service_timeperiod' => $this->translate('Service Notification Timeperiod'),
|
2015-04-10 12:23:35 +02:00
|
|
|
'contact_notify_host_timeperiod' => $this->translate('Host Notification Timeperiod')
|
2015-05-12 10:16:51 +02:00
|
|
|
), $query);
|
2013-10-04 10:09:00 +02:00
|
|
|
}
|
|
|
|
|
2014-11-13 18:38:42 +01:00
|
|
|
public function eventgridAction()
|
2014-02-21 11:44:03 +01:00
|
|
|
{
|
2015-02-23 17:00:30 +01:00
|
|
|
$this->addTitleTab('eventgrid', $this->translate('Event Grid'), $this->translate('Show the Event Grid'));
|
2014-09-16 15:58:24 +02:00
|
|
|
|
2014-09-17 18:21:32 +02:00
|
|
|
$form = new StatehistoryForm();
|
|
|
|
$form->setEnctype(Zend_Form::ENCTYPE_URLENCODED);
|
|
|
|
$form->setMethod('get');
|
|
|
|
$form->setTokenDisabled();
|
2014-09-30 11:34:04 +02:00
|
|
|
$form->setUidDisabled();
|
|
|
|
$form->render();
|
2014-09-17 18:21:32 +02:00
|
|
|
$this->view->form = $form;
|
|
|
|
|
2015-03-02 12:27:27 +01:00
|
|
|
$this->params->remove('view');
|
2014-11-13 18:40:13 +01:00
|
|
|
$orientation = $this->params->shift('vertical', 0) ? 'vertical' : 'horizontal';
|
2014-11-16 00:37:58 +01:00
|
|
|
/*
|
2014-09-16 15:58:24 +02:00
|
|
|
$orientationBox = new SelectBox(
|
|
|
|
'orientation',
|
|
|
|
array(
|
2014-10-21 17:22:16 +02:00
|
|
|
'0' => mt('monitoring', 'Vertical'),
|
|
|
|
'1' => mt('monitoring', 'Horizontal')
|
2014-09-16 15:58:24 +02:00
|
|
|
),
|
2014-10-21 17:22:16 +02:00
|
|
|
mt('monitoring', 'Orientation'),
|
2014-09-16 15:58:24 +02:00
|
|
|
'horizontal'
|
|
|
|
);
|
|
|
|
$orientationBox->applyRequest($this->getRequest());
|
2014-11-16 00:37:58 +01:00
|
|
|
*/
|
2014-06-06 09:37:37 +02:00
|
|
|
$query = $this->backend->select()->from(
|
2014-11-13 18:38:42 +01:00
|
|
|
'eventgrid',
|
2014-09-17 18:21:32 +02:00
|
|
|
array('day', $form->getValue('state'))
|
2014-09-16 15:58:24 +02:00
|
|
|
);
|
2014-09-30 11:34:04 +02:00
|
|
|
$this->params->remove(array('objecttype', 'from', 'to', 'state', 'btn_submit'));
|
2014-11-19 12:07:40 +01:00
|
|
|
$this->view->filter = Filter::fromQuerystring((string) $this->params);
|
|
|
|
$query->applyFilter($this->view->filter);
|
2014-09-17 18:21:32 +02:00
|
|
|
$this->view->summary = $query->getQuery()->fetchAll();
|
|
|
|
$this->view->column = $form->getValue('state');
|
2014-11-16 00:37:58 +01:00
|
|
|
// $this->view->orientationBox = $orientationBox;
|
2014-09-16 15:58:24 +02:00
|
|
|
$this->view->orientation = $orientation;
|
2014-02-21 11:44:03 +01:00
|
|
|
}
|
|
|
|
|
2013-10-04 10:09:00 +02:00
|
|
|
public function contactgroupsAction()
|
|
|
|
{
|
2015-02-23 17:00:30 +01:00
|
|
|
$this->addTitleTab(
|
|
|
|
'contactgroups',
|
|
|
|
$this->translate('Contact Groups'),
|
|
|
|
$this->translate('List contact groups')
|
|
|
|
);
|
2015-04-17 16:14:13 +02:00
|
|
|
|
2014-06-06 09:37:37 +02:00
|
|
|
$query = $this->backend->select()->from('contactgroup', array(
|
|
|
|
'contactgroup_name',
|
|
|
|
'contactgroup_alias',
|
|
|
|
'contact_name',
|
|
|
|
'contact_alias',
|
|
|
|
'contact_email',
|
|
|
|
'contact_pager',
|
2015-04-17 16:14:13 +02:00
|
|
|
));
|
2014-11-16 00:20:12 +01:00
|
|
|
$this->filterQuery($query);
|
2014-06-06 09:37:37 +02:00
|
|
|
|
|
|
|
// Fetch and prepare all contact groups:
|
|
|
|
$contactgroups = $query->getQuery()->fetchAll();
|
2014-03-07 10:35:11 +01:00
|
|
|
$groupData = array();
|
|
|
|
foreach ($contactgroups as $c) {
|
|
|
|
if (!array_key_exists($c->contactgroup_name, $groupData)) {
|
|
|
|
$groupData[$c->contactgroup_name] = array(
|
|
|
|
'alias' => $c->contactgroup_alias,
|
|
|
|
'contacts' => array()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
$groupData[$c->contactgroup_name]['contacts'][] = $c;
|
|
|
|
}
|
2014-06-06 09:37:37 +02:00
|
|
|
// TODO: Find a better naming
|
2014-03-07 10:35:11 +01:00
|
|
|
$this->view->groupData = $groupData;
|
2015-05-15 10:56:52 +02:00
|
|
|
|
|
|
|
$this->setupSortControl(array(
|
|
|
|
'contactgroup_name' => $this->translate('Contactgroup Name'),
|
|
|
|
'contactgroup_alias' => $this->translate('Contactgroup Alias')
|
|
|
|
), $query);
|
2013-07-12 14:33:17 +02:00
|
|
|
}
|
|
|
|
|
2013-09-26 17:02:56 +02:00
|
|
|
public function commentsAction()
|
|
|
|
{
|
2015-02-23 17:00:30 +01:00
|
|
|
$this->addTitleTab('comments', $this->translate('Comments'), $this->translate('List comments'));
|
2014-03-09 19:31:59 +01:00
|
|
|
$this->setAutorefreshInterval(12);
|
2015-04-17 16:14:29 +02:00
|
|
|
|
2014-06-06 09:37:37 +02:00
|
|
|
$query = $this->backend->select()->from('comment', array(
|
|
|
|
'id' => 'comment_internal_id',
|
|
|
|
'objecttype' => 'comment_objecttype',
|
|
|
|
'comment' => 'comment_data',
|
2015-04-09 13:07:50 +02:00
|
|
|
'author' => 'comment_author_name',
|
2014-06-06 09:37:37 +02:00
|
|
|
'timestamp' => 'comment_timestamp',
|
|
|
|
'type' => 'comment_type',
|
|
|
|
'persistent' => 'comment_is_persistent',
|
|
|
|
'expiration' => 'comment_expiration',
|
2015-04-09 12:49:06 +02:00
|
|
|
'host_name',
|
|
|
|
'service_description',
|
2015-01-21 16:10:02 +01:00
|
|
|
'host_display_name',
|
|
|
|
'service_display_name'
|
2014-06-06 09:37:37 +02:00
|
|
|
));
|
2014-11-16 00:20:12 +01:00
|
|
|
$this->filterQuery($query);
|
2015-05-15 14:32:58 +02:00
|
|
|
$this->view->comments = $query;
|
2015-05-15 10:56:52 +02:00
|
|
|
|
|
|
|
$this->setupLimitControl();
|
|
|
|
$this->setupPaginationControl($this->view->comments);
|
2013-09-26 17:02:56 +02:00
|
|
|
$this->setupSortControl(
|
|
|
|
array(
|
2015-01-21 16:15:38 +01:00
|
|
|
'comment_timestamp' => $this->translate('Comment Timestamp'),
|
|
|
|
'host_display_name' => $this->translate('Host'),
|
|
|
|
'service_display_name' => $this->translate('Service'),
|
|
|
|
'comment_type' => $this->translate('Comment Type'),
|
|
|
|
'comment_expiration' => $this->translate('Expiration')
|
2015-05-12 10:16:51 +02:00
|
|
|
),
|
|
|
|
$query
|
2013-09-26 17:02:56 +02:00
|
|
|
);
|
2015-01-23 09:18:29 +01:00
|
|
|
|
|
|
|
if ($this->Auth()->hasPermission('monitoring/command/comment/delete')) {
|
2015-05-07 16:20:59 +02:00
|
|
|
$this->view->delCommentForm = new DeleteCommentCommandForm();
|
|
|
|
$this->view->delCommentForm->handleRequest();
|
2015-01-23 09:18:29 +01:00
|
|
|
}
|
2013-09-26 17:02:56 +02:00
|
|
|
}
|
|
|
|
|
2013-10-15 12:49:58 +02:00
|
|
|
public function servicegroupsAction()
|
|
|
|
{
|
2015-02-23 17:00:30 +01:00
|
|
|
$this->addTitleTab(
|
|
|
|
'servicegroups',
|
|
|
|
$this->translate('Service Groups'),
|
|
|
|
$this->translate('List service groups')
|
|
|
|
);
|
2014-06-06 09:37:37 +02:00
|
|
|
$this->setAutorefreshInterval(12);
|
2015-04-17 16:14:46 +02:00
|
|
|
|
2014-06-06 09:37:37 +02:00
|
|
|
$query = $this->backend->select()->from('groupsummary', array(
|
2015-04-10 16:28:57 +02:00
|
|
|
'servicegroup_name',
|
2015-01-23 11:23:59 +01:00
|
|
|
'servicegroup_alias',
|
2014-06-06 09:37:37 +02:00
|
|
|
'hosts_up',
|
|
|
|
'hosts_unreachable_handled',
|
|
|
|
'hosts_unreachable_unhandled',
|
|
|
|
'hosts_down_handled',
|
|
|
|
'hosts_down_unhandled',
|
|
|
|
'hosts_pending',
|
|
|
|
'services_ok',
|
|
|
|
'services_unknown_handled',
|
|
|
|
'services_unknown_unhandled',
|
|
|
|
'services_critical_handled',
|
|
|
|
'services_critical_unhandled',
|
|
|
|
'services_warning_handled',
|
|
|
|
'services_warning_unhandled',
|
2014-11-19 11:52:23 +01:00
|
|
|
'services_pending',
|
|
|
|
'services_ok_last_state_change',
|
|
|
|
'services_pending_last_state_change',
|
|
|
|
'services_warning_last_state_change_handled',
|
|
|
|
'services_critical_last_state_change_handled',
|
|
|
|
'services_unknown_last_state_change_handled',
|
|
|
|
'services_warning_last_state_change_unhandled',
|
|
|
|
'services_critical_last_state_change_unhandled',
|
|
|
|
'services_unknown_last_state_change_unhandled',
|
|
|
|
'services_total'
|
2015-01-23 15:46:51 +01:00
|
|
|
))->order('services_severity')->order('servicegroup_alias');
|
|
|
|
// TODO(el): Can't default to the sort rules of the data view because it's meant for both host groups and
|
|
|
|
// service groups. We should separate them.
|
2014-11-16 00:20:12 +01:00
|
|
|
$this->filterQuery($query);
|
2015-05-15 14:32:58 +02:00
|
|
|
$this->view->servicegroups = $query;
|
2015-05-15 10:56:52 +02:00
|
|
|
|
|
|
|
$this->setupLimitControl();
|
|
|
|
$this->setupPaginationControl($this->view->servicegroups);
|
2013-10-15 14:55:01 +02:00
|
|
|
$this->setupSortControl(array(
|
2015-01-23 15:46:51 +01:00
|
|
|
'services_severity' => $this->translate('Severity'),
|
|
|
|
'servicegroup_alias' => $this->translate('Service Group Name'),
|
|
|
|
'services_total' => $this->translate('Total Services'),
|
|
|
|
'services_ok' => $this->translate('Services OK'),
|
|
|
|
'services_unknown' => $this->translate('Services UNKNOWN'),
|
|
|
|
'services_critical' => $this->translate('Services CRITICAL'),
|
|
|
|
'services_warning' => $this->translate('Services WARNING'),
|
|
|
|
'services_pending' => $this->translate('Services PENDING')
|
2015-05-12 10:16:51 +02:00
|
|
|
), $query);
|
2013-10-15 12:49:58 +02:00
|
|
|
}
|
|
|
|
|
2013-10-15 15:12:59 +02:00
|
|
|
public function hostgroupsAction()
|
|
|
|
{
|
2015-02-23 17:00:30 +01:00
|
|
|
$this->addTitleTab('hostgroups', $this->translate('Host Groups'), $this->translate('List host groups'));
|
2014-06-06 09:37:37 +02:00
|
|
|
$this->setAutorefreshInterval(12);
|
2015-04-17 16:14:59 +02:00
|
|
|
|
2014-06-06 09:37:37 +02:00
|
|
|
$query = $this->backend->select()->from('groupsummary', array(
|
2015-04-10 16:28:33 +02:00
|
|
|
'hostgroup_name',
|
2015-01-23 11:22:00 +01:00
|
|
|
'hostgroup_alias',
|
2014-06-06 09:37:37 +02:00
|
|
|
'hosts_up',
|
|
|
|
'hosts_unreachable_handled',
|
|
|
|
'hosts_unreachable_unhandled',
|
|
|
|
'hosts_down_handled',
|
|
|
|
'hosts_down_unhandled',
|
|
|
|
'hosts_pending',
|
2015-05-13 16:31:25 +02:00
|
|
|
'hosts_up_last_state_change',
|
|
|
|
'hosts_pending_last_state_change',
|
|
|
|
'hosts_down_last_state_change_handled',
|
|
|
|
'hosts_unreachable_last_state_change_handled',
|
|
|
|
'hosts_down_last_state_change_unhandled',
|
|
|
|
'hosts_unreachable_last_state_change_unhandled',
|
2014-06-06 09:37:37 +02:00
|
|
|
'services_ok',
|
|
|
|
'services_unknown_handled',
|
|
|
|
'services_unknown_unhandled',
|
|
|
|
'services_critical_handled',
|
|
|
|
'services_critical_unhandled',
|
|
|
|
'services_warning_handled',
|
|
|
|
'services_warning_unhandled',
|
2014-11-19 11:52:23 +01:00
|
|
|
'services_pending',
|
|
|
|
'services_ok_last_state_change',
|
|
|
|
'services_pending_last_state_change',
|
|
|
|
'services_warning_last_state_change_handled',
|
|
|
|
'services_critical_last_state_change_handled',
|
|
|
|
'services_unknown_last_state_change_handled',
|
|
|
|
'services_warning_last_state_change_unhandled',
|
|
|
|
'services_critical_last_state_change_unhandled',
|
|
|
|
'services_unknown_last_state_change_unhandled',
|
|
|
|
'services_total'
|
2015-01-23 15:46:51 +01:00
|
|
|
))->order('services_severity')->order('hostgroup_alias');
|
|
|
|
// TODO(el): Can't default to the sort rules of the data view because it's meant for both host groups and
|
|
|
|
// service groups. We should separate them.
|
2014-11-16 00:20:12 +01:00
|
|
|
$this->filterQuery($query);
|
2015-05-15 14:32:58 +02:00
|
|
|
$this->view->hostgroups = $query;
|
2015-05-15 10:56:52 +02:00
|
|
|
|
|
|
|
$this->setupLimitControl();
|
|
|
|
$this->setupPaginationControl($this->view->hostgroups);
|
2013-10-15 15:12:59 +02:00
|
|
|
$this->setupSortControl(array(
|
2014-11-20 12:49:10 +01:00
|
|
|
'services_severity' => $this->translate('Severity'),
|
2015-01-23 15:46:51 +01:00
|
|
|
'hostgroup_alias' => $this->translate('Host Group Name'),
|
2014-11-20 12:49:10 +01:00
|
|
|
'services_total' => $this->translate('Total Services'),
|
|
|
|
'services_ok' => $this->translate('Services OK'),
|
|
|
|
'services_unknown' => $this->translate('Services UNKNOWN'),
|
|
|
|
'services_critical' => $this->translate('Services CRITICAL'),
|
|
|
|
'services_warning' => $this->translate('Services WARNING'),
|
|
|
|
'services_pending' => $this->translate('Services PENDING')
|
2015-05-12 10:16:51 +02:00
|
|
|
), $query);
|
2013-10-15 15:12:59 +02:00
|
|
|
}
|
|
|
|
|
2013-10-14 12:56:06 +02:00
|
|
|
public function eventhistoryAction()
|
|
|
|
{
|
2015-02-23 17:00:30 +01:00
|
|
|
$this->addTitleTab(
|
|
|
|
'eventhistory',
|
|
|
|
$this->translate('Event Overview'),
|
|
|
|
$this->translate('List event records')
|
|
|
|
);
|
2014-09-26 14:59:06 +02:00
|
|
|
|
2014-06-06 09:37:37 +02:00
|
|
|
$query = $this->backend->select()->from('eventHistory', array(
|
|
|
|
'host_name',
|
2015-01-21 09:55:17 +01:00
|
|
|
'host_display_name',
|
2014-06-06 09:37:37 +02:00
|
|
|
'service_description',
|
2015-01-21 09:55:17 +01:00
|
|
|
'service_display_name',
|
2014-06-06 09:37:37 +02:00
|
|
|
'object_type',
|
|
|
|
'timestamp',
|
|
|
|
'state',
|
|
|
|
'attempt',
|
|
|
|
'max_attempts',
|
|
|
|
'output',
|
2015-04-09 14:17:27 +02:00
|
|
|
'type'
|
2014-06-06 09:37:37 +02:00
|
|
|
));
|
2014-11-20 17:19:26 +01:00
|
|
|
|
2014-11-26 16:07:33 +01:00
|
|
|
$this->filterQuery($query);
|
2015-05-15 14:32:58 +02:00
|
|
|
$this->view->history = $query;
|
2014-12-01 13:45:25 +01:00
|
|
|
|
2015-04-17 16:15:58 +02:00
|
|
|
$this->setupLimitControl();
|
|
|
|
$this->setupPaginationControl($this->view->history);
|
2015-05-15 10:56:52 +02:00
|
|
|
$this->setupSortControl(array(
|
|
|
|
'timestamp' => $this->translate('Occurence')
|
|
|
|
), $query);
|
2013-10-14 12:56:06 +02:00
|
|
|
}
|
|
|
|
|
2014-11-12 15:06:48 +01:00
|
|
|
public function servicegridAction()
|
2014-03-12 14:41:17 +01:00
|
|
|
{
|
2015-02-23 17:00:30 +01:00
|
|
|
$this->addTitleTab('servicegrid', $this->translate('Service Grid'), $this->translate('Show the Service Grid'));
|
2014-06-06 09:37:37 +02:00
|
|
|
$this->setAutorefreshInterval(15);
|
2014-09-05 17:38:02 +02:00
|
|
|
$query = $this->backend->select()->from('serviceStatus', array(
|
2014-06-06 09:37:37 +02:00
|
|
|
'host_name',
|
|
|
|
'service_description',
|
|
|
|
'service_state',
|
|
|
|
'service_output',
|
|
|
|
'service_handled'
|
|
|
|
));
|
2014-11-16 00:20:12 +01:00
|
|
|
$this->filterQuery($query);
|
2014-06-06 09:37:37 +02:00
|
|
|
$this->setupSortControl(array(
|
2014-09-29 15:20:19 +02:00
|
|
|
'host_name' => $this->translate('Hostname'),
|
|
|
|
'service_description' => $this->translate('Service description')
|
2015-05-12 10:16:51 +02:00
|
|
|
), $query);
|
2014-09-05 17:38:02 +02:00
|
|
|
$pivot = $query->pivot('service_description', 'host_name');
|
2014-06-06 09:37:37 +02:00
|
|
|
$this->view->pivot = $pivot;
|
|
|
|
$this->view->horizontalPaginator = $pivot->paginateXAxis();
|
|
|
|
$this->view->verticalPaginator = $pivot->paginateYAxis();
|
|
|
|
}
|
2014-03-12 14:41:17 +01:00
|
|
|
|
2014-11-15 23:53:06 +01:00
|
|
|
protected function filterQuery($query)
|
|
|
|
{
|
|
|
|
$editor = Widget::create('filterEditor')
|
|
|
|
->setQuery($query)
|
2015-04-30 17:25:14 +02:00
|
|
|
->preserveParams(
|
|
|
|
'limit', 'sort', 'dir', 'format', 'view', 'backend',
|
|
|
|
'stateType', 'addColumns', '_dev'
|
|
|
|
)
|
2014-11-23 20:07:30 +01:00
|
|
|
->ignoreParams('page')
|
2014-11-15 23:53:06 +01:00
|
|
|
->handleRequest($this->getRequest());
|
|
|
|
$query->applyFilter($editor->getFilter());
|
|
|
|
|
2015-04-17 16:21:14 +02:00
|
|
|
$this->setupFilterControl($editor);
|
2014-11-16 00:20:12 +01:00
|
|
|
$this->view->filter = $editor->getFilter();
|
2014-11-15 23:53:06 +01:00
|
|
|
|
2014-06-06 09:37:37 +02:00
|
|
|
$this->handleFormatRequest($query);
|
|
|
|
return $query;
|
2014-03-12 14:41:17 +01:00
|
|
|
}
|
|
|
|
|
2015-05-19 10:11:54 +02:00
|
|
|
/**
|
|
|
|
* Get columns to be added from URL parameter 'addColumns'
|
|
|
|
* and assign to $this->view->addColumns (as array)
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
2015-05-18 16:29:33 +02:00
|
|
|
protected function addColumns()
|
2014-03-21 11:24:17 +01:00
|
|
|
{
|
2014-06-06 09:37:37 +02:00
|
|
|
$columns = preg_split(
|
|
|
|
'~,~',
|
2015-03-13 09:07:02 +01:00
|
|
|
$this->params->shift('addColumns', ''),
|
2014-06-06 09:37:37 +02:00
|
|
|
-1,
|
|
|
|
PREG_SPLIT_NO_EMPTY
|
|
|
|
);
|
2015-05-18 16:29:33 +02:00
|
|
|
$this->view->addColumns = $columns;
|
2014-06-06 09:37:37 +02:00
|
|
|
return $columns;
|
2014-03-21 11:24:17 +01:00
|
|
|
}
|
|
|
|
|
2015-02-23 17:00:30 +01:00
|
|
|
protected function addTitleTab($action, $title, $tip)
|
2014-02-21 11:41:05 +01:00
|
|
|
{
|
|
|
|
$this->getTabs()->add($action, array(
|
2015-02-23 17:00:30 +01:00
|
|
|
'title' => $tip,
|
|
|
|
'label' => $title,
|
|
|
|
'url' => Url::fromRequest()
|
2014-02-21 11:41:05 +01:00
|
|
|
))->activate($action);
|
2014-06-06 09:37:37 +02:00
|
|
|
$this->view->title = $title;
|
2014-02-21 11:41:05 +01:00
|
|
|
}
|
|
|
|
|
2013-09-03 18:43:17 +02:00
|
|
|
/**
|
|
|
|
* Return all tabs for this controller
|
|
|
|
*
|
|
|
|
* @return Tabs
|
|
|
|
*/
|
|
|
|
private function createTabs()
|
|
|
|
{
|
2015-04-20 14:59:32 +02:00
|
|
|
$this->getTabs()->extend(new OutputFormat())->extend(new DashboardAction());
|
2013-07-30 17:17:19 +02:00
|
|
|
}
|
2013-06-27 10:14:41 +02:00
|
|
|
}
|