[icinga-checkins] icinga.org: icinga-core/test/ido: Fixed SLA queries.

git at icinga.org git at icinga.org
Wed Nov 16 15:44:14 CET 2011


Module: icinga-core
Branch: test/ido
Commit: 9f62ac7d4187dad81bfb71ab0074df0426771eec
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=9f62ac7d4187dad81bfb71ab0074df0426771eec

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Wed Nov 16 14:22:19 2011 +0100

Fixed SLA queries.

---

 module/idoutils/src/sla.c |   70 ++++++++++++++++++++++----------------------
 1 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/module/idoutils/src/sla.c b/module/idoutils/src/sla.c
index 25e18ad..3b607cf 100644
--- a/module/idoutils/src/sla.c
+++ b/module/idoutils/src/sla.c
@@ -182,14 +182,14 @@ int sla_query_states(ido2db_idi *idi, unsigned long object_id,
 		return -1;
 	}
 
-	rc = asprintf(&query, "SELECT slahistory_id,"
-	              "%s AS start_time, %s AS end_time, %s AS acknowledgement_time,"
-	              "state, state_type, scheduled_downtime"
-	              "FROM %s"
-	              "WHERE instance_id = '%lu' AND object_id = '%lu' AND"
-	              "((start_time > %s AND start_time < %s) OR"
-	              " (end_time > %s AND end_time < %s) OR"
-	              " (start_time < %s AND end_time > %s) OR"
+	rc = asprintf(&query, "SELECT slahistory_id, "
+	              "%s AS start_time, %s AS end_time, %s AS acknowledgement_time, "
+	              "state, state_type, scheduled_downtime "
+	              "FROM %s "
+	              "WHERE instance_id = '%lu' AND object_id = '%lu' AND "
+	              "((start_time > %s AND start_time < %s) OR "
+	              " (end_time > %s AND end_time < %s) OR "
+	              " (start_time < %s AND end_time > %s) OR "
 	              " (end_time IS NULL))",
 	              start_time_sql, end_time_sql, ack_time_sql,
 	              ido2db_db_tablenames[IDO2DB_DBTABLE_SLAHISTORY],
@@ -400,12 +400,12 @@ int sla_save_state(ido2db_idi *idi, sla_state_t *state) {
 	}
 
 	if (state->persistent) {
-		rc = asprintf(&query, "UPDATE %s"
-		              "SET start_time = %s,"
-		              "end_time = %s,"
-		              "acknowledgement_time = %s,"
-		              "state = %d, state_type = %d,"
-		              "scheduled_downtime = %d"
+		rc = asprintf(&query, "UPDATE %s "
+		              "SET start_time = %s, "
+		              "end_time = %s, "
+		              "acknowledgement_time = %s, "
+		              "state = %d, state_type = %d, "
+		              "scheduled_downtime = %d "
 		              "WHERE slahistory_id = '%lu'",
 		              ido2db_db_tablenames[IDO2DB_DBTABLE_SLAHISTORY],
 		              (start_time_str != NULL) ? start_time_str : "NULL",
@@ -422,16 +422,16 @@ int sla_save_state(ido2db_idi *idi, sla_state_t *state) {
 		if (rc < 0)
 			return -1;
 	} else {
-		rc = asprintf(&query, "INSERT INTO %s"
-		              "(instance_id,"
-		              " start_time,"
-		              " end_time,"
-		              " acknowledgement_time,"
-		              " object_id, state,"
-		              " state_type, scheduled_downtime)"
-		              "VALUES"
-		              "('%lu', %s, %s,"
-		              " %s, '%lu', '%d',"
+		rc = asprintf(&query, "INSERT INTO %s "
+		              "(instance_id, "
+		              " start_time, "
+		              " end_time, "
+		              " acknowledgement_time, "
+		              " object_id, state, "
+		              " state_type, scheduled_downtime) "
+		              "VALUES "
+		              "('%lu', %s, %s, "
+		              " %s, '%lu', '%d', "
 		              " '%d', '%d')",
 		              ido2db_db_tablenames[IDO2DB_DBTABLE_SLAHISTORY],
 		              state->instance_id,
@@ -748,15 +748,15 @@ int sla_query_downtime(ido2db_idi *idi, unsigned long object_id,
 		return -1;
 	}
 
-	rc = asprintf(&query, "SELECT downtimehistory_id,"
-	              "%s AS actual_start_time, %s AS actual_end_time,"
-	              "%s AS scheduled_start_time, %s AS scheduled_end_time,"
-	              "is_fixed, duration"
-	              "FROM %s"
-	              "WHERE instance_id = '%lu' AND object_id = '%lu' AND"
-	              "((actual_start_time > %s AND actual_start_time < %s) OR"
-	              " (actual_end_time > %s AND actual_end_time < %s) OR"
-	              " (actual_start_time < %s AND actual_end_time > %s) OR"
+	rc = asprintf(&query, "SELECT downtimehistory_id, "
+	              "%s AS actual_start_time, %s AS actual_end_time, "
+	              "%s AS scheduled_start_time, %s AS scheduled_end_time, "
+	              "is_fixed, duration "
+	              "FROM %s "
+	              "WHERE instance_id = '%lu' AND object_id = '%lu' AND "
+	              "((actual_start_time > %s AND actual_start_time < %s) OR "
+	              " (actual_end_time > %s AND actual_end_time < %s) OR "
+	              " (actual_start_time < %s AND actual_end_time > %s) OR "
 	              " (actual_end_time IS NULL))",
 	              actual_start_sql, actual_end_sql,
 	              scheduled_start_sql, scheduled_end_sql,
@@ -1047,8 +1047,8 @@ static int sla_query_dependent_services(ido2db_idi *idi,
 
 #ifdef USE_LIBDBI
 
-	rc = asprintf(&query, "SELECT service_object_id"
-	              "FROM %s"
+	rc = asprintf(&query, "SELECT service_object_id "
+	              "FROM %s "
 	              "WHERE instance_id = '%lu' AND host_object_id = '%lu'",
 	              ido2db_db_tablenames[IDO2DB_DBTABLE_SERVICES],
 	              idi->dbinfo.instance_id, parent_object_id);





More information about the icinga-checkins mailing list