2014-02-05 17:23:51 +01:00
|
|
|
<?php
|
2016-02-08 15:41:00 +01:00
|
|
|
/* Icinga Web 2 | (c) 2014 Icinga Development Team | GPLv2+ */
|
2014-02-05 17:23:51 +01:00
|
|
|
|
2015-08-28 09:36:34 +02:00
|
|
|
namespace Icinga\Module\Monitoring\Controllers;
|
|
|
|
|
2017-11-16 16:12:10 +01:00
|
|
|
use Icinga\Chart\Donut;
|
2015-08-28 09:35:25 +02:00
|
|
|
use Icinga\Module\Monitoring\Controller;
|
2014-03-07 13:15:26 +01:00
|
|
|
use Icinga\Web\Url;
|
2015-08-28 09:36:10 +02:00
|
|
|
use Icinga\Web\Widget\Tabextension\DashboardAction;
|
2015-09-30 14:47:42 +02:00
|
|
|
use Icinga\Web\Widget\Tabextension\MenuAction;
|
2014-02-05 17:23:51 +01:00
|
|
|
|
2015-08-28 09:36:34 +02:00
|
|
|
class TacticalController extends Controller
|
2014-02-05 17:23:51 +01:00
|
|
|
{
|
|
|
|
public function indexAction()
|
|
|
|
{
|
2015-07-22 13:40:50 +02:00
|
|
|
$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(
|
2015-02-23 16:58:48 +01:00
|
|
|
'title' => $this->translate(
|
|
|
|
'Show an overview of all hosts and services, their current'
|
|
|
|
. ' states and monitoring feature utilisation'
|
|
|
|
),
|
|
|
|
'label' => $this->translate('Tactical Overview'),
|
2014-06-17 15:48:26 +02:00
|
|
|
'url' => Url::fromRequest()
|
2014-03-07 13:15:26 +01:00
|
|
|
)
|
2015-09-30 14:47:42 +02:00
|
|
|
)->extend(new DashboardAction())->extend(new MenuAction())->activate('tactical_overview');
|
2017-11-16 16:12:10 +01:00
|
|
|
|
2015-06-05 12:43:24 +02:00
|
|
|
$stats = $this->backend->select()->from(
|
2015-06-12 14:42:49 +02:00
|
|
|
'statussummary',
|
2014-03-04 09:39:00 +01:00
|
|
|
array(
|
|
|
|
'hosts_up',
|
2017-11-16 16:12:10 +01:00
|
|
|
'hosts_down_handled',
|
2014-03-04 09:39:00 +01:00
|
|
|
'hosts_down_unhandled',
|
2017-11-16 16:12:10 +01:00
|
|
|
'hosts_unreachable_handled',
|
2014-03-04 09:39:00 +01:00
|
|
|
'hosts_unreachable_unhandled',
|
2017-11-16 16:12:10 +01:00
|
|
|
'hosts_pending',
|
2014-03-04 09:39:00 +01:00
|
|
|
'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',
|
2014-03-04 09:39:00 +01:00
|
|
|
'services_not_checked',
|
|
|
|
)
|
2015-06-05 12:43:24 +02:00
|
|
|
);
|
|
|
|
$this->applyRestriction('monitoring/filter/objects', $stats);
|
2017-11-16 16:12:10 +01:00
|
|
|
|
2018-05-02 11:14:27 +02: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());
|
|
|
|
});
|
|
|
|
|
2018-02-19 11:04:39 +01:00
|
|
|
$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'))
|
2018-01-17 15:01:02 +01:00
|
|
|
->addSlice($summary->hosts_not_checked, array('class' => 'slice-state-not-checked'))
|
|
|
|
->setLabelBig($summary->hosts_down_unhandled)
|
|
|
|
->setLabelBigEyeCatching($summary->hosts_down_unhandled > 0)
|
2018-04-05 13:43:14 +02:00
|
|
|
->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'))
|
2018-01-17 15:01:02 +01:00
|
|
|
->addSlice($summary->services_not_checked, array('class' => 'slice-state-not-checked'))
|
|
|
|
->setLabelBig($summary->services_critical_unhandled)
|
|
|
|
->setLabelBigEyeCatching($summary->services_critical_unhandled > 0)
|
2018-04-05 13:43:14 +02:00
|
|
|
->setLabelSmall($this->translate('Services Critical'));
|
2017-11-16 16:12:10 +01:00
|
|
|
|
|
|
|
$this->view->hostStatusSummaryChart = $hostSummaryChart
|
2018-05-02 11:14:27 +02:00
|
|
|
->setLabelBigUrl($this->view->filteredUrl(
|
2017-11-16 16:12:10 +01:00
|
|
|
'monitoring/list/hosts',
|
|
|
|
array(
|
2018-05-02 11:14:27 +02:00
|
|
|
'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
|
2018-05-02 11:14:27 +02:00
|
|
|
->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
|
|
|
}
|
|
|
|
}
|