icingaweb2/modules/monitoring/application/controllers/MultiController.php

82 lines
2.3 KiB
PHP
Raw Normal View History

<?php
// {{{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\Web\Controller\ActionController;
/**
* Displays aggregations collections of multiple objects.
*/
class Monitoring_MultiController extends ActionController
{
public function init()
{
$this->view->objects = $this->getDetailQueries();
}
public function hostAction()
{
$this->view->hosts = $this->_getAllParams();
}
public function servicesAction()
{
}
public function notificationsAction()
{
}
public function historyAction()
{
}
/**
* Fetch all queries from the 'detail' parameter and prepare
* them for further processing.
*
* @return array An array containing all requests and their filter values.
*/
private function getDetailQueries()
{
$details = $this->_getAllParams();
$objects = array();
foreach ($details as $property => $values) {
if (!is_array($values)) {
continue;
}
foreach ($values as $index => $value) {
if (!array_key_exists($index, $objects)) {
$objects[$index] = array();
}
$objects[$index][$property] = $value;
}
}
return $objects;
}
}