2013-06-27 10:14:41 +02:00
|
|
|
<?php
|
2013-08-14 12:42:32 +02:00
|
|
|
// @codingStandardsIgnoreStart
|
|
|
|
// {{{ICINGA_LICENSE_HEADER}}}
|
|
|
|
/**
|
2013-10-23 15:10:33 +02:00
|
|
|
* This file is part of Icinga Web 2.
|
2013-08-14 12:42:32 +02:00
|
|
|
*
|
2013-10-23 15:10:33 +02:00
|
|
|
* Icinga Web 2 - Head for multiple monitoring backends.
|
2013-08-14 12:42:32 +02:00
|
|
|
* 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.
|
|
|
|
*
|
2013-10-23 15:10:33 +02:00
|
|
|
* @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>
|
|
|
|
*
|
2013-08-14 12:42:32 +02:00
|
|
|
*/
|
|
|
|
// {{{ICINGA_LICENSE_HEADER}}}
|
2013-08-20 11:44:05 +02:00
|
|
|
|
2013-10-09 16:38:46 +02:00
|
|
|
use Icinga\Application\Benchmark;
|
|
|
|
use Icinga\Data\Db\Query;
|
2014-03-08 18:49:31 +01:00
|
|
|
use Icinga\Module\Monitoring\Controller;
|
2013-10-09 16:38:46 +02:00
|
|
|
use Icinga\Web\Hook;
|
|
|
|
use Icinga\Web\Widget\Tabextension\DashboardAction;
|
|
|
|
use Icinga\Web\Widget\Tabextension\OutputFormat;
|
|
|
|
use Icinga\Web\Widget\Tabs;
|
|
|
|
use Icinga\Module\Monitoring\Backend;
|
|
|
|
use Icinga\Web\Widget\SortBox;
|
2013-10-14 13:25:25 +02:00
|
|
|
use Icinga\Web\Widget\FilterBox;
|
2014-03-05 20:12:45 +01:00
|
|
|
use Icinga\Web\Widget\Chart\HistoryColorGrid;
|
2013-10-09 16:38:46 +02:00
|
|
|
use Icinga\Application\Config as IcingaConfig;
|
2013-06-27 10:14:41 +02:00
|
|
|
|
2013-10-14 13:25:25 +02:00
|
|
|
use Icinga\Module\Monitoring\DataView\DataView;
|
2014-03-08 18:49:31 +01:00
|
|
|
// TODO: Naming! There WAS a reason they used to carry 'View' in their name
|
2013-09-24 15:26:10 +02:00
|
|
|
use Icinga\Module\Monitoring\DataView\Notification as NotificationView;
|
|
|
|
use Icinga\Module\Monitoring\DataView\Downtime as DowntimeView;
|
2013-10-04 10:09:00 +02:00
|
|
|
use Icinga\Module\Monitoring\DataView\Contact as ContactView;
|
|
|
|
use Icinga\Module\Monitoring\DataView\Contactgroup as ContactgroupView;
|
2013-10-14 13:25:25 +02:00
|
|
|
use Icinga\Module\Monitoring\DataView\HostStatus as HostStatusView;
|
|
|
|
use Icinga\Module\Monitoring\DataView\ServiceStatus as ServiceStatusView;
|
2013-09-26 17:02:56 +02:00
|
|
|
use Icinga\Module\Monitoring\DataView\Comment as CommentView;
|
2013-10-15 12:49:58 +02:00
|
|
|
use Icinga\Module\Monitoring\DataView\Groupsummary as GroupsummaryView;
|
2013-10-14 12:56:06 +02:00
|
|
|
use Icinga\Module\Monitoring\DataView\EventHistory as EventHistoryView;
|
2014-02-21 11:44:03 +01:00
|
|
|
use Icinga\Module\Monitoring\DataView\StateHistorySummary;
|
2013-10-14 13:25:25 +02:00
|
|
|
use Icinga\Module\Monitoring\Filter\UrlViewFilter;
|
2013-10-17 19:48:46 +02:00
|
|
|
use Icinga\Module\Monitoring\DataView\ServiceStatus;
|
2013-10-14 13:25:25 +02:00
|
|
|
use Icinga\Filter\Filterable;
|
2014-02-18 20:00:18 +01:00
|
|
|
use Icinga\Web\Url;
|
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
|
|
|
/**
|
|
|
|
* The backend used for this controller
|
|
|
|
*
|
2013-08-20 15:45:44 +02:00
|
|
|
* @var Backend
|
2013-08-14 12:42:32 +02:00
|
|
|
*/
|
2013-06-27 10:14:41 +02:00
|
|
|
protected $backend;
|
2013-08-14 12:42:32 +02:00
|
|
|
/**
|
|
|
|
* Retrieve backend and hooks for this controller
|
|
|
|
*
|
|
|
|
* @see ActionController::init
|
|
|
|
*/
|
2013-06-27 10:14:41 +02:00
|
|
|
public function init()
|
|
|
|
{
|
2013-09-24 15:26:10 +02:00
|
|
|
$this->backend = Backend::createBackend($this->_getParam('backend'));
|
2013-06-27 10:14:41 +02:00
|
|
|
$this->view->grapher = Hook::get('grapher');
|
2013-08-08 16:22:22 +02:00
|
|
|
$this->createTabs();
|
2013-09-11 17:19:18 +02:00
|
|
|
$this->view->activeRowHref = $this->getParam('detail');
|
2014-03-04 13:33:02 +01:00
|
|
|
$this->view->compact = ($this->_request->getParam('view') === 'compact');
|
2013-06-27 10:14:41 +02:00
|
|
|
}
|
|
|
|
|
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-02-18 20:00:18 +01:00
|
|
|
$this->getTabs()->add('hosts', array(
|
|
|
|
'title' => 'Hosts Status',
|
|
|
|
'url' => Url::fromPath('monitoring/list/hosts')
|
|
|
|
))->activate('hosts');
|
2013-10-14 13:25:25 +02:00
|
|
|
|
2014-03-04 13:33:02 +01:00
|
|
|
$this->setAutorefreshInterval(10);
|
2014-02-18 20:00:18 +01:00
|
|
|
$this->view->title = 'Host Status';
|
2013-09-24 15:26:10 +02:00
|
|
|
$this->compactView = 'hosts-compact';
|
2013-10-14 13:25:25 +02:00
|
|
|
$dataview = HostStatusView::fromRequest(
|
2013-09-24 15:26:10 +02:00
|
|
|
$this->_request,
|
2013-07-12 13:53:11 +02:00
|
|
|
array(
|
|
|
|
'host_icon_image',
|
|
|
|
'host_name',
|
|
|
|
'host_state',
|
|
|
|
'host_address',
|
|
|
|
'host_acknowledged',
|
|
|
|
'host_output',
|
2014-02-18 20:00:18 +01:00
|
|
|
// 'host_long_output',
|
2013-07-12 13:53:11 +02:00
|
|
|
'host_in_downtime',
|
2013-07-12 15:14:55 +02:00
|
|
|
'host_is_flapping',
|
|
|
|
'host_state_type',
|
2013-07-12 13:53:11 +02:00
|
|
|
'host_handled',
|
2013-07-19 11:29:51 +02:00
|
|
|
'host_last_check',
|
2013-07-12 13:53:11 +02:00
|
|
|
'host_last_state_change',
|
2013-07-12 15:14:55 +02:00
|
|
|
'host_notifications_enabled',
|
2014-02-18 20:00:18 +01:00
|
|
|
// 'host_unhandled_service_count',
|
2013-07-15 13:21:48 +02:00
|
|
|
'host_action_url',
|
|
|
|
'host_notes_url',
|
2014-02-18 20:00:18 +01:00
|
|
|
// 'host_last_comment',
|
2013-09-26 16:29:48 +02:00
|
|
|
'host_active_checks_enabled',
|
2013-10-09 11:48:42 +02:00
|
|
|
'host_passive_checks_enabled',
|
|
|
|
'host_current_check_attempt',
|
|
|
|
'host_max_check_attempts'
|
2013-07-12 13:53:11 +02:00
|
|
|
)
|
2013-10-14 13:25:25 +02:00
|
|
|
);
|
|
|
|
$query = $dataview->getQuery();
|
2014-01-22 14:34:39 +01:00
|
|
|
$this->applyRestrictions($query);
|
|
|
|
|
2013-10-17 19:48:46 +02:00
|
|
|
$this->setupFilterControl($dataview, 'host');
|
|
|
|
|
2013-09-03 18:43:17 +02:00
|
|
|
$this->setupSortControl(array(
|
|
|
|
'host_last_check' => 'Last Host Check',
|
|
|
|
'host_severity' => 'Host Severity',
|
|
|
|
'host_state' => 'Current Host State',
|
|
|
|
'host_name' => 'Host Name',
|
|
|
|
'host_address' => 'Address',
|
|
|
|
'host_state' => 'Hard State'
|
|
|
|
));
|
2013-09-24 15:26:10 +02:00
|
|
|
$this->handleFormatRequest($query);
|
2013-10-14 13:25:25 +02:00
|
|
|
$this->view->hosts = $query->paginate();
|
2014-02-18 20:00:18 +01:00
|
|
|
|
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-02-18 20:00:18 +01:00
|
|
|
$this->getTabs()->add('services', array(
|
|
|
|
'title' => 'Services Status',
|
|
|
|
'url' => Url::fromPath('monitoring/list/services')
|
|
|
|
))->activate('services');
|
2014-03-08 01:00:21 +01:00
|
|
|
$this->view->showHost = true;
|
|
|
|
if ($host = $this->_getParam('host')) {
|
|
|
|
if (strpos($host, '*') === false) {
|
|
|
|
$this->view->showHost = false;
|
|
|
|
}
|
|
|
|
}
|
2014-02-18 20:00:18 +01:00
|
|
|
$this->view->title = 'Service Status';
|
2014-03-04 13:33:02 +01:00
|
|
|
$this->setAutorefreshInterval(10);
|
2014-01-22 14:34:39 +01:00
|
|
|
$query = $this->fetchServices();
|
|
|
|
$this->applyRestrictions($query);
|
|
|
|
$this->view->services = $query->paginate();
|
2013-10-17 19:48:46 +02:00
|
|
|
|
2014-02-18 20:52:05 +01:00
|
|
|
//$this->setupFilterControl(ServiceStatus::fromRequest($this->getRequest()), 'service');
|
|
|
|
$this->setupFilterControl($query, 'service');
|
2013-09-03 18:43:17 +02:00
|
|
|
$this->setupSortControl(array(
|
|
|
|
'service_last_check' => 'Last Service Check',
|
|
|
|
'service_severity' => 'Severity',
|
|
|
|
'service_state' => 'Current Service State',
|
|
|
|
'service_description' => 'Service Name',
|
|
|
|
'service_state_type' => 'Hard State',
|
|
|
|
'host_severity' => 'Host Severity',
|
|
|
|
'host_state' => 'Current Host State',
|
|
|
|
'host_name' => 'Host Name',
|
|
|
|
'host_address' => 'Host Address',
|
|
|
|
'host_last_check' => 'Last Host Check'
|
2013-09-24 15:26:10 +02:00
|
|
|
));
|
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()
|
|
|
|
{
|
2014-02-18 20:00:18 +01:00
|
|
|
$this->getTabs()->add('downtimes', array(
|
|
|
|
'title' => 'Downtimes',
|
|
|
|
'url' => Url::fromPath('monitoring/list/downtimes')
|
|
|
|
))->activate('downtimes');
|
2014-03-09 21:58:01 +01:00
|
|
|
$this->setAutorefreshInterval(12);
|
|
|
|
$query = DowntimeView::fromRequest(
|
|
|
|
$this->_request,
|
|
|
|
array(
|
2014-03-09 22:32:40 +01:00
|
|
|
'id' => 'downtime_internal_id',
|
|
|
|
'objecttype' => 'downtime_objecttype',
|
|
|
|
'comment' => 'downtime_comment',
|
|
|
|
'author' => 'downtime_author',
|
|
|
|
'start' => 'downtime_start',
|
|
|
|
'scheduled_start' => 'downtime_scheduled_start',
|
|
|
|
'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',
|
|
|
|
'host' => 'downtime_host',
|
|
|
|
'service' => 'downtime_service'
|
2014-03-09 21:58:01 +01:00
|
|
|
)
|
2014-03-09 22:32:40 +01:00
|
|
|
)->getQuery()->order('downtime_is_in_effect', 'DESC')->order('downtime_scheduled_start', 'DESC');
|
2013-10-15 19:56:33 +02:00
|
|
|
|
2013-09-24 15:26:10 +02:00
|
|
|
$this->view->downtimes = $query->paginate();
|
2013-09-03 18:43:17 +02:00
|
|
|
$this->setupSortControl(array(
|
|
|
|
'downtime_is_in_effect' => 'Is In Effect',
|
2014-03-09 22:32:40 +01:00
|
|
|
'downtime_host' => 'Host / Service',
|
2013-09-03 18:43:17 +02:00
|
|
|
'downtime_entry_time' => 'Entry Time',
|
2014-03-09 22:32:40 +01:00
|
|
|
'downtime_author' => 'Author',
|
|
|
|
'downtime_start' => 'Start Time',
|
|
|
|
'downtime_start' => 'End Time',
|
2014-03-09 22:35:33 +01:00
|
|
|
'downtime_scheduled_start' => 'Scheduled Start',
|
|
|
|
'downtime_scheduled_end' => 'Scheduled End',
|
2013-09-03 18:43:17 +02:00
|
|
|
'downtime_duration' => 'Duration',
|
2013-09-24 15:26:10 +02:00
|
|
|
));
|
|
|
|
$this->handleFormatRequest($query);
|
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()
|
|
|
|
{
|
2014-02-21 11:42:03 +01:00
|
|
|
$this->addTitleTab('notifications');
|
2014-02-18 20:00:18 +01:00
|
|
|
|
2013-10-19 13:13:56 +02:00
|
|
|
$query = NotificationView::fromRequest($this->_request)->getQuery();
|
2013-09-24 15:26:10 +02:00
|
|
|
$this->view->notifications = $query->paginate();
|
2013-09-03 18:43:17 +02:00
|
|
|
$this->setupSortControl(array(
|
2013-10-04 10:09:00 +02:00
|
|
|
'notification_start_time' => 'Notification Start'
|
|
|
|
));
|
|
|
|
$this->handleFormatRequest($query);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function contactsAction()
|
|
|
|
{
|
2014-02-21 11:42:03 +01:00
|
|
|
$this->addTitleTab('contactgroups');
|
2013-10-04 10:09:00 +02:00
|
|
|
$query = ContactView::fromRequest(
|
|
|
|
$this->_request,
|
|
|
|
array(
|
|
|
|
'contact_name',
|
|
|
|
'contact_id',
|
|
|
|
'contact_alias',
|
|
|
|
'contact_email',
|
|
|
|
'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',
|
|
|
|
'contact_notify_host_downtime',
|
|
|
|
)
|
|
|
|
)->getQuery();
|
|
|
|
$this->view->contacts = $query->paginate();
|
|
|
|
$this->setupSortControl(array(
|
|
|
|
'contact_name' => 'Name',
|
|
|
|
'contact_alias' => 'Alias',
|
|
|
|
'contact_email' => 'Email',
|
|
|
|
'contact_pager' => 'Pager Address / Number',
|
|
|
|
'contact_notify_service_timeperiod' => 'Service Notification Timeperiod',
|
|
|
|
'contact_notify_host_timeperiod' => 'Host Notification Timeperiod'
|
|
|
|
));
|
|
|
|
$this->handleFormatRequest($query);
|
|
|
|
}
|
|
|
|
|
2014-02-21 11:44:03 +01:00
|
|
|
public function statehistorysummaryAction()
|
|
|
|
{
|
|
|
|
$this->addTitleTab('statehistorysummary');
|
2014-03-05 20:12:45 +01:00
|
|
|
$query = StateHistorySummary::fromRequest(
|
2014-03-06 11:30:52 +01:00
|
|
|
$this->_request, array('day', 'cnt_critical')
|
2014-03-05 20:12:45 +01:00
|
|
|
)->getQuery()->order('day');
|
2014-03-06 11:30:52 +01:00
|
|
|
$query->limit(365);
|
2014-02-21 11:44:03 +01:00
|
|
|
$this->view->summary = $query->fetchAll();
|
2014-03-05 20:12:45 +01:00
|
|
|
$this->view->grid = new HistoryColorGrid();
|
2014-02-21 11:44:03 +01:00
|
|
|
$this->handleFormatRequest($query);
|
|
|
|
}
|
|
|
|
|
2013-10-04 10:09:00 +02:00
|
|
|
public function contactgroupsAction()
|
|
|
|
{
|
2014-02-21 11:46:57 +01:00
|
|
|
$this->addTitleTab('contactgroups');
|
|
|
|
|
2014-03-07 10:35:11 +01:00
|
|
|
$query = ContactgroupView::fromRequest(
|
2013-10-04 10:09:00 +02:00
|
|
|
$this->_request,
|
|
|
|
array(
|
|
|
|
'contactgroup_name',
|
|
|
|
'contactgroup_alias',
|
2014-02-21 11:46:57 +01:00
|
|
|
'contact_name',
|
|
|
|
'contact_alias',
|
|
|
|
'contact_email',
|
|
|
|
'contact_pager',
|
2013-10-04 10:09:00 +02:00
|
|
|
)
|
2014-02-21 11:46:57 +01:00
|
|
|
)->getQuery()->order('contactgroup_alias');
|
2014-03-07 10:35:11 +01:00
|
|
|
$contactgroups = $query->fetchAll();
|
2013-07-12 14:33:17 +02:00
|
|
|
$this->handleFormatRequest($query);
|
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;
|
|
|
|
}
|
|
|
|
$this->view->groupData = $groupData;
|
2013-07-12 14:33:17 +02:00
|
|
|
}
|
|
|
|
|
2013-09-26 17:02:56 +02:00
|
|
|
public function commentsAction()
|
|
|
|
{
|
2014-02-21 11:42:03 +01:00
|
|
|
$this->getTabs()->add('comments', array(
|
|
|
|
'title' => 'Comments',
|
|
|
|
'url' => Url::fromPath('monitoring/list/comments')
|
|
|
|
))->activate('comments');
|
2014-03-09 19:31:59 +01:00
|
|
|
$this->setAutorefreshInterval(12);
|
2013-09-26 17:02:56 +02:00
|
|
|
$query = CommentView::fromRequest(
|
|
|
|
$this->_request,
|
|
|
|
array(
|
2014-03-09 19:29:23 +01:00
|
|
|
'id' => 'comment_internal_id',
|
|
|
|
'objecttype' => 'comment_objecttype',
|
|
|
|
'comment' => 'comment_data',
|
|
|
|
'author' => 'comment_author',
|
|
|
|
'timestamp' => 'comment_timestamp',
|
|
|
|
'type' => 'comment_type',
|
|
|
|
'persistent' => 'comment_is_persistent',
|
2014-03-09 20:05:59 +01:00
|
|
|
'expiration' => 'comment_expiration',
|
|
|
|
'host' => 'comment_host',
|
|
|
|
'service' => 'comment_service'
|
2013-09-26 17:02:56 +02:00
|
|
|
)
|
|
|
|
)->getQuery();
|
|
|
|
|
|
|
|
$this->view->comments = $query->paginate();
|
|
|
|
|
|
|
|
$this->setupSortControl(
|
|
|
|
array(
|
2014-03-09 19:39:32 +01:00
|
|
|
'comment_timestamp' => 'Comment Timestamp',
|
2014-03-09 20:05:59 +01:00
|
|
|
'comment_host' => 'Host / Service',
|
2014-03-09 19:39:32 +01:00
|
|
|
'comment_type' => 'Comment Type',
|
2014-03-09 20:05:59 +01:00
|
|
|
'comment_expiration' => 'Expiration',
|
2013-09-26 17:02:56 +02:00
|
|
|
)
|
|
|
|
);
|
|
|
|
$this->handleFormatRequest($query);
|
|
|
|
}
|
|
|
|
|
2013-10-15 12:49:58 +02:00
|
|
|
public function servicegroupsAction()
|
|
|
|
{
|
2014-03-07 11:14:19 +01:00
|
|
|
$this->addTitleTab('servicegroups');
|
|
|
|
|
2013-10-15 12:49:58 +02:00
|
|
|
$query = GroupsummaryView::fromRequest(
|
|
|
|
$this->_request,
|
|
|
|
array(
|
2013-10-22 14:35:58 +02:00
|
|
|
'servicegroup',
|
|
|
|
'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',
|
|
|
|
'services_pending'
|
2013-10-15 12:49:58 +02:00
|
|
|
)
|
|
|
|
)->getQuery();
|
|
|
|
$this->handleFormatRequest($query);
|
2013-10-15 14:55:01 +02:00
|
|
|
$this->view->servicegroups = $query->paginate();
|
|
|
|
$this->setupSortControl(array(
|
|
|
|
'servicegroup_name' => 'Servicegroup Name'
|
|
|
|
));
|
2013-10-15 12:49:58 +02:00
|
|
|
}
|
|
|
|
|
2013-10-15 15:12:59 +02:00
|
|
|
public function hostgroupsAction()
|
|
|
|
{
|
2014-02-21 11:42:03 +01:00
|
|
|
$this->addTitleTab('hostgroups');
|
2014-02-18 20:00:18 +01:00
|
|
|
|
2013-10-15 15:12:59 +02:00
|
|
|
$query = GroupsummaryView::fromRequest(
|
|
|
|
$this->_request,
|
|
|
|
array(
|
2013-10-22 14:35:58 +02:00
|
|
|
'hostgroup',
|
|
|
|
'hosts_up',
|
2014-03-07 16:43:22 +01:00
|
|
|
'hosts_unreachable_handled',
|
2013-10-22 14:35:58 +02:00
|
|
|
'hosts_unreachable_unhandled',
|
2014-03-07 16:43:22 +01:00
|
|
|
'hosts_down_handled',
|
2013-10-22 14:35:58 +02:00
|
|
|
'hosts_down_unhandled',
|
|
|
|
'hosts_pending',
|
|
|
|
'services_ok',
|
2014-03-07 16:43:22 +01:00
|
|
|
'services_unknown_handled',
|
2013-10-22 14:35:58 +02:00
|
|
|
'services_unknown_unhandled',
|
2014-03-07 16:43:22 +01:00
|
|
|
'services_critical_handled',
|
2013-10-22 14:35:58 +02:00
|
|
|
'services_critical_unhandled',
|
2014-03-07 16:43:22 +01:00
|
|
|
'services_warning_handled',
|
2013-10-22 14:35:58 +02:00
|
|
|
'services_warning_unhandled',
|
|
|
|
'services_pending'
|
2013-10-15 15:12:59 +02:00
|
|
|
)
|
|
|
|
)->getQuery();
|
2014-01-22 17:19:15 +01:00
|
|
|
$this->applyRestrictions($query);
|
2013-10-15 15:12:59 +02:00
|
|
|
$this->handleFormatRequest($query);
|
|
|
|
$this->view->hostgroups = $query->paginate();
|
|
|
|
$this->setupSortControl(array(
|
|
|
|
'hostgroup_name' => 'Hostgroup Name'
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2013-10-14 12:56:06 +02:00
|
|
|
public function eventhistoryAction()
|
|
|
|
{
|
2014-03-04 13:33:02 +01:00
|
|
|
$this->addTitleTab('eventhistory');
|
2014-02-21 12:59:32 +01:00
|
|
|
$dataview = EventHistoryView::fromRequest(
|
2013-10-17 20:53:11 +02:00
|
|
|
$this->getRequest(),
|
|
|
|
array(
|
|
|
|
'host_name',
|
|
|
|
'service_description',
|
|
|
|
'object_type',
|
|
|
|
'timestamp',
|
|
|
|
'raw_timestamp',
|
|
|
|
'state',
|
|
|
|
'attempt',
|
|
|
|
'max_attempts',
|
|
|
|
'output',
|
|
|
|
'type',
|
|
|
|
'host',
|
|
|
|
'service'
|
|
|
|
)
|
2014-02-21 12:59:32 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
$this->setupFilterControl($dataview, 'eventhistory');
|
2013-10-14 12:56:06 +02:00
|
|
|
$this->setupSortControl(
|
2014-02-21 12:59:32 +01:00
|
|
|
array(
|
|
|
|
'raw_timestamp' => 'Occurence'
|
|
|
|
)
|
2013-10-14 12:56:06 +02:00
|
|
|
);
|
2014-02-21 12:59:32 +01:00
|
|
|
|
|
|
|
$query = $dataview->getQuery();
|
|
|
|
$this->handleFormatRequest($query);
|
|
|
|
$this->view->history = $query->paginate();
|
2013-10-14 12:56:06 +02:00
|
|
|
}
|
|
|
|
|
2014-03-20 11:30:42 +01:00
|
|
|
// TODO: Should be able to identify hosts that have not a single service (without compromising the pagination)
|
2014-03-12 14:41:17 +01:00
|
|
|
public function servicematrixAction()
|
|
|
|
{
|
|
|
|
$this->view->title = 'Servicematrix';
|
|
|
|
$this->addTitleTab('servicematrix');
|
|
|
|
$dataview = ServiceStatusView::fromRequest(
|
|
|
|
$this->getRequest(),
|
|
|
|
array(
|
|
|
|
'host_name',
|
|
|
|
'service_description',
|
|
|
|
'service_state',
|
|
|
|
'service_output',
|
|
|
|
'service_handled'
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->setupFilterControl($dataview, 'servicematrix');
|
|
|
|
$this->setupSortControl(
|
|
|
|
array(
|
2014-03-12 15:20:33 +01:00
|
|
|
'host_name' => 'Hostname',
|
|
|
|
'service_description' => 'Service description'
|
2014-03-12 14:41:17 +01:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2014-03-13 16:26:14 +01:00
|
|
|
$this->view->pivot = $dataview->pivot('service_description', 'host_name');
|
|
|
|
$this->view->horizontalPaginator = $this->view->pivot->paginateXAxis();
|
|
|
|
$this->view->verticalPaginator = $this->view->pivot->paginateYAxis();
|
2014-03-12 14:41:17 +01:00
|
|
|
}
|
|
|
|
|
2014-01-22 14:34:39 +01:00
|
|
|
/**
|
|
|
|
* Apply current users monitoring/filter restrictions to the given query
|
|
|
|
*
|
|
|
|
* @param $query Filterable Query that should be filtered
|
|
|
|
* @return Filterable
|
|
|
|
*/
|
|
|
|
protected function applyRestrictions(Filterable $query)
|
|
|
|
{
|
|
|
|
foreach ($this->getRestrictions('monitoring/filter') as $restriction) {
|
|
|
|
parse_str($restriction, $filter);
|
|
|
|
foreach ($filter as $k => $v) {
|
2014-01-22 17:19:15 +01:00
|
|
|
if ($query->isValidFilterTarget($k)) {
|
2014-01-22 14:34:39 +01:00
|
|
|
// TODO: This is NOT enough. We need to fix filters and get
|
|
|
|
// applyAuthFilters back.
|
|
|
|
$query->where($k, $v);
|
2014-01-22 17:19:15 +01:00
|
|
|
}
|
2014-01-22 14:34:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return $query;
|
|
|
|
}
|
|
|
|
|
2013-07-30 17:17:19 +02:00
|
|
|
/**
|
2013-09-03 18:43:17 +02:00
|
|
|
* Create a sort control box at the 'sortControl' view parameter
|
|
|
|
*
|
|
|
|
* @param array $columns An array containing the sort columns, with the
|
|
|
|
* submit value as the key and the value as the label
|
2013-07-30 17:17:19 +02:00
|
|
|
*/
|
2013-09-03 18:43:17 +02:00
|
|
|
private function setupSortControl(array $columns)
|
2013-07-30 17:17:19 +02:00
|
|
|
{
|
2013-09-03 18:43:17 +02:00
|
|
|
$this->view->sortControl = new SortBox(
|
|
|
|
$this->getRequest()->getActionName(),
|
|
|
|
$columns
|
|
|
|
);
|
|
|
|
$this->view->sortControl->applyRequest($this->getRequest());
|
|
|
|
}
|
|
|
|
|
2013-10-17 19:48:46 +02:00
|
|
|
private function setupFilterControl(Filterable $dataview, $domain)
|
2013-10-14 13:25:25 +02:00
|
|
|
{
|
|
|
|
$parser = new UrlViewFilter($dataview);
|
|
|
|
$this->view->filterBox = new FilterBox(
|
2013-10-17 19:48:46 +02:00
|
|
|
$parser->fromRequest($this->getRequest()),
|
|
|
|
$domain,
|
2013-10-14 13:25:25 +02:00
|
|
|
'monitoring'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2014-02-21 11:41:05 +01:00
|
|
|
protected function addTitleTab($action)
|
|
|
|
{
|
|
|
|
$this->getTabs()->add($action, array(
|
|
|
|
'title' => ucfirst($action),
|
|
|
|
'url' => Url::fromPath('monitoring/list/' . $action)
|
|
|
|
))->activate($action);
|
|
|
|
}
|
|
|
|
|
2013-09-03 18:43:17 +02:00
|
|
|
/**
|
|
|
|
* Return all tabs for this controller
|
|
|
|
*
|
|
|
|
* @return Tabs
|
|
|
|
*/
|
|
|
|
private function createTabs()
|
|
|
|
{
|
|
|
|
$tabs = $this->getTabs();
|
2014-03-10 01:24:45 +01:00
|
|
|
if (in_array($this->_request->getActionName(), array(
|
|
|
|
'hosts',
|
|
|
|
'services',
|
|
|
|
'eventhistory',
|
|
|
|
'notifications'
|
|
|
|
))) {
|
|
|
|
$tabs->extend(new OutputFormat())->extend(new DashboardAction());
|
|
|
|
}
|
2013-07-30 17:17:19 +02:00
|
|
|
}
|
2013-06-27 10:14:41 +02:00
|
|
|
}
|
2013-08-14 12:42:32 +02:00
|
|
|
// @codingStandardsIgnoreEnd
|