[icinga-checkins] icinga.org: icinga-api/cdoebler/default: * Added notification target, query and fields

git at icinga.org git at icinga.org
Tue Oct 20 14:59:08 CEST 2009


Module: icinga-api
Branch: cdoebler/default
Commit: 55961d420e385d9bcdcba75193639ea882782844
URL:    https://git.icinga.org/?p=icinga-api.git;a=commit;h=55961d420e385d9bcdcba75193639ea882782844

Author: Marius Hein <marius.hein at netways.de>
Date:   Tue Oct 13 12:19:52 2009 +0200

* Added notification target, query and fields

---

 objects/IcingaApiConstantsInterface.php      |    1 +
 objects/search/IcingaApiSearchColumnsIdo.php |   39 ++++++++++++++++++++++++-
 objects/search/IcingaApiSearchIdo.php        |   16 ++++++++++
 3 files changed, 54 insertions(+), 2 deletions(-)

diff --git a/objects/IcingaApiConstantsInterface.php b/objects/IcingaApiConstantsInterface.php
index c97b004..4c9c818 100644
--- a/objects/IcingaApiConstantsInterface.php
+++ b/objects/IcingaApiConstantsInterface.php
@@ -43,6 +43,7 @@ interface IcingaApiConstantsInterface {
 	const TARGET_HOST_STATUS_HISTORY = 'host_status_history';
 	const TARGET_SERVICE_STATUS_HISTORY = 'service_status_history';
 	const TARGET_HOST_PARENTS = 'host_parents';
+	const TARGET_NOTIFICATIONS = 'notifications';
 
 	// SEARCH TYPES
 	const SEARCH_TYPE_COUNT = 'count';
diff --git a/objects/search/IcingaApiSearchColumnsIdo.php b/objects/search/IcingaApiSearchColumnsIdo.php
index 1150ffd..a3c8ad1 100644
--- a/objects/search/IcingaApiSearchColumnsIdo.php
+++ b/objects/search/IcingaApiSearchColumnsIdo.php
@@ -166,7 +166,25 @@ class IcingaApiSearchColumnsIdo {
 		'STATEHISTORY_MAX_CHECK_ATTEMPTS' => 'sh.max_check_attempts statehistory_max_check_attempts',
 		'STATEHISTORY_LAST_STATE' => 'sh.last_state statehistory_last_state',
 		'STATEHISTORY_LAST_HARD_STATE' => 'sh.last_hard_state statehistory_last_hard_state',
-		'STATEHISTORY_OUTPUT' => 'sh.output statehistory_output'
+		'STATEHISTORY_OUTPUT' => 'sh.output statehistory_output',
+	
+		// Notifications
+		'NOTIFY_ID' => 'n.notification_id notify_id',
+		'NOTIFY_INSTANCE_ID' => 'n.instance_id notify_instance_id',
+		'NOTIFY_TYPE' => 'n.notification_type notify_type',
+		'NOTIFY_REASON' => 'n.notification_reason notify_reason',
+		'NOTIFY_STARTTIME' => 'n.start_time notify_starttime',
+		'NOTIFY_STARTTIME_USEC' => 'n.start_time_usec notify_starttime_usec',
+		'NOTIFY_ENDTIME' => 'n.end_time notify_endtime',
+		'NOTIFY_ENDTIME_USEC' => 'n.end_time_usec notify_endtime_usec',
+		'NOTIFY_STATE' => 'n.state notify_state',
+		'NOTIFY_OUTPUT' => 'n.output notify_output',
+		'NOTIFY_LONG_OUTPUT' => 'n.long_output notify_long_output',
+		'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'
+	
 	
 	);
 
@@ -309,7 +327,24 @@ class IcingaApiSearchColumnsIdo {
 		'STATEHISTORY_MAX_CHECK_ATTEMPTS' => 'sh.max_check_attempts',
 		'STATEHISTORY_LAST_STATE' => 'sh.last_state',
 		'STATEHISTORY_LAST_HARD_STATE' => 'sh.last_hard_state',
-		'STATEHISTORY_OUTPUT' => 'sh.output'
+		'STATEHISTORY_OUTPUT' => 'sh.output',
+	
+		// Notifications
+		'NOTIFY_ID' => 'n.notification_id',
+		'NOTIFY_INSTANCE_ID' => 'n.instance_id',
+		'NOTIFY_TYPE' => 'n.notification_type',
+		'NOTIFY_REASON' => 'n.notification_reason',
+		'NOTIFY_STARTTIME' => 'n.start_time',
+		'NOTIFY_STARTTIME_USEC' => 'n.start_time_usec',
+		'NOTIFY_ENDTIME' => 'n.end_time',
+		'NOTIFY_ENDTIME_USEC' => 'n.end_time_usec',
+		'NOTIFY_STATE' => 'n.state',
+		'NOTIFY_OUTPUT' => 'n.output',
+		'NOTIFY_LONG_OUTPUT' => 'n.long_output',
+		'NOTIFY_ESCALATED' => 'n.escalated',
+		'NOTIFY_NOTIFIED' => 'n.contacts_notified',
+		'NOTIFY_OBJECT_ID' => 'on.object_id',
+		'NOTIFY_OBJECTTYPE_ID' => 'on.objecttype_id'
 	);
 	
 }
diff --git a/objects/search/IcingaApiSearchIdo.php b/objects/search/IcingaApiSearchIdo.php
index ea63778..0a8c893 100644
--- a/objects/search/IcingaApiSearchIdo.php
+++ b/objects/search/IcingaApiSearchIdo.php
@@ -237,6 +237,22 @@ class IcingaApiSearchIdo
 				${GROUPBY}
 				${ORDERBY:host_parent_name asc, host_child_name asc}
 				${LIMIT}',
+		self::TARGET_NOTIFICATIONS => 
+			'select
+				${FIELDS}
+			from
+				${TABLE_PREFIX}notifications n
+			Inner Join ${TABLE_PREFIX}objects AS `on` ON `on`.object_id = n.object_id
+			Left Join ${TABLE_PREFIX}services AS s ON s.service_object_id = `on`.object_id
+			Left Join ${TABLE_PREFIX}hosts ON ${TABLE_PREFIX}hosts.host_object_id = `on`.object_id OR ${TABLE_PREFIX}hosts.host_object_id = s.host_object_id
+			Left Join ${TABLE_PREFIX}objects AS oh ON oh.object_id = ${TABLE_PREFIX}hosts.host_object_id
+			Left Join ${TABLE_PREFIX}objects AS os ON os.object_id = s.service_object_id
+			where
+				`on`.is_active =  1
+				${FILTER}
+				${GROUPBY}
+				${ORDERBY:n.start_time ASC}
+				${LIMIT}'
 	);
 
 	/*





More information about the icinga-checkins mailing list