2013-06-27 10:14:41 +02:00
|
|
|
<?php
|
2013-07-02 16:00:41 +02:00
|
|
|
// {{{ICINGA_LICENSE_HEADER}}}
|
2013-08-06 11:24:16 +02:00
|
|
|
/**
|
2013-10-23 15:10:33 +02:00
|
|
|
* This file is part of Icinga Web 2.
|
2013-08-06 11:24:16 +02:00
|
|
|
*
|
2013-10-23 15:10:33 +02:00
|
|
|
* Icinga Web 2 - Head for multiple monitoring backends.
|
2013-08-06 11:24:16 +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-06 11:24:16 +02:00
|
|
|
*/
|
2013-07-02 16:00:41 +02:00
|
|
|
// {{{ICINGA_LICENSE_HEADER}}}
|
2013-06-27 10:14:41 +02:00
|
|
|
|
2013-08-21 00:50:15 +02:00
|
|
|
// @codingStandardsIgnoreStart
|
2013-08-20 15:32:25 +02:00
|
|
|
use \Icinga\Module\Monitoring\Backend;
|
2013-10-10 11:54:51 +02:00
|
|
|
use Icinga\Module\Monitoring\Controller as MonitoringController;
|
2013-09-24 12:48:30 +02:00
|
|
|
use \Icinga\Web\Hook;
|
2013-08-20 15:32:25 +02:00
|
|
|
use \Icinga\Module\Monitoring\Object\Host;
|
|
|
|
use \Icinga\Module\Monitoring\Object\Service;
|
2013-09-24 12:48:30 +02:00
|
|
|
use \Icinga\Application\Benchmark;
|
|
|
|
use \Icinga\Web\Widget\Tabextension\OutputFormat;
|
2013-10-15 19:56:33 +02:00
|
|
|
use Icinga\Web\Widget\Tabextension\DashboardAction;
|
|
|
|
use Icinga\Module\Monitoring\Object\AbstractObject;
|
2013-09-24 12:48:30 +02:00
|
|
|
use \Icinga\Web\Widget\Tabs;
|
2013-08-08 16:22:22 +02:00
|
|
|
|
2013-07-02 16:00:41 +02:00
|
|
|
/**
|
|
|
|
* Class Monitoring_ShowController
|
|
|
|
*
|
|
|
|
* Actions for show context
|
|
|
|
*/
|
2013-10-10 11:54:51 +02:00
|
|
|
class Monitoring_ShowController extends MonitoringController
|
2013-06-27 10:14:41 +02:00
|
|
|
{
|
2013-07-02 16:00:41 +02:00
|
|
|
/**
|
|
|
|
* @var Backend
|
|
|
|
*/
|
2013-06-27 10:14:41 +02:00
|
|
|
protected $backend;
|
|
|
|
|
2013-07-02 16:00:41 +02:00
|
|
|
/**
|
|
|
|
* Initialize the controller
|
|
|
|
*/
|
2013-06-27 10:14:41 +02:00
|
|
|
public function init()
|
|
|
|
{
|
2013-10-17 19:48:46 +02:00
|
|
|
if ($this->getRequest()->getActionName() === 'host') {
|
|
|
|
$this->view->object = new Host($this->getRequest());
|
2013-10-19 20:09:17 +02:00
|
|
|
} elseif ($this->getRequest()->getActionName() === 'service'
|
|
|
|
|| $this->getRequest()->getActionName() === 'services' ) {
|
2013-10-17 19:48:46 +02:00
|
|
|
$this->view->object = new Service($this->getRequest());
|
|
|
|
} else {
|
|
|
|
$this->view->object = AbstractObject::fromRequest($this->getRequest());
|
|
|
|
}
|
|
|
|
|
2013-08-08 16:22:22 +02:00
|
|
|
$this->createTabs();
|
2013-06-27 10:14:41 +02:00
|
|
|
}
|
|
|
|
|
2013-07-02 16:00:41 +02:00
|
|
|
/**
|
|
|
|
* Service overview
|
|
|
|
*/
|
2013-06-27 10:14:41 +02:00
|
|
|
public function serviceAction()
|
|
|
|
{
|
2013-10-15 19:56:33 +02:00
|
|
|
$this->view->object->populate();
|
2013-06-27 10:14:41 +02:00
|
|
|
}
|
|
|
|
|
2013-07-02 16:00:41 +02:00
|
|
|
/**
|
|
|
|
* Host overview
|
|
|
|
*/
|
2013-06-27 10:14:41 +02:00
|
|
|
public function hostAction()
|
|
|
|
{
|
2013-10-15 19:56:33 +02:00
|
|
|
$this->view->object->populate();
|
2013-06-27 10:14:41 +02:00
|
|
|
}
|
|
|
|
|
2013-10-10 11:54:51 +02:00
|
|
|
public function historyAction()
|
|
|
|
{
|
2013-10-15 19:56:33 +02:00
|
|
|
$this->view->object->populate();
|
2013-10-10 11:54:51 +02:00
|
|
|
$this->view->object->fetchEventHistory();
|
2013-10-15 19:56:33 +02:00
|
|
|
$this->view->history = $this->view->object->eventhistory->limit(10)->paginate();
|
|
|
|
|
2013-10-10 11:54:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function servicesAction()
|
|
|
|
{
|
|
|
|
$params = $this->_request->getParams();
|
|
|
|
unset($params['service']);
|
2014-01-22 14:34:39 +01:00
|
|
|
$this->view->services = $this->fetchServices($params)->paginate();
|
2013-10-10 11:54:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-02 16:00:41 +02:00
|
|
|
/**
|
|
|
|
* History entries for objects
|
|
|
|
*/
|
2013-10-10 11:54:51 +02:00
|
|
|
/* public function historyAction()
|
2013-06-27 10:14:41 +02:00
|
|
|
{
|
|
|
|
$this->view->history = $this->backend->select()
|
2013-07-02 16:00:41 +02:00
|
|
|
->from(
|
|
|
|
'eventHistory',
|
|
|
|
array(
|
|
|
|
'object_type',
|
|
|
|
'host_name',
|
|
|
|
'service_description',
|
|
|
|
'timestamp',
|
|
|
|
'state',
|
|
|
|
'attempt',
|
|
|
|
'max_attempts',
|
|
|
|
'output',
|
|
|
|
'type'
|
|
|
|
)
|
|
|
|
)->applyRequest($this->_request);
|
2013-06-27 10:14:41 +02:00
|
|
|
|
2013-07-02 16:00:41 +02:00
|
|
|
$this->view->preserve = $this->view->history->getAppliedFilter()->toParams();
|
|
|
|
if ($this->_getParam('dump') === 'sql') {
|
|
|
|
echo '<pre>' . htmlspecialchars($this->view->history->getQuery()->dump()) . '</pre>';
|
|
|
|
exit;
|
|
|
|
}
|
2013-06-27 10:14:41 +02:00
|
|
|
if ($this->_getParam('sort')) {
|
|
|
|
$this->view->preserve['sort'] = $this->_getParam('sort');
|
|
|
|
}
|
2013-07-12 15:55:31 +02:00
|
|
|
$this->view->preserve = $this->view->history->getAppliedFilter()->toParams();
|
2013-10-10 11:54:51 +02:00
|
|
|
}*/
|
2013-06-27 10:14:41 +02:00
|
|
|
|
2013-07-02 16:00:41 +02:00
|
|
|
/**
|
|
|
|
* Creating tabs for this controller
|
2013-09-24 12:48:30 +02:00
|
|
|
* @return Tabs
|
2013-07-02 16:00:41 +02:00
|
|
|
*/
|
2013-06-27 10:14:41 +02:00
|
|
|
protected function createTabs()
|
|
|
|
{
|
2013-07-12 14:33:17 +02:00
|
|
|
$object = $this->view->object;
|
2013-08-08 16:22:22 +02:00
|
|
|
$tabs = $this->getTabs();
|
2013-06-27 10:14:41 +02:00
|
|
|
$params = array(
|
2013-10-10 11:54:51 +02:00
|
|
|
'host' => $object->host_name,
|
2013-06-27 10:14:41 +02:00
|
|
|
);
|
2013-07-12 14:33:17 +02:00
|
|
|
if ($object instanceof Service) {
|
|
|
|
$params['service'] = $object->service_description;
|
|
|
|
} elseif ($service = $this->_getParam('service')) {
|
|
|
|
$params['service'] = $service;
|
2013-06-27 10:14:41 +02:00
|
|
|
}
|
2013-10-10 11:54:51 +02:00
|
|
|
if (isset($params['service'])) {
|
|
|
|
$tabs->add(
|
|
|
|
'service',
|
|
|
|
array(
|
|
|
|
'title' => 'Service',
|
2013-10-16 15:37:44 +02:00
|
|
|
'iconCls' => 'icinga-icon-service',
|
2013-10-10 11:54:51 +02:00
|
|
|
'url' => 'monitoring/show/service',
|
|
|
|
'urlParams' => $params,
|
|
|
|
'tagParams' => array(
|
|
|
|
'data-icinga-target' => 'detail'
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
$tabs->add(
|
|
|
|
'host',
|
|
|
|
array(
|
|
|
|
'title' => 'Host',
|
2013-10-16 15:37:44 +02:00
|
|
|
'iconCls' => 'icinga-icon-host',
|
2013-10-10 11:54:51 +02:00
|
|
|
'url' => 'monitoring/show/host',
|
|
|
|
'urlParams' => $params,
|
|
|
|
'tagParams' => array(
|
|
|
|
'data-icinga-target' => 'detail'
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
$tabs->add(
|
|
|
|
'services',
|
|
|
|
array(
|
|
|
|
'title' => 'Services',
|
2013-10-16 15:37:44 +02:00
|
|
|
'iconCls' => 'icinga-icon-service',
|
2013-10-10 11:54:51 +02:00
|
|
|
'url' => 'monitoring/show/services',
|
|
|
|
'urlParams' => $params,
|
|
|
|
'tagParams' => array(
|
|
|
|
'data-icinga-target' => 'detail'
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
$tabs->add(
|
|
|
|
'history',
|
|
|
|
array(
|
|
|
|
'title' => 'History',
|
2013-10-16 15:37:44 +02:00
|
|
|
'iconCls' => 'icinga-icon-history',
|
2013-10-10 11:54:51 +02:00
|
|
|
'url' => 'monitoring/show/history',
|
|
|
|
'urlParams' => $params,
|
|
|
|
'tagParams' => array(
|
|
|
|
'data-icinga-target' => 'detail'
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2013-08-08 16:22:22 +02:00
|
|
|
$tabs->extend(new OutputFormat())
|
2014-02-05 18:18:22 +01:00
|
|
|
->extend(new DashboardAction());
|
2013-06-27 10:14:41 +02:00
|
|
|
}
|
|
|
|
}
|
2013-08-07 10:27:50 +02:00
|
|
|
// @codingStandardsIgnoreEnd
|