diff --git a/module/idoutils/config/ido2db.cfg-sample.in b/module/idoutils/config/ido2db.cfg-sample.in index 2d635ddd0..b70743c82 100644 --- a/module/idoutils/config/ido2db.cfg-sample.in +++ b/module/idoutils/config/ido2db.cfg-sample.in @@ -296,6 +296,8 @@ debug_readable_timestamp=0 oci_errors_to_syslog=1 + + # ORACLE TRACE LEVEL # This setting activates oracle session trace for each ido2db connection using trace event # Level value must be one of the currently supported values (1,4,8,12) or 0 for off @@ -309,7 +311,10 @@ oci_errors_to_syslog=1 oracle_trace_level=0 -# SLA feature -# This setting enables collection of SLA data in the icinga_slahistory table + + +# ENABLE SLA +# This setting enables collection of SLA data in the slahistory table +# Values: 0 = disabled, 1 = enabled enable_sla=0 diff --git a/module/idoutils/include/sla.h b/module/idoutils/include/sla.h index 52864357b..cc1cdc0cf 100644 --- a/module/idoutils/include/sla.h +++ b/module/idoutils/include/sla.h @@ -57,8 +57,6 @@ typedef struct sla_downtime_list_s { sla_downtime_t downtimes[0]; } sla_downtime_list_t; -extern int enable_sla; - sla_state_t *sla_alloc_state(unsigned long instance_id, unsigned long object_id); void sla_free_state(sla_state_t *state); diff --git a/module/idoutils/src/dbhandlers.c b/module/idoutils/src/dbhandlers.c index e4a278114..396371be4 100644 --- a/module/idoutils/src/dbhandlers.c +++ b/module/idoutils/src/dbhandlers.c @@ -29,6 +29,8 @@ extern char *ido2db_db_tablenames[IDO2DB_MAX_DBTABLES]; extern ido2db_dbconfig ido2db_db_settings; /* for tables cleanup settings */ +extern int enable_sla; + int dummy; /* reduce compiler warnings */ /****************************************************************************/ diff --git a/module/idoutils/src/ido2db.c b/module/idoutils/src/ido2db.c index 205f108bb..e9f30f83e 100644 --- a/module/idoutils/src/ido2db.c +++ b/module/idoutils/src/ido2db.c @@ -86,6 +86,7 @@ int ido2db_debug_verbosity = IDO2DB_DEBUGV_BASIC; FILE *ido2db_debug_file_fp = NULL; unsigned long ido2db_max_debug_file_size = 0L; +int enable_sla = IDO_FALSE; int ido2db_debug_readable_timestamp = IDO_FALSE; int stop_signal_detected = IDO_FALSE; @@ -584,8 +585,8 @@ int ido2db_process_config_var(char *arg) { ido2db_db_settings.oci_errors_to_syslog = (atoi(val) > 0) ? IDO_TRUE : IDO_FALSE; } else if (!strcmp(var, "oracle_trace_level")) { ido2db_db_settings.oracle_trace_level = atoi(val); - } else if (strcmp(var, "enable_sla") == 0) { - enable_sla = strtoul(val, NULL, 0); + } else if (!strcmp(var, "enable_sla")) { + enable_sla = (atoi(val) > 0) ? IDO_TRUE : IDO_FALSE; } else if (!strcmp(var, "debug_readable_timestamp")) { ido2db_debug_readable_timestamp = (atoi(val) > 0) ? IDO_TRUE : IDO_FALSE; } diff --git a/module/idoutils/src/sla.c b/module/idoutils/src/sla.c index e08dd3414..5c3dc7478 100644 --- a/module/idoutils/src/sla.c +++ b/module/idoutils/src/sla.c @@ -23,7 +23,7 @@ #include "../../../include/broker.h" #include "../../../include/comments.h" -int enable_sla = 0; +extern int enable_sla; /** * Allocates and initializes a new SLA state history entry. @@ -182,11 +182,11 @@ int sla_query_states(ido2db_idi *idi, unsigned long object_id, return -1; } - rc = asprintf(&query, "SELECT slahistory_id,\n" - "%s AS start_time, %s AS end_time, %s AS acknowledgement_time,\n" - "state, state_type, scheduled_downtime\n" - "FROM %s\n" - "WHERE instance_id = '%lu' AND object_id = '%lu' AND\n" + 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" @@ -398,12 +398,12 @@ int sla_save_state(ido2db_idi *idi, sla_state_t *state) { } if (state->persistent) { - rc = asprintf(&query, "UPDATE %s\n" - "SET start_time = %s,\n" - "end_time = %s,\n" - "acknowledgement_time = %s,\n" - "state = %d, state_type = %d,\n" - "scheduled_downtime = %d\n" + 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", @@ -420,16 +420,16 @@ int sla_save_state(ido2db_idi *idi, sla_state_t *state) { if (rc < 0) return -1; } else { - rc = asprintf(&query, "INSERT INTO %s\n" - "(instance_id,\n" - " start_time,\n" - " end_time,\n" - " acknowledgement_time,\n" - " object_id, state,\n" - " state_type, scheduled_downtime)\n" - "VALUES\n" - "('%lu', %s, %s,\n" - " %s, '%lu', '%d',\n" + 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, @@ -746,12 +746,12 @@ int sla_query_downtime(ido2db_idi *idi, unsigned long object_id, return -1; } - rc = asprintf(&query, "SELECT downtimehistory_id,\n" - "%s AS actual_start_time, %s AS actual_end_time,\n" - "%s AS scheduled_start_time, %s AS scheduled_end_time,\n" - "is_fixed, duration\n" - "FROM %s\n" - "WHERE instance_id = '%lu' AND object_id = '%lu' AND\n" + 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" @@ -1044,8 +1044,8 @@ static int sla_query_dependent_services(ido2db_idi *idi, #ifdef USE_LIBDBI - rc = asprintf(&query, "SELECT service_object_id\n" - "FROM %s\n" + 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);