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

120 lines
5.3 KiB
PHP
Raw Normal View History

2014-02-05 17:23:51 +01:00
<?php
/* Icinga Web 2 | (c) 2014 Icinga Development Team | GPLv2+ */
2014-02-05 17:23:51 +01:00
namespace Icinga\Module\Monitoring\Controllers;
2017-11-16 16:12:10 +01:00
use Icinga\Chart\Donut;
use Icinga\Module\Monitoring\Controller;
2014-03-07 13:15:26 +01:00
use Icinga\Web\Url;
use Icinga\Web\Widget\Tabextension\DashboardAction;
use Icinga\Web\Widget\Tabextension\MenuAction;
2014-02-05 17:23:51 +01:00
class TacticalController extends Controller
2014-02-05 17:23:51 +01:00
{
public function indexAction()
{
$this->setAutorefreshInterval(15);
2017-11-16 16:12:10 +01:00
2014-03-07 13:15:26 +01:00
$this->getTabs()->add(
'tactical_overview',
array(
'title' => $this->translate(
'Show an overview of all hosts and services, their current'
. ' states and monitoring feature utilisation'
),
'label' => $this->translate('Tactical Overview'),
'url' => Url::fromRequest()
2014-03-07 13:15:26 +01:00
)
)->extend(new DashboardAction())->extend(new MenuAction())->activate('tactical_overview');
2017-11-16 16:12:10 +01:00
$stats = $this->backend->select()->from(
'statussummary',
array(
'hosts_up',
2017-11-16 16:12:10 +01:00
'hosts_down_handled',
'hosts_down_unhandled',
2017-11-16 16:12:10 +01:00
'hosts_unreachable_handled',
'hosts_unreachable_unhandled',
2017-11-16 16:12:10 +01:00
'hosts_pending',
'hosts_not_checked',
2017-11-16 16:12:10 +01:00
'services_ok',
'services_warning_handled',
'services_warning_unhandled',
'services_critical_handled',
'services_critical_unhandled',
'services_unknown_handled',
'services_unknown_unhandled',
'services_pending',
'services_not_checked',
)
);
$this->applyRestriction('monitoring/filter/objects', $stats);
2017-11-16 16:12:10 +01:00
$this->setupFilterControl($stats, null, ['host', 'service'], ['format']);
$this->view->setHelperFunction('filteredUrl', function ($path, array $params) {
$filter = clone $this->view->filterEditor->getFilter();
foreach ($params as $column => $value) {
$filter = $filter->andFilter($filter->where($column, $value));
}
return $this->view->url($path)->setQueryString($filter->toQueryString());
});
$this->handleFormatRequest($stats);
2017-11-16 16:12:10 +01:00
$summary = $stats->fetchRow();
$hostSummaryChart = new Donut();
$hostSummaryChart
->addSlice($summary->hosts_up, array('class' => 'slice-state-ok'))
->addSlice($summary->hosts_down_handled, array('class' => 'slice-state-critical-handled'))
->addSlice($summary->hosts_down_unhandled, array('class' => 'slice-state-critical'))
->addSlice($summary->hosts_unreachable_handled, array('class' => 'slice-state-unreachable-handled'))
->addSlice($summary->hosts_unreachable_unhandled, array('class' => 'slice-state-unreachable'))
->addSlice($summary->hosts_pending, array('class' => 'slice-state-pending'))
->addSlice($summary->hosts_not_checked, array('class' => 'slice-state-not-checked'))
->setLabelBig($summary->hosts_down_unhandled)
->setLabelBigEyeCatching($summary->hosts_down_unhandled > 0)
->setLabelSmall($this->translate('Hosts Down'));
2017-11-16 16:12:10 +01:00
$serviceSummaryChart = new Donut();
$serviceSummaryChart
->addSlice($summary->services_ok, array('class' => 'slice-state-ok'))
->addSlice($summary->services_warning_handled, array('class' => 'slice-state-warning-handled'))
->addSlice($summary->services_warning_unhandled, array('class' => 'slice-state-warning'))
->addSlice($summary->services_critical_handled, array('class' => 'slice-state-critical-handled'))
->addSlice($summary->services_critical_unhandled, array('class' => 'slice-state-critical'))
->addSlice($summary->services_unknown_handled, array('class' => 'slice-state-unknown-handled'))
->addSlice($summary->services_unknown_unhandled, array('class' => 'slice-state-unknown'))
->addSlice($summary->services_pending, array('class' => 'slice-state-pending'))
->addSlice($summary->services_not_checked, array('class' => 'slice-state-not-checked'))
->setLabelBig($summary->services_critical_unhandled)
->setLabelBigEyeCatching($summary->services_critical_unhandled > 0)
->setLabelSmall($this->translate('Services Critical'));
2017-11-16 16:12:10 +01:00
$this->view->hostStatusSummaryChart = $hostSummaryChart
->setLabelBigUrl($this->view->filteredUrl(
2017-11-16 16:12:10 +01:00
'monitoring/list/hosts',
array(
'host_state' => 1,
'host_handled' => 0,
'sort' => 'host_last_check',
'dir' => 'asc'
2017-11-16 16:12:10 +01:00
)
))
->render();
$this->view->serviceStatusSummaryChart = $serviceSummaryChart
->setLabelBigUrl($this->view->filteredUrl(
2017-11-16 16:12:10 +01:00
'monitoring/list/services',
array(
'service_state' => 2,
'service_handled' => 0,
'sort' => 'service_last_check',
'dir' => 'asc'
)
))
->render();
$this->view->statusSummary = $summary;
2014-02-05 17:23:51 +01:00
}
}