mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-25 23:04:51 +02:00
parent
bbcd6e3a2b
commit
80c80436cf
@ -5,21 +5,43 @@ namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
|||||||
|
|
||||||
class ServicegroupQuery extends IdoQuery
|
class ServicegroupQuery extends IdoQuery
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected $allowCustomVars = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
protected $columnMap = array(
|
protected $columnMap = array(
|
||||||
|
'hostgroups' => array(
|
||||||
|
'hostgroup' => 'hgo.name1 COLLATE latin1_general_ci',
|
||||||
|
'hostgroup_alias' => 'hg.alias COLLATE latin1_general_ci',
|
||||||
|
'hostgroup_name' => 'hgo.name1'
|
||||||
|
),
|
||||||
|
'hosts' => array(
|
||||||
|
'host_alias' => 'h.alias',
|
||||||
|
'host_display_name' => 'h.display_name COLLATE latin1_general_ci',
|
||||||
|
),
|
||||||
'servicegroups' => array(
|
'servicegroups' => array(
|
||||||
'servicegroup' => 'sgo.name1 COLLATE latin1_general_ci',
|
'servicegroup' => 'sgo.name1 COLLATE latin1_general_ci',
|
||||||
'servicegroup_name' => 'sgo.name1',
|
'servicegroup_alias' => 'sg.alias COLLATE latin1_general_ci',
|
||||||
'servicegroup_alias' => 'sg.alias COLLATE latin1_general_ci'
|
'servicegroup_name' => 'sgo.name1'
|
||||||
|
),
|
||||||
|
'serviceobjects' => array(
|
||||||
|
'host' => 'so.name1 COLLATE latin1_general_ci',
|
||||||
|
'host_name' => 'so.name1',
|
||||||
|
'service' => 'so.name2 COLLATE latin1_general_ci',
|
||||||
|
'service_description' => 'so.name2'
|
||||||
),
|
),
|
||||||
'services' => array(
|
'services' => array(
|
||||||
'host' => 'so.name1 COLLATE latin1_general_ci',
|
'service_display_name' => 's.display_name COLLATE latin1_general_ci',
|
||||||
'host_name' => 'so.name1',
|
|
||||||
'service' => 'so.name2 COLLATE latin1_general_ci',
|
|
||||||
'service_host_name' => 'so.name1',
|
|
||||||
'service_description' => 'so.name2'
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
protected function joinBaseTables()
|
protected function joinBaseTables()
|
||||||
{
|
{
|
||||||
$this->select->from(
|
$this->select->from(
|
||||||
@ -27,15 +49,64 @@ class ServicegroupQuery extends IdoQuery
|
|||||||
array()
|
array()
|
||||||
)->join(
|
)->join(
|
||||||
array('sgo' => $this->prefix . 'objects'),
|
array('sgo' => $this->prefix . 'objects'),
|
||||||
'sg.servicegroup_object_id = sgo.' . $this->object_id
|
'sg.servicegroup_object_id = sgo.object_id',
|
||||||
. ' AND sgo.is_active = 1',
|
|
||||||
array()
|
array()
|
||||||
|
)->where(
|
||||||
|
'sgo.is_active = ?',
|
||||||
|
1
|
||||||
|
)
|
||||||
|
->where(
|
||||||
|
'sgo.objecttype_id = ?',
|
||||||
|
4
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->joinedVirtualTables = array('servicegroups' => true);
|
$this->joinedVirtualTables = array('servicegroups' => true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function joinServices()
|
/**
|
||||||
|
* Join host groups
|
||||||
|
*/
|
||||||
|
protected function joinHostgroups()
|
||||||
|
{
|
||||||
|
$this->requireVirtualTable('services');
|
||||||
|
$this->select->join(
|
||||||
|
array('hgm' => $this->prefix . 'hostgroup_members'),
|
||||||
|
'hgm.host_object_id = s.host_object_id',
|
||||||
|
array()
|
||||||
|
)->join(
|
||||||
|
array('hg' => $this->prefix . 'hostgroups'),
|
||||||
|
'hg.hostgroup_id = hgm.hostgroup_id',
|
||||||
|
array()
|
||||||
|
)->join(
|
||||||
|
array('hgo' => $this->prefix . 'objects'),
|
||||||
|
'hgo.object_id = hg.hostgroup_object_id',
|
||||||
|
array()
|
||||||
|
)->where(
|
||||||
|
'hgo.is_active = ?',
|
||||||
|
1
|
||||||
|
)
|
||||||
|
->where(
|
||||||
|
'hgo.objecttype_id = ?',
|
||||||
|
3
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Join hosts
|
||||||
|
*/
|
||||||
|
protected function joinHosts()
|
||||||
|
{
|
||||||
|
$this->requireVirtualTable('services');
|
||||||
|
$this->select->join(
|
||||||
|
array('h' => $this->prefix . 'hosts'),
|
||||||
|
'h.host_object_id = s.host_object_id',
|
||||||
|
array()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Join service objects
|
||||||
|
*/
|
||||||
|
protected function joinServiceobjects()
|
||||||
{
|
{
|
||||||
$this->select->join(
|
$this->select->join(
|
||||||
array('sgm' => $this->prefix . 'servicegroup_members'),
|
array('sgm' => $this->prefix . 'servicegroup_members'),
|
||||||
@ -43,7 +114,21 @@ class ServicegroupQuery extends IdoQuery
|
|||||||
array()
|
array()
|
||||||
)->join(
|
)->join(
|
||||||
array('so' => $this->prefix . 'objects'),
|
array('so' => $this->prefix . 'objects'),
|
||||||
'sgm.service_object_id = so.' . $this->object_id . ' AND so.is_active = 1',
|
'sgm.service_object_id = so.object_id',
|
||||||
|
array()
|
||||||
|
);
|
||||||
|
$this->group('sgo.name1');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Join services
|
||||||
|
*/
|
||||||
|
protected function joinServices()
|
||||||
|
{
|
||||||
|
$this->requireVirtualTable('serviceobjects');
|
||||||
|
$this->select->join(
|
||||||
|
array('s' => $this->prefix . 'services'),
|
||||||
|
's.service_object_id = so.object_id',
|
||||||
array()
|
array()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -3,43 +3,45 @@
|
|||||||
|
|
||||||
namespace Icinga\Module\Monitoring\DataView;
|
namespace Icinga\Module\Monitoring\DataView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Service group view */
|
||||||
class Servicegroup extends DataView
|
class Servicegroup extends DataView
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Retrieve columns provided by this view
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
public function getColumns()
|
public function getColumns()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
'servicegroup_name',
|
|
||||||
'servicegroup_alias',
|
'servicegroup_alias',
|
||||||
'host_name',
|
'servicegroup_name'
|
||||||
'service_host_name',
|
|
||||||
'service_description'
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve default sorting rules for particular columns. These involve sort order and potential additional to sort
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
public function getSortRules()
|
public function getFilterColumns()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
'servicegroup_name' => array(
|
'host', 'host_alias', 'host_display_name', 'host_name',
|
||||||
'order' => self::SORT_ASC
|
'hostgroup', 'hostgroup_alias', 'hostgroup_name',
|
||||||
),
|
'service', 'service_description', 'service_display_name',
|
||||||
'servicegroup_alias' => array(
|
'servicegroup'
|
||||||
'order' => self::SORT_ASC
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFilterColumns()
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function isValidFilterTarget($column)
|
||||||
{
|
{
|
||||||
return array('servicegroup', 'host', 'service');
|
if ($column[0] === '_'
|
||||||
|
&& preg_match('/^_(?:host|service)_/', $column)
|
||||||
|
) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return parent::isValidFilterTarget($column);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user