Skip to content

Commit

Permalink
monitoring; Remove HoststatehistoryQuery::getGroup()
Browse files Browse the repository at this point in the history
refs #9956
  • Loading branch information
lippserd committed Sep 30, 2015
1 parent 2f79c2f commit 178ebd2
Showing 1 changed file with 21 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ class HoststatehistoryQuery extends IdoQuery
*/
protected $allowCustomVars = true;

/**
* {@inheritdoc}
*/
protected $groupBase = array('statehistory' => array('hh.statehistory_id', 'ho.object_id'));

/**
* {@inheritdoc}
*/
protected $groupOrigin = array('hostgroups', 'services');

/**
* Array to map type names to type ids for query optimization
*
Expand All @@ -30,18 +40,6 @@ class HoststatehistoryQuery extends IdoQuery
'instances' => array(
'instance_name' => 'i.instance_name'
),
'statehistory' => array(
'host' => 'ho.name1 COLLATE latin1_general_ci',
'host_name' => 'ho.name1',
'object_type' => '(\'host\')'
),
'history' => array(
'type' => "(CASE WHEN hh.state_type = 1 THEN 'hard_state' ELSE 'soft_state' END)",
'timestamp' => 'UNIX_TIMESTAMP(hh.state_time)',
'object_id' => 'hh.object_id',
'state' => 'hh.state',
'output' => "('[ ' || hh.current_check_attempt || '/' || hh.max_check_attempts || ' ] ' || hh.output)",
),
'hostgroups' => array(
'hostgroup' => 'hgo.name1 COLLATE latin1_general_ci',
'hostgroup_alias' => 'hg.alias COLLATE latin1_general_ci',
Expand All @@ -61,7 +59,17 @@ class HoststatehistoryQuery extends IdoQuery
'service_description' => 'so.name2',
'service_display_name' => 's.display_name COLLATE latin1_general_ci',
'service_host_name' => 'so.name1'
)
),
'statehistory' => array(
'host' => 'ho.name1 COLLATE latin1_general_ci',
'host_name' => 'ho.name1',
'object_id' => 'hh.object_id',
'object_type' => '(\'host\')',
'output' => "('[ ' || hh.current_check_attempt || '/' || hh.max_check_attempts || ' ] ' || hh.output)",
'state' => 'hh.state',
'timestamp' => 'UNIX_TIMESTAMP(hh.state_time)',
'type' => "(CASE WHEN hh.state_type = 1 THEN 'hard_state' ELSE 'soft_state' END)"
),
);

/**
Expand Down Expand Up @@ -96,7 +104,6 @@ protected function joinBaseTables()
array()
);
$this->joinedVirtualTables['statehistory'] = true;
$this->joinedVirtualTables['history'] = true;
}

/**
Expand Down Expand Up @@ -179,20 +186,4 @@ protected function joinInstances()
array()
);
}

/**
* {@inheritdoc}
*/
public function getGroup()
{
$group = array();
if ($this->hasJoinedVirtualTable('hostgroups') || $this->hasJoinedVirtualTable('services')) {
$group = array('hh.statehistory_id', 'ho.object_id');
if ($this->hasJoinedVirtualTable('hosts')) {
$group[] = 'h.host_id';
}
}

return $group;
}
}

0 comments on commit 178ebd2

Please sign in to comment.