parent
d0f11e10f6
commit
6307af9e10
|
@ -3,8 +3,6 @@
|
|||
|
||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||
|
||||
use Zend_Db_Expr;
|
||||
|
||||
/**
|
||||
* Query for service status
|
||||
*/
|
||||
|
@ -15,6 +13,16 @@ class ServicestatusQuery extends IdoQuery
|
|||
*/
|
||||
protected $allowCustomVars = true;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $groupBase = array('services' => array('so.object_id', 's.service_id'));
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $groupOrigin = array('hostgroups', 'servicegroups');
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -401,69 +409,22 @@ class ServicestatusQuery extends IdoQuery
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getGroup()
|
||||
protected function handleGroupColumn($column, &$groupColumns, &$groupedTables)
|
||||
{
|
||||
$group = parent::getGroup() ?: array();
|
||||
if (! is_array($group)) {
|
||||
$group = array($group);
|
||||
}
|
||||
$groupedTables = array();
|
||||
if ($this->hasJoinedVirtualTable('servicegroups')) {
|
||||
$group[] = 'so.object_id';
|
||||
$group[] = 's.service_id';
|
||||
$groupedTables['services'] = true;
|
||||
$serviceGroupColumns = array_keys($this->columnMap['servicegroups']);
|
||||
$selectedServiceGroupColumns = array_intersect($serviceGroupColumns, array_keys($this->columns));
|
||||
if (! empty($selectedServiceGroupColumns)) {
|
||||
$group[] = 'sgo.object_id';
|
||||
$group[] = 'sg.servicegroup_id';
|
||||
$groupedTables['servicegroups'] = true;
|
||||
}
|
||||
}
|
||||
if ($this->hasJoinedVirtualTable('hostgroups')) {
|
||||
if (! isset($groupedTables['services'])) {
|
||||
$group[] = 'so.object_id';
|
||||
$group[] = 's.service_id';
|
||||
$groupedTables['services'] = true;
|
||||
}
|
||||
$hostGroupColumns = array_keys($this->columnMap['hostgroups']);
|
||||
$selectedHostGroupColumns = array_intersect($hostGroupColumns, array_keys($this->columns));
|
||||
if (! empty($selectedHostGroupColumns)) {
|
||||
$group[] = 'hgo.object_id';
|
||||
$group[] = 'hg.hostgroup_id';
|
||||
$groupedTables['hostgroups'] = true;
|
||||
}
|
||||
}
|
||||
if (! empty($groupedTables)) {
|
||||
foreach ($this->columns as $alias => $column) {
|
||||
if ($column instanceof Zend_Db_Expr || $column === '(NULL)') {
|
||||
continue;
|
||||
switch ($column) {
|
||||
case 'service_handled':
|
||||
case 'service_severity':
|
||||
case 'service_unhandled':
|
||||
if (! isset($groupedTables['hoststatus'])) {
|
||||
$groupColumns[] = 'hs.hoststatus_id';
|
||||
$groupedTables['hoststatus'] = true;
|
||||
}
|
||||
$tableName = $this->aliasToTableName(
|
||||
$this->hasAliasName($alias) ? $alias : $this->customAliasToAlias($alias)
|
||||
);
|
||||
if (isset($groupedTables[$tableName])) {
|
||||
continue;
|
||||
if (! isset($groupedTables['servicestatus'])) {
|
||||
$groupColumns[] = 'ss.servicestatus_id';
|
||||
$groupedTables['servicestatus'] = true;
|
||||
}
|
||||
switch ($tableName) {
|
||||
case 'hosts':
|
||||
$group[] = 'h.host_id';
|
||||
break;
|
||||
case 'hoststatus':
|
||||
$group[] = 'hs.hoststatus_id';
|
||||
break;
|
||||
case 'instances':
|
||||
$group[] = 'i.instance_id';
|
||||
break;
|
||||
case 'servicestatus':
|
||||
$group[] = 'ss.servicestatus_id';
|
||||
break;
|
||||
default:
|
||||
continue 2;
|
||||
}
|
||||
$groupedTables[$tableName] = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return $group;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue