[icinga-checkins] icinga.org: icinga-api/master: * Added scheduled downtime target

git at icinga.org git at icinga.org
Tue Jan 18 10:03:22 CET 2011


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

Author: Marius Hein <marius.hein at netways.de>
Date:   Tue Jan 18 10:03:06 2011 +0100

* Added scheduled downtime target

---

 objects/IcingaApiConstantsInterface.php            |    3 +-
 .../data_interfaces/IcingaApiSearchIdoMysql.php    |   96 ++++++++++++++------
 2 files changed, 70 insertions(+), 29 deletions(-)

diff --git a/objects/IcingaApiConstantsInterface.php b/objects/IcingaApiConstantsInterface.php
index a55d597..db45257 100644
--- a/objects/IcingaApiConstantsInterface.php
+++ b/objects/IcingaApiConstantsInterface.php
@@ -54,7 +54,8 @@ interface IcingaApiConstantsInterface {
 	const TARGET_HOSTGROUP_SUMMARY = 'hostgroup_summary';
 	const TARGET_SERVICEGROUP_SUMMARY = 'servicegroup_summary';
 	const TARGET_COMMAND = 'command';	// livestatus only
-	const TARGET_DOWNTIME = 'downtime';	// livestatus only
+	const TARGET_DOWNTIME = 'downtime';
+	const TARGET_DOWNTIMEHISTORY = 'downtimehistory';
 	const TARGET_COMMENT = 'comment';
 	const TARGET_STATUS = 'status';		// livestatus only
 	const TARGET_HOST_SERVICE = 'host_service';
diff --git a/objects/search/data_interfaces/IcingaApiSearchIdoMysql.php b/objects/search/data_interfaces/IcingaApiSearchIdoMysql.php
index 04b9cfc..6c15a9b 100644
--- a/objects/search/data_interfaces/IcingaApiSearchIdoMysql.php
+++ b/objects/search/data_interfaces/IcingaApiSearchIdoMysql.php
@@ -391,11 +391,40 @@ implements IcingaApiSearchIdoInterface {
 			${ORDERBY}
 			${LIMIT}',
 		
+		self::TARGET_DOWNTIMEHISTORY => 
+			'select
+				distinct ${FIELDS}
+			from
+			${TABLE_PREFIX}downtimehistory AS dth
+			
+			left join ${TABLE_PREFIX}objects AS os ON os.object_id = dth.object_id
+			left join ${TABLE_PREFIX}services AS s ON s.service_object_id = os.object_id
+			${if_table:ss:left join ${TABLE_PREFIX}servicestatus ss on ss.service_object_id = os.object_id}
+			
+			left join ${TABLE_PREFIX}objects AS oh ON oh.object_id = s.host_object_id OR oh.object_id = dth.object_id
+			${if_table:h:inner join ${TABLE_PREFIX}hosts h on h.host_object_id = oh.object_id}
+			${if_table:hs:inner join ${TABLE_PREFIX}hoststatus hs on hs.host_object_id = oh.object_id}
+			
+			${if_table:hgm:left join ${TABLE_PREFIX}hostgroup_members AS hgm ON hgm.host_object_id = oh.object_id}
+			${if_table:hg,hgm:left join ${TABLE_PREFIX}hostgroups AS hg ON hg.hostgroup_id = hgm.hostgroup_id}
+			${if_table:ohg,hg,hgm:left join ${TABLE_PREFIX}objects AS ohg ON ohg.object_id = hg.hostgroup_object_id}
+			
+			${if_table:sgm:left join ${TABLE_PREFIX}servicegroup_members sgm on sgm.service_object_id = os.object_id}
+			${if_table: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}
+			
+			${if_table:i,dth:left join ${TABLE_PREFIX}instances i on i.instance_id = dth.instance_id}
+			
+			${FILTER}
+			${GROUPBY}
+			${ORDERBY}
+			${LIMIT}',
+		
 		self::TARGET_DOWNTIME => 
 			'select
 				distinct ${FIELDS}
 			from
-			${TABLE_PREFIX}downtimehistory AS dt
+			${TABLE_PREFIX}scheduleddowntime AS dt
 			
 			left join ${TABLE_PREFIX}objects AS os ON os.object_id = dt.object_id
 			left join ${TABLE_PREFIX}services AS s ON s.service_object_id = os.object_id
@@ -415,13 +444,7 @@ implements IcingaApiSearchIdoInterface {
 			
 			${if_table:i,dt:left join ${TABLE_PREFIX}instances i on i.instance_id = dt.instance_id}
 			
-			where 
-				not dt.was_cancelled 
-				and not(dt.was_started=0 and dt.scheduled_start_time<=NOW()) 
-				and not dt.actual_end_time
-				
-			
-			${FILTER_AND}
+			${FILTER}
 			${GROUPBY}
 			${ORDERBY}
 			${LIMIT}'
@@ -679,26 +702,43 @@ implements IcingaApiSearchIdoInterface {
 		'COMMENT_EXPIRES' => array('co', 'expires'),
 		'COMMENT_EXPIRATION_TIME' => array('co', 'expiration_time'),
 		
-			// Downtimes
-		'DOWNTIMEHISTORY_ID' => array ('dt', 'downtimehistory_id'),
-		'DOWNTIMEHISTORY_INSTANCE_ID' => array ('dt', 'instance_id'),
-		'DOWNTIMEHISTORY_DOWNTIME_TYPE' => array ('dt', 'downtime_type'),
-		'DOWNTIMEHISTORY_OBJECT_ID' => array ('dt', 'object_id'),
-		'DOWNTIMEHISTORY_ENTRY_TIME' => array ('dt', 'entry_time'),
-		'DOWNTIMEHISTORY_AUTHOR_NAME' => array ('dt', 'author_name'),
-		'DOWNTIMEHISTORY_COMMENT_DATA' => array ('dt', 'comment_data'),
-		'DOWNTIMEHISTORY_INTERNAL_DOWNTIME_ID' => array ('dt', 'internal_downtime_id'),
-		'DOWNTIMEHISTORY_TRIGGERED_BY_ID' => array ('dt', 'triggered_by_id'),
-		'DOWNTIMEHISTORY_IS_FIXED' => array ('dt', 'is_fixed'),
-		'DOWNTIMEHISTORY_DURATION' => array ('dt', 'duration'),
-		'DOWNTIMEHISTORY_SCHEDULED_START_TIME' => array ('dt', 'scheduled_start_time'),
-		'DOWNTIMEHISTORY_SCHEDULED_END_TIME' => array ('dt', 'scheduled_end_time'),
-		'DOWNTIMEHISTORY_WAS_STARTED' => array ('dt', 'was_started'),
-		'DOWNTIMEHISTORY_ACTUAL_START_TIME' => array ('dt', 'actual_start_time'),
-		'DOWNTIMEHISTORY_ACTUAL_START_TIME_USEC' => array ('dt', 'actual_start_time_usec'),
-		'DOWNTIMEHISTORY_ACTUAL_END_TIME' => array ('dt', 'actual_end_time'),
-		'DOWNTIMEHISTORY_ACTUAL_END_TIME_USEC' => array ('dt', 'actual_end_time_usec'),
-		'DOWNTIMEHISTORY_WAS_CANCELLED' => array ('dt', 'was_cancelled')
+			// Downtimehistory
+		'DOWNTIMEHISTORY_ID' => array ('dthh', 'downtimehistory_id'),
+		'DOWNTIMEHISTORY_INSTANCE_ID' => array ('dth', 'instance_id'),
+		'DOWNTIMEHISTORY_DOWNTIME_TYPE' => array ('dth', 'downtime_type'),
+		'DOWNTIMEHISTORY_OBJECT_ID' => array ('dth', 'object_id'),
+		'DOWNTIMEHISTORY_ENTRY_TIME' => array ('dth', 'entry_time'),
+		'DOWNTIMEHISTORY_AUTHOR_NAME' => array ('dth', 'author_name'),
+		'DOWNTIMEHISTORY_COMMENT_DATA' => array ('dth', 'comment_data'),
+		'DOWNTIMEHISTORY_INTERNAL_DOWNTIME_ID' => array ('dth', 'internal_downtime_id'),
+		'DOWNTIMEHISTORY_TRIGGERED_BY_ID' => array ('dth', 'triggered_by_id'),
+		'DOWNTIMEHISTORY_IS_FIXED' => array ('dth', 'is_fixed'),
+		'DOWNTIMEHISTORY_DURATION' => array ('dth', 'duration'),
+		'DOWNTIMEHISTORY_SCHEDULED_START_TIME' => array ('dth', 'scheduled_start_time'),
+		'DOWNTIMEHISTORY_SCHEDULED_END_TIME' => array ('dth', 'scheduled_end_time'),
+		'DOWNTIMEHISTORY_WAS_STARTED' => array ('dth', 'was_started'),
+		'DOWNTIMEHISTORY_ACTUAL_START_TIME' => array ('dth', 'actual_start_time'),
+		'DOWNTIMEHISTORY_ACTUAL_START_TIME_USEC' => array ('dth', 'actual_start_time_usec'),
+		'DOWNTIMEHISTORY_ACTUAL_END_TIME' => array ('dth', 'actual_end_time'),
+		'DOWNTIMEHISTORY_ACTUAL_END_TIME_USEC' => array ('dth', 'actual_end_time_usec'),
+		'DOWNTIMEHISTORY_WAS_CANCELLED' => array ('dth', 'was_cancelled'),
+		
+		'DOWNTIME_ID' => array ('dt', 'scheduleddowntime_id'),
+		'DOWNTIME_INSTANCE_ID' => array ('dt', 'instance_id'),
+		'DOWNTIME_DOWNTIME_TYPE' => array ('dt', 'downtime_type'),
+		'DOWNTIME_OBJECT_ID' => array ('dt', 'object_id'),
+		'DOWNTIME_ENTRY_TIME' => array ('dt', 'entry_time'),
+		'DOWNTIME_AUTHOR_NAME' => array ('dt', 'author_name'),
+		'DOWNTIME_COMMENT_DATA' => array ('dt', 'comment_data'),
+		'DOWNTIME_INTERNAL_DOWNTIME_ID' => array ('dt', 'internal_downtime_id'),
+		'DOWNTIME_TRIGGERED_BY_ID' => array ('dt', 'triggered_by_id'),
+		'DOWNTIME_IS_FIXED' => array ('dt', 'is_fixed'),
+		'DOWNTIME_DURATION' => array ('dt', 'duration'),
+		'DOWNTIME_SCHEDULED_START_TIME' => array ('dt', 'scheduled_start_time'),
+		'DOWNTIME_SCHEDULED_END_TIME' => array ('dt', 'scheduled_end_time'),
+		'DOWNTIME_WAS_STARTED' => array ('dt', 'was_started'),
+		'DOWNTIME_ACTUAL_START_TIME' => array ('dt', 'actual_start_time'),
+		'DOWNTIME_ACTUAL_START_TIME_USEC' => array ('dt', 'actual_start_time_usec')
 		);
 
 			/*





More information about the icinga-checkins mailing list