2019-10-09 11:25:39 -04:00
|
|
|
<?php
|
|
|
|
|
|
2019-11-04 19:07:30 -05:00
|
|
|
namespace Icinga\Module\Icingadb\Controllers;
|
2019-10-09 11:25:39 -04:00
|
|
|
|
2019-11-04 19:07:30 -05:00
|
|
|
use Icinga\Module\Icingadb\Model\Service;
|
2019-11-05 06:36:59 -05:00
|
|
|
use Icinga\Module\Icingadb\Model\ServicestateSummary;
|
2019-11-04 19:07:30 -05:00
|
|
|
use Icinga\Module\Icingadb\Web\Controller;
|
|
|
|
|
use Icinga\Module\Icingadb\Widget\ServiceList;
|
2019-10-09 11:25:39 -04:00
|
|
|
|
|
|
|
|
class ServicesController extends Controller
|
|
|
|
|
{
|
|
|
|
|
public function indexAction()
|
|
|
|
|
{
|
|
|
|
|
$this->setTitle($this->translate('Services'));
|
|
|
|
|
|
|
|
|
|
$db = $this->getDb();
|
|
|
|
|
|
|
|
|
|
$services = Service::on($db)->with([
|
|
|
|
|
'state',
|
2019-10-10 09:13:27 -04:00
|
|
|
'host',
|
|
|
|
|
'host.state'
|
2019-10-09 11:25:39 -04:00
|
|
|
]);
|
2019-11-05 06:36:59 -05:00
|
|
|
$summary = ServicestateSummary::on($db)->with('state');
|
2019-10-09 11:25:39 -04:00
|
|
|
|
|
|
|
|
$limitControl = $this->createLimitControl();
|
2019-10-15 09:29:36 -04:00
|
|
|
$paginationControl = $this->createPaginationControl($services);
|
2019-12-11 07:59:39 -05:00
|
|
|
$sortControl = $this->createSortControl(
|
|
|
|
|
$services,
|
|
|
|
|
[
|
|
|
|
|
'service.display_name, host.display_name' => $this->translate('Name'),
|
|
|
|
|
'service.state.severity desc' => $this->translate('Severity'),
|
|
|
|
|
'service.state.soft_state' => $this->translate('Current State'),
|
|
|
|
|
'service.state.last_state_change desc' => $this->translate('Last State Change'),
|
|
|
|
|
'host.display_name, service.display_name' => $this->translate('Host')
|
|
|
|
|
]
|
|
|
|
|
);
|
2019-10-15 09:29:36 -04:00
|
|
|
$viewModeSwitcher = $this->createViewModeSwitcher();
|
2019-10-18 02:44:38 -04:00
|
|
|
$filterControl = $this->createFilterControl($services);
|
2019-10-09 11:25:39 -04:00
|
|
|
|
2019-10-16 03:22:05 -04:00
|
|
|
$this->filter($services);
|
2019-11-05 06:36:59 -05:00
|
|
|
$this->filter($summary);
|
2019-10-16 03:22:05 -04:00
|
|
|
|
2019-11-05 06:36:59 -05:00
|
|
|
yield $this->export($services, $summary);
|
2019-10-15 10:50:40 -04:00
|
|
|
|
2019-10-09 11:25:39 -04:00
|
|
|
$serviceList = (new ServiceList($services))
|
|
|
|
|
->setViewMode($viewModeSwitcher->getViewMode());
|
|
|
|
|
|
2019-10-15 09:29:36 -04:00
|
|
|
$this->addControl($paginationControl);
|
2019-12-11 07:59:39 -05:00
|
|
|
$this->addControl($sortControl);
|
2019-10-09 11:25:39 -04:00
|
|
|
$this->addControl($limitControl);
|
2019-11-05 04:16:29 -05:00
|
|
|
$this->addControl($viewModeSwitcher);
|
2019-10-18 02:44:38 -04:00
|
|
|
$this->addControl($filterControl);
|
2019-10-09 11:25:39 -04:00
|
|
|
|
|
|
|
|
$this->addContent($serviceList);
|
2019-12-11 02:59:30 -05:00
|
|
|
|
|
|
|
|
$this->setAutorefreshInterval(10);
|
2019-10-09 11:25:39 -04:00
|
|
|
}
|
|
|
|
|
}
|