[icinga-checkins] icinga.org: icinga-api/mhein/default: * Added fields for service summary status count

git at icinga.org git at icinga.org
Mon Jul 19 17:43:05 CEST 2010


Module: icinga-api
Branch: mhein/default
Commit: 67f8d6f409f563e605b40ae460b050889e981981
URL:    https://git.icinga.org/?p=icinga-api.git;a=commit;h=67f8d6f409f563e605b40ae460b050889e981981

Author: Marius Hein <marius.hein at netways.de>
Date:   Mon Jul 19 17:42:04 2010 +0200

* Added fields for service summary status count
* Extend queries for summary status (hosts->servicegroups, mysql)

---

 objects/search/IcingaApiSearchIdo.php              |    2 +-
 .../data_interfaces/IcingaApiSearchIdoMysql.php    |   12 ++++++++++++
 .../data_interfaces/IcingaApiSearchIdoOci.php      |    1 +
 .../data_interfaces/IcingaApiSearchIdoOci8.php     |    1 +
 .../data_interfaces/IcingaApiSearchIdoPgsql.php    |    1 +
 5 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/objects/search/IcingaApiSearchIdo.php b/objects/search/IcingaApiSearchIdo.php
index 0854154..49eb6a4 100644
--- a/objects/search/IcingaApiSearchIdo.php
+++ b/objects/search/IcingaApiSearchIdo.php
@@ -408,7 +408,7 @@ class IcingaApiSearchIdo
 		 * @todo Find another syntax for including functions in column notation
 		 */
 		foreach ($this->joinTables as $id=>$tp) {
-			$this->joinTables[$id] = preg_replace('@^.*[^\w]+@', '', $tp);
+			$this->joinTables[$id] = preg_replace('@^.+\(@', '', $tp);
 		}
 
 		if ($numFilterMatches) {
diff --git a/objects/search/data_interfaces/IcingaApiSearchIdoMysql.php b/objects/search/data_interfaces/IcingaApiSearchIdoMysql.php
index 19c7269..444a81e 100644
--- a/objects/search/data_interfaces/IcingaApiSearchIdoMysql.php
+++ b/objects/search/data_interfaces/IcingaApiSearchIdoMysql.php
@@ -207,6 +207,12 @@ implements IcingaApiSearchIdoInterface {
 			${if_table:ohg,hg,hgm,oh:inner join ${TABLE_PREFIX}objects ohg on ohg.object_id = hg.hostgroup_object_id}
 			${if_table:cvsh,oh:inner join ${TABLE_PREFIX}customvariablestatus cvsh on oh.object_id = cvsh.object_id}
 			${if_table:cvsc,oc,cgm,cg,hcg,h,oh:-- inner join ${TABLE_PREFIX}customvariablestatus cvsc on oc.object_id = cvsc.object_id}
+
+			${if_table:osg,sg,s,oh:inner join ${TABLE_PREFIX}services s on s.host_object_id = oh.object_id}
+			${if_table:osg,sg,sgm:left join ${TABLE_PREFIX}servicegroup_members sgm on sgm.service_object_id = s.service_object_id}
+			${if_table:osg,sg,sgm:left join ${TABLE_PREFIX}servicegroups sg on sg.servicegroup_id = sgm.servicegroup_id}
+			${if_table:osg,sg,sgm:left join ${TABLE_PREFIX}objects osg on osg.object_id = sg.servicegroup_object_id}
+
 			where 1
 			${FILTER}
 			group by
@@ -234,6 +240,11 @@ implements IcingaApiSearchIdoInterface {
 			${if_table:cvsh,oh,s,os:inner join ${TABLE_PREFIX}customvariablestatus cvsh on oh.object_id = cvsh.object_id}
 			${if_table:cvss,os:inner join ${TABLE_PREFIX}customvariablestatus cvss on os.object_id = cvss.object_id}
 			${if_table:cvsc,oc,cgm,cg,scg,s,os:-- inner join ${TABLE_PREFIX}customvariablestatus cvsc on oc.object_id = cvsc.object_id}
+
+			${if_table:sgm,os:left join ${TABLE_PREFIX}servicegroup_members sgm on sgm.service_object_id = os.object_id}
+			${if_table:sg,sgm,os:left join ${TABLE_PREFIX}servicegroups sg on sg.servicegroup_id = sgm.servicegroup_id}
+			${if_table:osg,sg,sgm,os:left join ${TABLE_PREFIX}objects osg on osg.object_id = sg.servicegroup_object_id}
+
 			where 1
 			${FILTER}
 			group by
@@ -520,6 +531,7 @@ implements IcingaApiSearchIdoInterface {
 		'SERVICE_STATUS_ALL' => array('ss', '*'),
 		'SERVICE_CUSTOMVARIABLE_NAME' => array('cvss', 'varname'),
 		'SERVICE_CUSTOMVARIABLE_VALUE' => array('cvss', 'varvalue'),
+		'SERVICE_STATE_COUNT' => array('count(ss', 'current_state)'),
 
 			// Config vars
 		'CONFIG_VAR_ID' => array('cfv', 'configfilevariable_id'),
diff --git a/objects/search/data_interfaces/IcingaApiSearchIdoOci.php b/objects/search/data_interfaces/IcingaApiSearchIdoOci.php
index 68f0be8..91ffb9a 100644
--- a/objects/search/data_interfaces/IcingaApiSearchIdoOci.php
+++ b/objects/search/data_interfaces/IcingaApiSearchIdoOci.php
@@ -527,6 +527,7 @@ class IcingaApiSearchIdoOci
 		'SERVICE_STATUS_ALL' => array('ss', '*'),
 		'SERVICE_CUSTOMVARIABLE_NAME' => array('cvss', 'varname'),
 		'SERVICE_CUSTOMVARIABLE_VALUE' => array('cvss', 'varvalue'),
+		'SERVICE_STATE_COUNT' => array('count(ss', 'current_state)'),
 
 		// Config vars
 		'CONFIG_VAR_ID' => array('cfv', 'id'),
diff --git a/objects/search/data_interfaces/IcingaApiSearchIdoOci8.php b/objects/search/data_interfaces/IcingaApiSearchIdoOci8.php
index 5f2526e..56709f8 100644
--- a/objects/search/data_interfaces/IcingaApiSearchIdoOci8.php
+++ b/objects/search/data_interfaces/IcingaApiSearchIdoOci8.php
@@ -531,6 +531,7 @@ class IcingaApiSearchIdoOci8
 		'SERVICE_STATUS_ALL' => array('ss', '*'),
 		'SERVICE_CUSTOMVARIABLE_NAME' => array('cvss', 'varname'),
 		'SERVICE_CUSTOMVARIABLE_VALUE' => array('cvss', 'varvalue'),
+		'SERVICE_STATE_COUNT' => array('count(ss', 'current_state)'),
 
 		// Config vars
 		'CONFIG_VAR_ID' => array('cfv', 'id'),
diff --git a/objects/search/data_interfaces/IcingaApiSearchIdoPgsql.php b/objects/search/data_interfaces/IcingaApiSearchIdoPgsql.php
index 3a7a8d4..c6ad0c8 100644
--- a/objects/search/data_interfaces/IcingaApiSearchIdoPgsql.php
+++ b/objects/search/data_interfaces/IcingaApiSearchIdoPgsql.php
@@ -508,6 +508,7 @@ class IcingaApiSearchIdoPgsql
 		'SERVICE_STATUS_ALL' => array('ss', '*'),
 		'SERVICE_CUSTOMVARIABLE_NAME' => array('cvss', 'varname'),
 		'SERVICE_CUSTOMVARIABLE_VALUE' => array('cvss', 'varvalue'),
+		'SERVICE_STATE_COUNT' => array('count(ss', 'current_state)'),
 	
 		// Config vars
 		'CONFIG_VAR_ID' => array('cfv', 'configfilevariable_id'),





More information about the icinga-checkins mailing list