[icinga-checkins] icinga.org: icinga-api/master: * Hostgroup summary query, target and field

git at icinga.org git at icinga.org
Wed Oct 21 12:01:45 CEST 2009


Module: icinga-api
Branch: master
Commit: fbe9b974d91438cd07b309df3494df7a46006f4b
URL:    https://git.icinga.org/?p=icinga-api.git;a=commit;h=fbe9b974d91438cd07b309df3494df7a46006f4b

Author: Marius Hein <marius.hein at netways.de>
Date:   Wed Oct 21 11:57:32 2009 +0200

* Hostgroup summary query, target and field

---

 objects/IcingaApiConstantsInterface.php      |    1 +
 objects/search/IcingaApiSearchColumnsIdo.php |    5 ++++-
 objects/search/IcingaApiSearchIdo.php        |   17 ++++++++++++++++-
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/objects/IcingaApiConstantsInterface.php b/objects/IcingaApiConstantsInterface.php
index 4c9c818..6ef327f 100644
--- a/objects/IcingaApiConstantsInterface.php
+++ b/objects/IcingaApiConstantsInterface.php
@@ -44,6 +44,7 @@ interface IcingaApiConstantsInterface {
 	const TARGET_SERVICE_STATUS_HISTORY = 'service_status_history';
 	const TARGET_HOST_PARENTS = 'host_parents';
 	const TARGET_NOTIFICATIONS = 'notifications';
+	const TARGET_HOSTGROUP_SUMMARY = 'hostgroup_summary';
 
 	// SEARCH TYPES
 	const SEARCH_TYPE_COUNT = 'count';
diff --git a/objects/search/IcingaApiSearchColumnsIdo.php b/objects/search/IcingaApiSearchColumnsIdo.php
index a3c8ad1..c34d145 100644
--- a/objects/search/IcingaApiSearchColumnsIdo.php
+++ b/objects/search/IcingaApiSearchColumnsIdo.php
@@ -183,7 +183,10 @@ class IcingaApiSearchColumnsIdo {
 		'NOTIFY_ESCALATED' => 'n.escalated notify_escalated',
 		'NOTIFY_NOTIFIED' => 'n.contacts_notified notify_notified',
 		'NOTIFY_OBJECT_ID' => 'on.object_id notify_object_id',
-		'NOTIFY_OBJECTTYPE_ID' => 'on.objecttype_id'
+		'NOTIFY_OBJECTTYPE_ID' => 'on.objecttype_id',
+		
+		// Summary queries
+		'HOSTGROUP_SUMMARY_COUNT' => 'Count(oh.object_id) hostgroup_summary_count'
 	
 	
 	);
diff --git a/objects/search/IcingaApiSearchIdo.php b/objects/search/IcingaApiSearchIdo.php
index 594c7af..ca830e8 100644
--- a/objects/search/IcingaApiSearchIdo.php
+++ b/objects/search/IcingaApiSearchIdo.php
@@ -258,7 +258,22 @@ class IcingaApiSearchIdo
 				${FILTER}
 				${GROUPBY}
 				${ORDERBY:n.start_time ASC}
-				${LIMIT}'
+				${LIMIT}',
+		self::TARGET_HOSTGROUP_SUMMARY => 
+			'select
+				${FIELDS}
+			FROM
+				${TABLE_PREFIX}hostgroups AS hg
+			Inner Join ${TABLE_PREFIX}objects AS ohg ON ohg.object_id = hg.hostgroup_object_id
+			Inner Join ${TABLE_PREFIX}hostgroup_members AS hgm ON hgm.hostgroup_id = hg.hostgroup_id
+			Inner Join ${TABLE_PREFIX}objects AS oh ON oh.object_id = hgm.host_object_id
+			Inner Join ${TABLE_PREFIX}hoststatus AS hs ON hs.host_object_id = oh.object_id
+			WHERE
+				ohg.is_active =  1
+				${FILTER}
+				${GROUPBY}
+				${ORDERBY:hs.current_state ASC}
+				${LIMIT}',
 	);
 
 	/*





More information about the icinga-checkins mailing list