Skip to content
This repository has been archived by the owner on Jan 15, 2019. It is now read-only.

Commit

Permalink
rework sla zeugs to fit coding policy and stays disabled by default
Browse files Browse the repository at this point in the history
refs #2037
  • Loading branch information
Michael Friedrich committed Oct 28, 2011
1 parent 46e92c2 commit c3e0acf
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 36 deletions.
9 changes: 7 additions & 2 deletions module/idoutils/config/ido2db.cfg-sample.in
Expand Up @@ -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
Expand All @@ -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
2 changes: 0 additions & 2 deletions module/idoutils/include/sla.h
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions module/idoutils/src/dbhandlers.c
Expand Up @@ -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 */

/****************************************************************************/
Expand Down
5 changes: 3 additions & 2 deletions module/idoutils/src/ido2db.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
60 changes: 30 additions & 30 deletions module/idoutils/src/sla.c
Expand Up @@ -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.
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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",
Expand All @@ -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,
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit c3e0acf

Please sign in to comment.