Optimize queries for creating the host and service problem badges in the menu
We now use two fast count queries w/ an appropriate filter instead of fetching a whole bunch of unnecessary host and service counters.
This commit is contained in:
parent
a9f3f99049
commit
f5a9016dea
|
@ -136,7 +136,7 @@ $section->add(N_('Host Problems'), array(
|
|||
'hosts_down_unhandled' => $this->translate('%d unhandled hosts down')
|
||||
),
|
||||
'state' => 'critical',
|
||||
'dataView' => 'statussummary'
|
||||
'dataView' => 'unhandledhostproblems'
|
||||
),
|
||||
'url' => 'monitoring/list/hosts?host_problem=1&sort=host_severity',
|
||||
'priority' => 50
|
||||
|
@ -148,7 +148,7 @@ $section->add(N_('Service Problems'), array(
|
|||
'services_critical_unhandled' => $this->translate('%d unhandled services critical')
|
||||
),
|
||||
'state' => 'critical',
|
||||
'dataView' => 'statussummary'
|
||||
'dataView' => 'unhandledserviceproblems'
|
||||
),
|
||||
'url' => 'monitoring/list/services?service_problem=1&sort=service_severity&dir=desc',
|
||||
'priority' => 60
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
/* Icinga Web 2 | (c) 2017 Icinga Development Team | GPLv2+ */
|
||||
|
||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||
|
||||
use Icinga\Data\Filter\Filter;
|
||||
|
||||
/**
|
||||
* Query for unhandled host problems
|
||||
*/
|
||||
class UnhandledhostproblemsQuery extends IdoQuery
|
||||
{
|
||||
protected $allowCustomVars = true;
|
||||
|
||||
protected $columnMap = array(
|
||||
'problems' => array(
|
||||
'hosts_down_unhandled' => 'COUNT(*)',
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* The service status sub select
|
||||
*
|
||||
* @var HoststatusQuery
|
||||
*/
|
||||
protected $subSelect;
|
||||
|
||||
public function addFilter(Filter $filter)
|
||||
{
|
||||
$this->subSelect->applyFilter(clone $filter);
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function joinBaseTables()
|
||||
{
|
||||
$this->subSelect = $this->createSubQuery(
|
||||
'Hoststatus',
|
||||
array('host_name')
|
||||
);
|
||||
$this->subSelect->where('host_handled', 0);
|
||||
$this->subSelect->where('host_state', 1);
|
||||
$this->select->from(
|
||||
array('problems' => $this->subSelect->setIsSubQuery(true)),
|
||||
array()
|
||||
);
|
||||
$this->joinedVirtualTables['problems'] = true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
/* Icinga Web 2 | (c) 2017 Icinga Development Team | GPLv2+ */
|
||||
|
||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||
|
||||
use Icinga\Data\Filter\Filter;
|
||||
|
||||
/**
|
||||
* Query for unhandled service problems
|
||||
*/
|
||||
class UnhandledserviceproblemsQuery extends IdoQuery
|
||||
{
|
||||
protected $allowCustomVars = true;
|
||||
|
||||
protected $columnMap = array(
|
||||
'problems' => array(
|
||||
'services_critical_unhandled' => 'COUNT(*)',
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* The service status sub select
|
||||
*
|
||||
* @var ServicestatusQuery
|
||||
*/
|
||||
protected $subSelect;
|
||||
|
||||
public function addFilter(Filter $filter)
|
||||
{
|
||||
$this->subSelect->applyFilter(clone $filter);
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function joinBaseTables()
|
||||
{
|
||||
$this->subSelect = $this->createSubQuery(
|
||||
'Servicestatus',
|
||||
array('service_description')
|
||||
);
|
||||
$this->subSelect->where('service_handled', 0);
|
||||
$this->subSelect->where('service_state', 2);
|
||||
$this->select->from(
|
||||
array('problems' => $this->subSelect->setIsSubQuery(true)),
|
||||
array()
|
||||
);
|
||||
$this->joinedVirtualTables['problems'] = true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
/* Icinga Web 2 | (c) 2017 Icinga Development Team | GPLv2+ */
|
||||
|
||||
namespace Icinga\Module\Monitoring\DataView;
|
||||
|
||||
/**
|
||||
* Data view for unhandled host problems
|
||||
*/
|
||||
class Unhandledhostproblems extends DataView
|
||||
{
|
||||
public function getColumns()
|
||||
{
|
||||
return array(
|
||||
'hosts_down_unhandled'
|
||||
);
|
||||
}
|
||||
|
||||
public function getStaticFilterColumns()
|
||||
{
|
||||
return array(
|
||||
'instance_name',
|
||||
'host', 'host_alias', 'host_display_name', 'host_name',
|
||||
'hostgroup', 'hostgroup_alias', 'hostgroup_name',
|
||||
'service', 'service_description', 'service_display_name',
|
||||
'servicegroup', 'servicegroup_alias', 'servicegroup_name'
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
/* Icinga Web 2 | (c) 2017 Icinga Development Team | GPLv2+ */
|
||||
|
||||
namespace Icinga\Module\Monitoring\DataView;
|
||||
|
||||
/**
|
||||
* Data view for unhandled service problems
|
||||
*/
|
||||
class Unhandledserviceproblems extends DataView
|
||||
{
|
||||
public function getColumns()
|
||||
{
|
||||
return array(
|
||||
'services_critical_unhandled'
|
||||
);
|
||||
}
|
||||
|
||||
public function getStaticFilterColumns()
|
||||
{
|
||||
return array(
|
||||
'instance_name',
|
||||
'host', 'host_alias', 'host_display_name', 'host_name',
|
||||
'hostgroup', 'hostgroup_alias', 'hostgroup_name',
|
||||
'service', 'service_description', 'service_display_name',
|
||||
'servicegroup', 'servicegroup_alias', 'servicegroup_name'
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue