[icinga-checkins] icinga.org: icinga-api/mhein/default: * Added downtime target (mysql)

git at icinga.org git at icinga.org
Thu Jan 13 16:53:15 CET 2011


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

Author: Marius Hein <marius.hein at netways.de>
Date:   Thu Jan 13 16:53:01 2011 +0100

* Added downtime target (mysql)

---

 .../data_interfaces/IcingaApiSearchIdoMysql.php    |   55 +++++++++++++++++++-
 1 files changed, 53 insertions(+), 2 deletions(-)

diff --git a/objects/search/data_interfaces/IcingaApiSearchIdoMysql.php b/objects/search/data_interfaces/IcingaApiSearchIdoMysql.php
index 6a70335..f836690 100644
--- a/objects/search/data_interfaces/IcingaApiSearchIdoMysql.php
+++ b/objects/search/data_interfaces/IcingaApiSearchIdoMysql.php
@@ -389,6 +389,37 @@ implements IcingaApiSearchIdoInterface {
 			${FILTER_AND}
 			${GROUPBY}
 			${ORDERBY}
+			${LIMIT}',
+		
+		self::TARGET_DOWNTIME => 
+			'select
+				distinct ${FIELDS}
+			from
+			${TABLE_PREFIX}downtimehistory 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
+			${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 = dt.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,dt:left join ${TABLE_PREFIX}instances i on i.instance_id = dt.instance_id}
+			
+			where not dt.actual_end_time
+			
+			${FILTER_AND}
+			${GROUPBY}
+			${ORDERBY}
 			${LIMIT}'
 		);
 			// COLUMNS
@@ -627,7 +658,7 @@ implements IcingaApiSearchIdoInterface {
 		'HOSTGROUP_SUMMARY_COUNT' => array('oh', 'object_id', 'count(%s)'),
 		'SERVICEGROUP_SUMMARY_COUNT' => array('ss', 'current_state', 'count(%s)'),
 		
-		// Comments
+			// Comments
 		'COMMENT_ID' => array('co', 'comment_id'),
 		'COMMENT_INSTANCE_ID' => array('co', 'instance_id'),
 		'COMMENT_ENTRY_TIME' => array('co', 'entry_time'),
@@ -642,8 +673,28 @@ implements IcingaApiSearchIdoInterface {
 		'COMMENT_IS_PERSISTENT' => array('co', 'is_persistent'),
 		'COMMENT_SOURCE' => array('co', 'comment_source'),
 		'COMMENT_EXPIRES' => array('co', 'expires'),
-		'COMMENT_EXPIRATION_TIME' => array('co', 'expiration_time')
+		'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')
 		);
 
 			/*





More information about the icinga-checkins mailing list