icingadb-web/application/controllers/TacticalController.php

48 lines
1.5 KiB
PHP
Raw Normal View History

2020-01-16 05:43:51 -05:00
<?php
2020-03-13 03:38:01 -04:00
/* Icinga DB Web | (c) 2020 Icinga GmbH | GPLv2 */
2020-01-16 05:43:51 -05:00
namespace Icinga\Module\Icingadb\Controllers;
use Icinga\Module\Icingadb\Model\HoststateSummary;
use Icinga\Module\Icingadb\Model\ServicestateSummary;
use Icinga\Module\Icingadb\Web\Controller;
use Icinga\Module\Icingadb\Widget\HostSummaryDonut;
use Icinga\Module\Icingadb\Widget\ServiceSummaryDonut;
2020-01-16 05:43:51 -05:00
class TacticalController extends Controller
{
public function indexAction()
{
$this->setTitle($this->translate('Tactical Overview'));
$db = $this->getDb();
$hoststateSummary = HoststateSummary::on($db)->with('state');
// With relation `host` because otherwise the filter editor only presents service cols
$servicestateSummary = ServicestateSummary::on($db)->with(['state', 'host']);
$filterControl = $this->createFilterControl($servicestateSummary);
$this->createFilterControl($hoststateSummary);
$this->filter($hoststateSummary);
$this->filter($servicestateSummary);
2020-01-16 05:43:51 -05:00
yield $this->export($hoststateSummary, $servicestateSummary);
$this->addControl($filterControl);
$this->addContent(
(new HostSummaryDonut($hoststateSummary->first()))
->setBaseFilter($this->getFilter())
);
2020-01-16 05:43:51 -05:00
$this->addContent(
(new ServiceSummaryDonut($servicestateSummary->first()))
->setBaseFilter($this->getFilter())
);
$this->setAutorefreshInterval(10);
2020-01-16 05:43:51 -05:00
}
}