Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 5 additions & 34 deletions application/controllers/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,14 @@

namespace Icinga\Module\Grafana\Controllers;

use Icinga\Module\Grafana\ProvidedHook\Icingadb\IcingadbSupport;

use Icinga\Application\Modules\Module;
use Icinga\Module\Monitoring\Controller;
use Icinga\Module\Monitoring\Object\Host;
use Icinga\Module\Monitoring\Object\Service;
use Icinga\Module\Grafana\Web\Controller\IcingadbGrafanaController;

use ipl\Web\Url;

/**
* DashboardController for showing graphs for Monitoring Module dashboards
*/
class DashboardController extends Controller
class DashboardController extends IcingadbGrafanaController
{
public function init()
{
Expand All @@ -24,32 +19,8 @@ public function init()

public function indexAction()
{
// Redirect to IcingaDB if it is enabled
if (Module::exists('icingadb') && IcingadbSupport::useIcingaDbAsBackend()) {
$this->redirectNow(Url::fromPath('grafana/icingadbdashboard')->setQueryString($this->params));
}

$this->getTabs()->add('graphs', [
'active' => true,
'label' => $this->translate('Graphs'),
'url' => $this->getRequest()->getUrl()
]);

$hostname = $this->params->getRequired('host');
$servicename = $this->params->get('service');

if ($servicename != null) {
$object = new Service($this->backend, $hostname, $servicename);
} else {
$object = new Host($this->backend, $this->params->getRequired('host'));
}

$this->applyRestriction('monitoring/filter/objects', $object);
if ($object->fetch() === false) {
$this->httpNotFound($this->translate('Host or Service not found'));
}

$graph = new Grapher();
$this->view->graph = $graph->getPreviewHtml($object);
// This is an old controller that was used in the Monitoring module.
// So we redirect to IcingaDB, just to that older dashboards don't break.
$this->redirectNow(Url::fromPath('grafana/icingadbdashboard')->setQueryString($this->params));
}
}
8 changes: 0 additions & 8 deletions application/controllers/IcingadbdashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
use Icinga\Module\Grafana\ProvidedHook\Icingadb\ServiceDetailExtension;
use Icinga\Module\Grafana\Web\Controller\IcingadbGrafanaController;

use Icinga\Module\Icingadb\Model\Host;

use ipl\Web\Url;

/**
* IcingadbdashboardController for showing graphs for IcingaDB Module dashboards
*/
Expand All @@ -23,10 +19,6 @@ public function init()

public function indexAction()
{
if (! $this->useIcingadbAsBackend) {
$this->redirectNow(Url::fromPath('grafana/dashboard')->setQueryString($this->params));
}

$this->getTabs()->add(
'graphs',
[
Expand Down