Search
j0ke.net Open Build Service
>
Projects
>
server:monitoring
>
icinga110
> icinga-core.git-44b8ee765c69eac913dd3fb0b505b8f73d9888b2.txt
Sign Up
|
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File icinga-core.git-44b8ee765c69eac913dd3fb0b505b8f73d9888b2.txt of Package icinga110 (Revision 2)
Currently displaying revision
2
,
show latest
From: Michael Friedrich <Michael.Friedrich@netways.de> Date: Thu, 26 Sep 2013 20:33:19 +0000 (+0200) Subject: idoutils: add check_source support. X-Git-Tag: v1.10.0-beta~37 X-Git-Url: https://git.icinga.org/?p=icinga-core.git;a=commitdiff_plain;h=44b8ee765c69eac913dd3fb0b505b8f73d9888b2;hp=66557d4cb65018b7a7d2aff0c47f866a90ad273e idoutils: add check_source support. refs #4709 --- diff --git a/module/idoutils/db/mysql/mysql.sql b/module/idoutils/db/mysql/mysql.sql index 91da5b0..fa4babf 100644 --- a/module/idoutils/db/mysql/mysql.sql +++ b/module/idoutils/db/mysql/mysql.sql @@ -703,6 +703,7 @@ CREATE TABLE IF NOT EXISTS icinga_hoststatus ( output TEXT character set latin1 default '', long_output TEXT default '', perfdata TEXT character set latin1 default '', + check_source TEXT character set latin1 default '', current_state smallint default 0, has_been_checked smallint default 0, should_be_scheduled smallint default 0, @@ -1179,6 +1180,7 @@ CREATE TABLE IF NOT EXISTS icinga_servicestatus ( output TEXT character set latin1 default '', long_output TEXT default '', perfdata TEXT character set latin1 default '', + check_source TEXT character set latin1 default '', current_state smallint default 0, has_been_checked smallint default 0, should_be_scheduled smallint default 0, diff --git a/module/idoutils/db/oracle/create_icinga_objects_oracle.sql b/module/idoutils/db/oracle/create_icinga_objects_oracle.sql index 265d16d..55727bf 100644 --- a/module/idoutils/db/oracle/create_icinga_objects_oracle.sql +++ b/module/idoutils/db/oracle/create_icinga_objects_oracle.sql @@ -1071,6 +1071,7 @@ CREATE TABLE hoststatus ( output clob, long_output clob, perfdata clob, + check_source varchar2(255) default '', current_state integer default 0 , has_been_checked integer default 0 , should_be_scheduled integer default 0 , @@ -1614,6 +1615,7 @@ CREATE TABLE servicestatus ( output clob, long_output clob, perfdata clob, + check_source varchar2(255) default '', current_state integer default 0 , has_been_checked integer default 0 , should_be_scheduled integer default 0 , diff --git a/module/idoutils/db/pgsql/pgsql.sql b/module/idoutils/db/pgsql/pgsql.sql index a7d455b..2d79747 100644 --- a/module/idoutils/db/pgsql/pgsql.sql +++ b/module/idoutils/db/pgsql/pgsql.sql @@ -732,6 +732,7 @@ CREATE TABLE icinga_hoststatus ( output TEXT default '', long_output TEXT default '', perfdata TEXT default '', + check_source TEXT default '', current_state INTEGER default 0, has_been_checked INTEGER default 0, should_be_scheduled INTEGER default 0, @@ -1208,6 +1209,7 @@ CREATE TABLE icinga_servicestatus ( output TEXT default '', long_output TEXT default '', perfdata TEXT default '', + check_source TEXT default '', current_state INTEGER default 0, has_been_checked INTEGER default 0, should_be_scheduled INTEGER default 0, diff --git a/module/idoutils/include/protoapi.h b/module/idoutils/include/protoapi.h index 63f3198..1cbf924 100644 --- a/module/idoutils/include/protoapi.h +++ b/module/idoutils/include/protoapi.h @@ -109,7 +109,7 @@ /************** COMMON DATA ATTRIBUTES **************/ -#define IDO_MAX_DATA_TYPES 272 +#define IDO_MAX_DATA_TYPES 273 #define IDO_DATA_NONE 0 @@ -394,4 +394,5 @@ #define IDO_DATA_DOWNTIMETRIGGERTIME 269 #define IDO_DATA_DISABLED_NOTIFICATIONS_EXPIRE_TIME 270 #define IDO_DATA_CUSTOMVARIABLESTATUS 271 /* seperate type from CUSTOMVARIABLE config */ +#define IDO_DATA_CHECKSOURCE 272 #endif diff --git a/module/idoutils/src/db.c b/module/idoutils/src/db.c index 881b4f0..bb07063 100644 --- a/module/idoutils/src/db.c +++ b/module/idoutils/src/db.c @@ -3949,7 +3949,7 @@ int ido2db_oci_prepared_statement_hoststatus(ido2db_idi *idi) { "process_performance_data=:X39, obsess_over_host=:X40, " "modified_host_attributes=:X41, event_handler=:X42, " "check_command=:X43, normal_check_interval=:X44, " - "retry_check_interval=:X45, check_timeperiod_object_id=:X46 " + "retry_check_interval=:X45, check_timeperiod_object_id=:X46, check_source=:X47 " "WHEN NOT MATCHED THEN " "INSERT (id, instance_id, host_object_id, status_update_time, output, long_output, perfdata, " "current_state, has_been_checked, should_be_scheduled, current_check_attempt, " @@ -3963,7 +3963,7 @@ int ido2db_oci_prepared_statement_hoststatus(ido2db_idi *idi) { "percent_state_change, latency, execution_time, scheduled_downtime_depth, " "failure_prediction_enabled, process_performance_data, obsess_over_host, " "modified_host_attributes, event_handler, check_command, normal_check_interval, " - "retry_check_interval, check_timeperiod_object_id) " + "retry_check_interval, check_timeperiod_object_id, check_source) " "VALUES (seq_hoststatus.nextval, :X1, :X2, unixts2localts(:X3), :X4i, :X5i, :X6i, " ":X7, :X8, :X9, :X10, " ":X11, unixts2localts(:X12), unixts2localts(:X13), :X14, " @@ -3976,7 +3976,7 @@ int ido2db_oci_prepared_statement_hoststatus(ido2db_idi *idi) { ":X34, :X35, :X36, :X37, " ":X38, :X39, :X40, " ":X41, :X42, :X43, :X44, " - ":X45, :X46)", + ":X45, :X46, :X47)", ido2db_db_tablenames[IDO2DB_DBTABLE_HOSTSTATUS]) == -1) { buf = NULL; } @@ -4086,7 +4086,7 @@ int ido2db_oci_prepared_statement_servicestatus(ido2db_idi *idi) { "failure_prediction_enabled=:X39, process_performance_data=:X40, " "obsess_over_service=:X41, modified_service_attributes=:X42, " "event_handler=:X43, check_command=:X44, normal_check_interval=:X45, " - "retry_check_interval=:X46, check_timeperiod_object_id=:X47 " + "retry_check_interval=:X46, check_timeperiod_object_id=:X47, check_source=:X48 " "WHEN NOT MATCHED THEN " "INSERT " "(id, instance_id, service_object_id, status_update_time, " @@ -4102,7 +4102,7 @@ int ido2db_oci_prepared_statement_servicestatus(ido2db_idi *idi) { "percent_state_change, latency, execution_time, scheduled_downtime_depth, " "failure_prediction_enabled, process_performance_data, obsess_over_service, " "modified_service_attributes, event_handler, check_command, " - "normal_check_interval, retry_check_interval, check_timeperiod_object_id) " + "normal_check_interval, retry_check_interval, check_timeperiod_object_id, check_source) " "VALUES " "(seq_servicestatus.nextval, :X1, :X2, unixts2localts(:X3), " ":X4i, :X5i, :X6i, :X7, :X8, :X9, :X10, :X11, " @@ -4112,7 +4112,7 @@ int ido2db_oci_prepared_statement_servicestatus(ido2db_idi *idi) { ":X22, unixts2localts(:X23), unixts2localts(:X24), :X25, " ":X26, :X27, :X28, :X29, :X30, :X31, :X32, :X33, " ":X34, :X35, :X36, :X37, :X38, :X39, :X40, :X41, :X42, " - ":X43, :X44, :X45, :X46, :X47)", + ":X43, :X44, :X45, :X46, :X47, :X48)", ido2db_db_tablenames[IDO2DB_DBTABLE_SERVICESTATUS]) == -1) { buf = NULL; } diff --git a/module/idoutils/src/dbhandlers.c b/module/idoutils/src/dbhandlers.c index fa2b07c..876f85b 100644 --- a/module/idoutils/src/dbhandlers.c +++ b/module/idoutils/src/dbhandlers.c @@ -3513,11 +3513,11 @@ int ido2db_handle_hoststatusdata(ido2db_idi *idi) { double normal_check_interval = 0.0; double retry_check_interval = 0.0; char *ts[10]; - char *es[5]; + char *es[6]; unsigned long object_id = 0L; unsigned long check_timeperiod_object_id = 0L; int x = 0; - void *data[56]; + void *data[57]; ido2db_log_debug_info(IDO2DB_DEBUGL_PROCESSINFO, 2, "ido2db_handle_hoststatusdata() start\n"); @@ -3575,6 +3575,7 @@ int ido2db_handle_hoststatusdata(ido2db_idi *idi) { es[2] = ido2db_db_escape_string(idi, idi->buffered_input[IDO_DATA_PERFDATA]); es[3] = ido2db_db_escape_string(idi, idi->buffered_input[IDO_DATA_EVENTHANDLER]); es[4] = ido2db_db_escape_string(idi, idi->buffered_input[IDO_DATA_CHECKCOMMAND]); + es[5] = ido2db_db_escape_string(idi, idi->buffered_input[IDO_DATA_CHECKSOURCE]); ts[0] = ido2db_db_timet_to_sql(idi, tstamp.tv_sec); ts[1] = ido2db_db_timet_to_sql(idi, last_check); @@ -3649,6 +3650,8 @@ int ido2db_handle_hoststatusdata(ido2db_idi *idi) { data[53] = (void *) &last_time_unreachable; data[54] = (void *) &last_notification; data[55] = (void *) &next_notification; + /* check_source */ + data[56] = (void *) &es[5]; ido2db_log_debug_info(IDO2DB_DEBUGL_PROCESSINFO, 2, "ido2db_handle_hoststatusdata() LongLen:%d\n", strlen(es[1])); @@ -3710,11 +3713,11 @@ int ido2db_handle_servicestatusdata(ido2db_idi *idi) { double normal_check_interval = 0.0; double retry_check_interval = 0.0; char *ts[11]; - char *es[5]; + char *es[6]; unsigned long object_id = 0L; unsigned long check_timeperiod_object_id = 0L; int x = 0; - void *data[58]; + void *data[59]; ido2db_log_debug_info(IDO2DB_DEBUGL_PROCESSINFO, 2, "ido2db_handle_servicestatusdata() start\n"); @@ -3773,6 +3776,7 @@ int ido2db_handle_servicestatusdata(ido2db_idi *idi) { es[2] = ido2db_db_escape_string(idi, idi->buffered_input[IDO_DATA_PERFDATA]); es[3] = ido2db_db_escape_string(idi, idi->buffered_input[IDO_DATA_EVENTHANDLER]); es[4] = ido2db_db_escape_string(idi, idi->buffered_input[IDO_DATA_CHECKCOMMAND]); + es[5] = ido2db_db_escape_string(idi, idi->buffered_input[IDO_DATA_CHECKSOURCE]); ts[0] = ido2db_db_timet_to_sql(idi, tstamp.tv_sec); ts[1] = ido2db_db_timet_to_sql(idi, last_check); @@ -3855,6 +3859,8 @@ int ido2db_handle_servicestatusdata(ido2db_idi *idi) { data[55] = (void *) &last_time_critical; data[56] = (void *) &last_notification; data[57] = (void *) &next_notification; + /* check_source */ + data[58] = (void *) &es[5]; ido2db_query_insert_or_update_servicestatusdata_add(idi, data); diff --git a/module/idoutils/src/dbqueries.c b/module/idoutils/src/dbqueries.c index b46812e..dd36d98 100644 --- a/module/idoutils/src/dbqueries.c +++ b/module/idoutils/src/dbqueries.c @@ -3423,7 +3423,7 @@ int ido2db_query_insert_or_update_hoststatusdata_add(ido2db_idi *idi, void **dat } } } - asprintf(&query1, "UPDATE %s SET instance_id=%lu, host_object_id=%lu, status_update_time=%s, output='%s', long_output='%s', perfdata='%s', current_state=%d, has_been_checked=%d, should_be_scheduled=%d, current_check_attempt=%d, max_check_attempts=%d, last_check=%s, next_check=%s, check_type=%d, last_state_change=%s, last_hard_state_change=%s, last_hard_state=%d, last_time_up=%s, last_time_down=%s, last_time_unreachable=%s, state_type=%d, last_notification=%s, next_notification=%s, no_more_notifications=%d, notifications_enabled=%d, problem_has_been_acknowledged=%d, acknowledgement_type=%d, current_notification_number=%d, passive_checks_enabled=%d, active_checks_enabled=%d, event_handler_enabled=%d, flap_detection_enabled=%d, is_flapping=%d, percent_state_change='%lf', latency='%lf', execution_time='%lf', scheduled_downtime_depth=%d, failure_prediction_enabled=%d, process_performance_data=%d, obsess_over_host=%d, modified_host_attributes=%lu, event_handler='%s', check_command='%s', normal_check_interval='%lf', retry_check_interval='%lf', check_timeperiod_object_id=%lu WHERE host_object_id=%lu", + asprintf(&query1, "UPDATE %s SET instance_id=%lu, host_object_id=%lu, status_update_time=%s, output='%s', long_output='%s', perfdata='%s', current_state=%d, has_been_checked=%d, should_be_scheduled=%d, current_check_attempt=%d, max_check_attempts=%d, last_check=%s, next_check=%s, check_type=%d, last_state_change=%s, last_hard_state_change=%s, last_hard_state=%d, last_time_up=%s, last_time_down=%s, last_time_unreachable=%s, state_type=%d, last_notification=%s, next_notification=%s, no_more_notifications=%d, notifications_enabled=%d, problem_has_been_acknowledged=%d, acknowledgement_type=%d, current_notification_number=%d, passive_checks_enabled=%d, active_checks_enabled=%d, event_handler_enabled=%d, flap_detection_enabled=%d, is_flapping=%d, percent_state_change='%lf', latency='%lf', execution_time='%lf', scheduled_downtime_depth=%d, failure_prediction_enabled=%d, process_performance_data=%d, obsess_over_host=%d, modified_host_attributes=%lu, event_handler='%s', check_command='%s', normal_check_interval='%lf', retry_check_interval='%lf', check_timeperiod_object_id=%lu, check_source='%s' WHERE host_object_id=%lu", ido2db_db_tablenames[IDO2DB_DBTABLE_HOSTSTATUS], *(unsigned long *) data[0], /* update start */ *(unsigned long *) data[1], @@ -3470,7 +3470,8 @@ int ido2db_query_insert_or_update_hoststatusdata_add(ido2db_idi *idi, void **dat *(char **) data[42], *(double *) data[43], *(double *) data[44], - *(unsigned long *) data[45], /* update end */ + *(unsigned long *) data[45], + *(char **) data[56], /* update end */ *(unsigned long *) data[1] /* unique constraint start/end */ ); /* send query to db */ @@ -3510,7 +3511,7 @@ int ido2db_query_insert_or_update_hoststatusdata_add(ido2db_idi *idi, void **dat if (mysql_update == FALSE) { /* try insert instead */ - asprintf(&query2, "INSERT INTO %s (instance_id, host_object_id, status_update_time, output, long_output, perfdata, current_state, has_been_checked, should_be_scheduled, current_check_attempt, max_check_attempts, last_check, next_check, check_type, last_state_change, last_hard_state_change, last_hard_state, last_time_up, last_time_down, last_time_unreachable, state_type, last_notification, next_notification, no_more_notifications, notifications_enabled, problem_has_been_acknowledged, acknowledgement_type, current_notification_number, passive_checks_enabled, active_checks_enabled, event_handler_enabled, flap_detection_enabled, is_flapping, percent_state_change, latency, execution_time, scheduled_downtime_depth, failure_prediction_enabled, process_performance_data, obsess_over_host, modified_host_attributes, event_handler, check_command, normal_check_interval, retry_check_interval, check_timeperiod_object_id) VALUES (%lu, %lu, %s, '%s', '%s', '%s', %d, %d, %d, %d, %d, %s, %s, %d, %s, %s, %d, %s, %s, %s, %d, %s, %s, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %lf, %lf, %lf, %d, %d, %d, %d, %lu, '%s', '%s', %lf, %lf, %lu)", + asprintf(&query2, "INSERT INTO %s (instance_id, host_object_id, status_update_time, output, long_output, perfdata, current_state, has_been_checked, should_be_scheduled, current_check_attempt, max_check_attempts, last_check, next_check, check_type, last_state_change, last_hard_state_change, last_hard_state, last_time_up, last_time_down, last_time_unreachable, state_type, last_notification, next_notification, no_more_notifications, notifications_enabled, problem_has_been_acknowledged, acknowledgement_type, current_notification_number, passive_checks_enabled, active_checks_enabled, event_handler_enabled, flap_detection_enabled, is_flapping, percent_state_change, latency, execution_time, scheduled_downtime_depth, failure_prediction_enabled, process_performance_data, obsess_over_host, modified_host_attributes, event_handler, check_command, normal_check_interval, retry_check_interval, check_timeperiod_object_id, check_source) VALUES (%lu, %lu, %s, '%s', '%s', '%s', %d, %d, %d, %d, %d, %s, %s, %d, %s, %s, %d, %s, %s, %s, %d, %s, %s, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %lf, %lf, %lf, %d, %d, %d, %d, %lu, '%s', '%s', %lf, %lf, %lu, '%s')", ido2db_db_tablenames[IDO2DB_DBTABLE_HOSTSTATUS], *(unsigned long *) data[0], /* insert start */ *(unsigned long *) data[1], @@ -3557,7 +3558,8 @@ int ido2db_query_insert_or_update_hoststatusdata_add(ido2db_idi *idi, void **dat *(char **) data[42], *(double *) data[43], *(double *) data[44], - *(unsigned long *) data[45] /* insert end */ + *(unsigned long *) data[45], + *(char **) data[56] /* insert end */ ); /* send query to db */ result = ido2db_db_query(idi, query2); @@ -3571,7 +3573,7 @@ int ido2db_query_insert_or_update_hoststatusdata_add(ido2db_idi *idi, void **dat case IDO2DB_DBSERVER_PGSQL: - asprintf(&query1, "UPDATE %s SET instance_id=%lu, host_object_id=%lu, status_update_time=%s, output=E'%s', long_output=E'%s', perfdata=E'%s', current_state=%d, has_been_checked=%d, should_be_scheduled=%d, current_check_attempt=%d, max_check_attempts=%d, last_check=%s, next_check=%s, check_type=%d, last_state_change=%s, last_hard_state_change=%s, last_hard_state=%d, last_time_up=%s, last_time_down=%s, last_time_unreachable=%s, state_type=%d, last_notification=%s, next_notification=%s, no_more_notifications=%d, notifications_enabled=%d, problem_has_been_acknowledged=%d, acknowledgement_type=%d, current_notification_number=%d, passive_checks_enabled=%d, active_checks_enabled=%d, event_handler_enabled=%d, flap_detection_enabled=%d, is_flapping=%d, percent_state_change='%lf', latency='%lf', execution_time='%lf', scheduled_downtime_depth=%d, failure_prediction_enabled=%d, process_performance_data=%d, obsess_over_host=%d, modified_host_attributes=%lu, event_handler=E'%s', check_command=E'%s', normal_check_interval='%lf', retry_check_interval='%lf', check_timeperiod_object_id=%lu WHERE host_object_id=%lu", + asprintf(&query1, "UPDATE %s SET instance_id=%lu, host_object_id=%lu, status_update_time=%s, output=E'%s', long_output=E'%s', perfdata=E'%s', current_state=%d, has_been_checked=%d, should_be_scheduled=%d, current_check_attempt=%d, max_check_attempts=%d, last_check=%s, next_check=%s, check_type=%d, last_state_change=%s, last_hard_state_change=%s, last_hard_state=%d, last_time_up=%s, last_time_down=%s, last_time_unreachable=%s, state_type=%d, last_notification=%s, next_notification=%s, no_more_notifications=%d, notifications_enabled=%d, problem_has_been_acknowledged=%d, acknowledgement_type=%d, current_notification_number=%d, passive_checks_enabled=%d, active_checks_enabled=%d, event_handler_enabled=%d, flap_detection_enabled=%d, is_flapping=%d, percent_state_change='%lf', latency='%lf', execution_time='%lf', scheduled_downtime_depth=%d, failure_prediction_enabled=%d, process_performance_data=%d, obsess_over_host=%d, modified_host_attributes=%lu, event_handler=E'%s', check_command=E'%s', normal_check_interval='%lf', retry_check_interval='%lf', check_timeperiod_object_id=%lu, check_source=E'%s' WHERE host_object_id=%lu", ido2db_db_tablenames[IDO2DB_DBTABLE_HOSTSTATUS], *(unsigned long *) data[0], /* update start */ *(unsigned long *) data[1], @@ -3618,7 +3620,8 @@ int ido2db_query_insert_or_update_hoststatusdata_add(ido2db_idi *idi, void **dat *(char **) data[42], *(double *) data[43], *(double *) data[44], - *(unsigned long *) data[45], /* update end */ + *(unsigned long *) data[45], + *(char **) data[56], /* update end */ *(unsigned long *) data[1] /* unique constraint start/end */ ); /* send query to db */ @@ -3631,7 +3634,7 @@ int ido2db_query_insert_or_update_hoststatusdata_add(ido2db_idi *idi, void **dat idi->dbinfo.dbi_result = NULL; /* try insert instead */ - asprintf(&query2, "INSERT INTO %s (instance_id, host_object_id, status_update_time, output, long_output, perfdata, current_state, has_been_checked, should_be_scheduled, current_check_attempt, max_check_attempts, last_check, next_check, check_type, last_state_change, last_hard_state_change, last_hard_state, last_time_up, last_time_down, last_time_unreachable, state_type, last_notification, next_notification, no_more_notifications, notifications_enabled, problem_has_been_acknowledged, acknowledgement_type, current_notification_number, passive_checks_enabled, active_checks_enabled, event_handler_enabled, flap_detection_enabled, is_flapping, percent_state_change, latency, execution_time, scheduled_downtime_depth, failure_prediction_enabled, process_performance_data, obsess_over_host, modified_host_attributes, event_handler, check_command, normal_check_interval, retry_check_interval, check_timeperiod_object_id) VALUES (%lu, %lu, %s, E'%s', E'%s', E'%s', %d, %d, %d, %d, %d, %s, %s, %d, %s, %s, %d, %s, %s, %s, %d, %s, %s, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %lf, %lf, %lf, %d, %d, %d, %d, %lu, E'%s', E'%s', %lf, %lf, %lu)", + asprintf(&query2, "INSERT INTO %s (instance_id, host_object_id, status_update_time, output, long_output, perfdata, current_state, has_been_checked, should_be_scheduled, current_check_attempt, max_check_attempts, last_check, next_check, check_type, last_state_change, last_hard_state_change, last_hard_state, last_time_up, last_time_down, last_time_unreachable, state_type, last_notification, next_notification, no_more_notifications, notifications_enabled, problem_has_been_acknowledged, acknowledgement_type, current_notification_number, passive_checks_enabled, active_checks_enabled, event_handler_enabled, flap_detection_enabled, is_flapping, percent_state_change, latency, execution_time, scheduled_downtime_depth, failure_prediction_enabled, process_performance_data, obsess_over_host, modified_host_attributes, event_handler, check_command, normal_check_interval, retry_check_interval, check_timeperiod_object_id, check_source) VALUES (%lu, %lu, %s, E'%s', E'%s', E'%s', %d, %d, %d, %d, %d, %s, %s, %d, %s, %s, %d, %s, %s, %s, %d, %s, %s, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %lf, %lf, %lf, %d, %d, %d, %d, %lu, E'%s', E'%s', %lf, %lf, %lu, E'%s')", ido2db_db_tablenames[IDO2DB_DBTABLE_HOSTSTATUS], *(unsigned long *) data[0], /* insert start */ *(unsigned long *) data[1], @@ -3678,7 +3681,8 @@ int ido2db_query_insert_or_update_hoststatusdata_add(ido2db_idi *idi, void **dat *(char **) data[42], *(double *) data[43], *(double *) data[44], - *(unsigned long *) data[45] /* insert end */ + *(unsigned long *) data[45], + *(char **) data[56] /* insert end */ ); /* send query to db */ result = ido2db_db_query(idi, query2); @@ -3846,6 +3850,15 @@ int ido2db_query_insert_or_update_hoststatusdata_add(ido2db_idi *idi, void **dat if (!OCI_BindUnsignedInt(idi->dbinfo.oci_statement_hoststatus, MT(":X46"), (uint *) data[45])) { return IDO_ERROR; } + if (*(char **) data[56] == NULL) { + if (ido2db_oci_prepared_statement_bind_null_param(idi->dbinfo.oci_statement_hoststatus, ":X47") == IDO_ERROR) { + return IDO_ERROR; + } + } else { + if (!OCI_BindString(idi->dbinfo.oci_statement_hoststatus, MT(":X47"), *(char **) data[56], 0)) { + return IDO_ERROR; + } + } //bind clob 2 times,once for update, once for insert to make oracle happy and avoid ora-600 because of double binding ido2db_log_debug_info(IDO2DB_DEBUGL_PROCESSINFO, 2, "ido2db_query_insert_or_update_hoststatus() bind clob\n"); lob_oi = OCI_LobCreate(idi->dbinfo.oci_connection, OCI_CLOB); @@ -3944,7 +3957,7 @@ int ido2db_query_insert_or_update_servicestatusdata_add(ido2db_idi *idi, void ** } } } - asprintf(&query1, "UPDATE %s SET instance_id=%lu, service_object_id=%lu, status_update_time=%s, output='%s', long_output='%s', perfdata='%s', current_state=%d, has_been_checked=%d, should_be_scheduled=%d, current_check_attempt=%d, max_check_attempts=%d, last_check=%s, next_check=%s, check_type=%d, last_state_change=%s, last_hard_state_change=%s, last_hard_state=%d, last_time_ok=%s, last_time_warning=%s, last_time_unknown=%s, last_time_critical=%s, state_type=%d, last_notification=%s, next_notification=%s, no_more_notifications=%d, notifications_enabled=%d, problem_has_been_acknowledged=%d, acknowledgement_type=%d, current_notification_number=%d, passive_checks_enabled=%d, active_checks_enabled=%d, event_handler_enabled=%d, flap_detection_enabled=%d, is_flapping=%d, percent_state_change='%lf', latency='%lf', execution_time='%lf', scheduled_downtime_depth=%d, failure_prediction_enabled=%d, process_performance_data=%d, obsess_over_service=%d, modified_service_attributes=%lu, event_handler='%s', check_command='%s', normal_check_interval='%lf', retry_check_interval='%lf', check_timeperiod_object_id=%lu WHERE service_object_id=%lu", + asprintf(&query1, "UPDATE %s SET instance_id=%lu, service_object_id=%lu, status_update_time=%s, output='%s', long_output='%s', perfdata='%s', current_state=%d, has_been_checked=%d, should_be_scheduled=%d, current_check_attempt=%d, max_check_attempts=%d, last_check=%s, next_check=%s, check_type=%d, last_state_change=%s, last_hard_state_change=%s, last_hard_state=%d, last_time_ok=%s, last_time_warning=%s, last_time_unknown=%s, last_time_critical=%s, state_type=%d, last_notification=%s, next_notification=%s, no_more_notifications=%d, notifications_enabled=%d, problem_has_been_acknowledged=%d, acknowledgement_type=%d, current_notification_number=%d, passive_checks_enabled=%d, active_checks_enabled=%d, event_handler_enabled=%d, flap_detection_enabled=%d, is_flapping=%d, percent_state_change='%lf', latency='%lf', execution_time='%lf', scheduled_downtime_depth=%d, failure_prediction_enabled=%d, process_performance_data=%d, obsess_over_service=%d, modified_service_attributes=%lu, event_handler='%s', check_command='%s', normal_check_interval='%lf', retry_check_interval='%lf', check_timeperiod_object_id=%lu, check_source='%s' WHERE service_object_id=%lu", ido2db_db_tablenames[IDO2DB_DBTABLE_SERVICESTATUS], *(unsigned long *) data[0], /* update start */ *(unsigned long *) data[1], @@ -3992,7 +4005,8 @@ int ido2db_query_insert_or_update_servicestatusdata_add(ido2db_idi *idi, void ** *(char **) data[43], *(double *) data[44], *(double *) data[45], - *(unsigned long *) data[46], /* update end */ + *(unsigned long *) data[46], + *(char **) data[58], /* update end */ *(unsigned long *) data[1] /* unique constraint start/end */ ); @@ -4035,7 +4049,7 @@ int ido2db_query_insert_or_update_servicestatusdata_add(ido2db_idi *idi, void ** if (mysql_update == FALSE) { /* try insert instead */ - asprintf(&query2, "INSERT INTO %s (instance_id, service_object_id, status_update_time, output, long_output, perfdata, current_state, has_been_checked, should_be_scheduled, current_check_attempt, max_check_attempts, last_check, next_check, check_type, last_state_change, last_hard_state_change, last_hard_state, last_time_ok, last_time_warning, last_time_unknown, last_time_critical, state_type, last_notification, next_notification, no_more_notifications, notifications_enabled, problem_has_been_acknowledged, acknowledgement_type, current_notification_number, passive_checks_enabled, active_checks_enabled, event_handler_enabled, flap_detection_enabled, is_flapping, percent_state_change, latency, execution_time, scheduled_downtime_depth, failure_prediction_enabled, process_performance_data, obsess_over_service, modified_service_attributes, event_handler, check_command, normal_check_interval, retry_check_interval, check_timeperiod_object_id) VALUES (%lu, %lu, %s, '%s', '%s', '%s', %d, %d, %d, %d, %d, %s, %s, %d, %s, %s, %d, %s, %s, %s, %s, %d, %s, %s, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, '%lf', '%lf', '%lf', %d, %d, %d, %d, %lu, '%s', '%s', '%lf', '%lf', %lu)", + asprintf(&query2, "INSERT INTO %s (instance_id, service_object_id, status_update_time, output, long_output, perfdata, current_state, has_been_checked, should_be_scheduled, current_check_attempt, max_check_attempts, last_check, next_check, check_type, last_state_change, last_hard_state_change, last_hard_state, last_time_ok, last_time_warning, last_time_unknown, last_time_critical, state_type, last_notification, next_notification, no_more_notifications, notifications_enabled, problem_has_been_acknowledged, acknowledgement_type, current_notification_number, passive_checks_enabled, active_checks_enabled, event_handler_enabled, flap_detection_enabled, is_flapping, percent_state_change, latency, execution_time, scheduled_downtime_depth, failure_prediction_enabled, process_performance_data, obsess_over_service, modified_service_attributes, event_handler, check_command, normal_check_interval, retry_check_interval, check_timeperiod_object_id, check_source) VALUES (%lu, %lu, %s, '%s', '%s', '%s', %d, %d, %d, %d, %d, %s, %s, %d, %s, %s, %d, %s, %s, %s, %s, %d, %s, %s, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, '%lf', '%lf', '%lf', %d, %d, %d, %d, %lu, '%s', '%s', '%lf', '%lf', %lu, '%s')", ido2db_db_tablenames[IDO2DB_DBTABLE_SERVICESTATUS], *(unsigned long *) data[0], /* insert start */ *(unsigned long *) data[1], @@ -4083,7 +4097,8 @@ int ido2db_query_insert_or_update_servicestatusdata_add(ido2db_idi *idi, void ** *(char **) data[43], *(double *) data[44], *(double *) data[45], - *(unsigned long *) data[46] /* insert end */ + *(unsigned long *) data[46], + *(char **) data[58] /* insert end */ ); /* send query to db */ result = ido2db_db_query(idi, query2); @@ -4096,7 +4111,7 @@ int ido2db_query_insert_or_update_servicestatusdata_add(ido2db_idi *idi, void ** break; case IDO2DB_DBSERVER_PGSQL: - asprintf(&query1, "UPDATE %s SET instance_id=%lu, service_object_id=%lu, status_update_time=%s, output=E'%s', long_output=E'%s', perfdata=E'%s', current_state=%d, has_been_checked=%d, should_be_scheduled=%d, current_check_attempt=%d, max_check_attempts=%d, last_check=%s, next_check=%s, check_type=%d, last_state_change=%s, last_hard_state_change=%s, last_hard_state=%d, last_time_ok=%s, last_time_warning=%s, last_time_unknown=%s, last_time_critical=%s, state_type=%d, last_notification=%s, next_notification=%s, no_more_notifications=%d, notifications_enabled=%d, problem_has_been_acknowledged=%d, acknowledgement_type=%d, current_notification_number=%d, passive_checks_enabled=%d, active_checks_enabled=%d, event_handler_enabled=%d, flap_detection_enabled=%d, is_flapping=%d, percent_state_change='%lf', latency='%lf', execution_time='%lf', scheduled_downtime_depth=%d, failure_prediction_enabled=%d, process_performance_data=%d, obsess_over_service=%d, modified_service_attributes=%lu, event_handler=E'%s', check_command=E'%s', normal_check_interval='%lf', retry_check_interval='%lf', check_timeperiod_object_id=%lu WHERE service_object_id=%lu", + asprintf(&query1, "UPDATE %s SET instance_id=%lu, service_object_id=%lu, status_update_time=%s, output=E'%s', long_output=E'%s', perfdata=E'%s', current_state=%d, has_been_checked=%d, should_be_scheduled=%d, current_check_attempt=%d, max_check_attempts=%d, last_check=%s, next_check=%s, check_type=%d, last_state_change=%s, last_hard_state_change=%s, last_hard_state=%d, last_time_ok=%s, last_time_warning=%s, last_time_unknown=%s, last_time_critical=%s, state_type=%d, last_notification=%s, next_notification=%s, no_more_notifications=%d, notifications_enabled=%d, problem_has_been_acknowledged=%d, acknowledgement_type=%d, current_notification_number=%d, passive_checks_enabled=%d, active_checks_enabled=%d, event_handler_enabled=%d, flap_detection_enabled=%d, is_flapping=%d, percent_state_change='%lf', latency='%lf', execution_time='%lf', scheduled_downtime_depth=%d, failure_prediction_enabled=%d, process_performance_data=%d, obsess_over_service=%d, modified_service_attributes=%lu, event_handler=E'%s', check_command=E'%s', normal_check_interval='%lf', retry_check_interval='%lf', check_timeperiod_object_id=%lu, check_source=E'%s' WHERE service_object_id=%lu", ido2db_db_tablenames[IDO2DB_DBTABLE_SERVICESTATUS], *(unsigned long *) data[0], /* update start */ *(unsigned long *) data[1], @@ -4144,7 +4159,8 @@ int ido2db_query_insert_or_update_servicestatusdata_add(ido2db_idi *idi, void ** *(char **) data[43], *(double *) data[44], *(double *) data[45], - *(unsigned long *) data[46], /* update end */ + *(unsigned long *) data[46], + *(char **) data[58], /* update end */ *(unsigned long *) data[1] /* unique constraint start/end */ ); @@ -4158,7 +4174,7 @@ int ido2db_query_insert_or_update_servicestatusdata_add(ido2db_idi *idi, void ** idi->dbinfo.dbi_result = NULL; /* try insert instead */ - asprintf(&query2, "INSERT INTO %s (instance_id, service_object_id, status_update_time, output, long_output, perfdata, current_state, has_been_checked, should_be_scheduled, current_check_attempt, max_check_attempts, last_check, next_check, check_type, last_state_change, last_hard_state_change, last_hard_state, last_time_ok, last_time_warning, last_time_unknown, last_time_critical, state_type, last_notification, next_notification, no_more_notifications, notifications_enabled, problem_has_been_acknowledged, acknowledgement_type, current_notification_number, passive_checks_enabled, active_checks_enabled, event_handler_enabled, flap_detection_enabled, is_flapping, percent_state_change, latency, execution_time, scheduled_downtime_depth, failure_prediction_enabled, process_performance_data, obsess_over_service, modified_service_attributes, event_handler, check_command, normal_check_interval, retry_check_interval, check_timeperiod_object_id) VALUES (%lu, %lu, %s, E'%s', E'%s', E'%s', %d, %d, %d, %d, %d, %s, %s, %d, %s, %s, %d, %s, %s, %s, %s, %d, %s, %s, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, '%lf', '%lf', '%lf', %d, %d, %d, %d, %lu, E'%s', E'%s', '%lf', '%lf', %lu)", + asprintf(&query2, "INSERT INTO %s (instance_id, service_object_id, status_update_time, output, long_output, perfdata, current_state, has_been_checked, should_be_scheduled, current_check_attempt, max_check_attempts, last_check, next_check, check_type, last_state_change, last_hard_state_change, last_hard_state, last_time_ok, last_time_warning, last_time_unknown, last_time_critical, state_type, last_notification, next_notification, no_more_notifications, notifications_enabled, problem_has_been_acknowledged, acknowledgement_type, current_notification_number, passive_checks_enabled, active_checks_enabled, event_handler_enabled, flap_detection_enabled, is_flapping, percent_state_change, latency, execution_time, scheduled_downtime_depth, failure_prediction_enabled, process_performance_data, obsess_over_service, modified_service_attributes, event_handler, check_command, normal_check_interval, retry_check_interval, check_timeperiod_object_id, check_source) VALUES (%lu, %lu, %s, E'%s', E'%s', E'%s', %d, %d, %d, %d, %d, %s, %s, %d, %s, %s, %d, %s, %s, %s, %s, %d, %s, %s, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, '%lf', '%lf', '%lf', %d, %d, %d, %d, %lu, E'%s', E'%s', '%lf', '%lf', %lu, E'%s')", ido2db_db_tablenames[IDO2DB_DBTABLE_SERVICESTATUS], *(unsigned long *) data[0], /* insert start */ *(unsigned long *) data[1], @@ -4206,7 +4222,8 @@ int ido2db_query_insert_or_update_servicestatusdata_add(ido2db_idi *idi, void ** *(char **) data[43], *(double *) data[44], *(double *) data[45], - *(unsigned long *) data[46] /* insert end */ + *(unsigned long *) data[46], + *(char **) data[58] /* insert end */ ); /* send query to db */ result = ido2db_db_query(idi, query2); @@ -4377,6 +4394,15 @@ int ido2db_query_insert_or_update_servicestatusdata_add(ido2db_idi *idi, void ** if (!OCI_BindUnsignedInt(idi->dbinfo.oci_statement_servicestatus, MT(":X47"), (uint *) data[46])) { return IDO_ERROR; } + if (*(char **) data[58] == NULL) { + if (ido2db_oci_prepared_statement_bind_null_param(idi->dbinfo.oci_statement_servicestatus, ":X48") == IDO_ERROR) { + return IDO_ERROR; + } + } else { + if (!OCI_BindString(idi->dbinfo.oci_statement_servicestatus, MT(":X48"), *(char **) data[58], 0)) { + return IDO_ERROR; + } + } //bind clob 2 times,once for update, once for insert to make oracle happy and avoid ora-600 because of double binding lob_oi = OCI_LobCreate(idi->dbinfo.oci_connection, OCI_CLOB); lob_ou = OCI_LobCreate(idi->dbinfo.oci_connection, OCI_CLOB); diff --git a/module/idoutils/src/ido2db.c b/module/idoutils/src/ido2db.c index a301fdb..6871a12 100644 --- a/module/idoutils/src/ido2db.c +++ b/module/idoutils/src/ido2db.c @@ -2249,6 +2249,8 @@ int ido2db_add_input_data_item(ido2db_idi *idi, int type, char *buf) { case IDO_DATA_CUSTOMVARIABLE: case IDO_DATA_CONTACT: + case IDO_DATA_CHECKSOURCE: + /* strings are escaped when they arrive */ if (buf == NULL) newbuf = strdup(""); diff --git a/module/idoutils/src/idomod.c b/module/idoutils/src/idomod.c index fcbe200..0a975aa 100644 --- a/module/idoutils/src/idomod.c +++ b/module/idoutils/src/idomod.c @@ -2091,6 +2091,7 @@ int idomod_broker_data(int event_type, void *data) { es[4] = ido_escape_buffer(temp_host->event_handler); es[5] = ido_escape_buffer(temp_host->host_check_command); es[6] = ido_escape_buffer(temp_host->check_period); + es[7] = ido_escape_buffer(temp_host->check_source); if(es[2] != NULL) { if(strlen(es[2]) > IDOMOD_MAX_TEXT_LEN) { @@ -2107,7 +2108,7 @@ int idomod_broker_data(int event_type, void *data) { retry_interval = temp_host->retry_interval; snprintf(temp_buffer, IDOMOD_MAX_BUFLEN - 1 - , "\n%d:\n%d=%d\n%d=%d\n%d=%d\n%d=%ld.%ld\n%d=%s\n%d=%s\n%d=%s\n%d=%s\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%lu\n%d=%lu\n%d=%d\n%d=%lu\n%d=%lu\n%d=%d\n%d=%lu\n%d=%lu\n%d=%lu\n%d=%d\n%d=%lu\n%d=%lu\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%.5lf\n%d=%.5lf\n%d=%.5lf\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%lu\n%d=%s\n%d=%s\n%d=%lf\n%d=%lf\n%d=%s\n" + , "\n%d:\n%d=%d\n%d=%d\n%d=%d\n%d=%ld.%ld\n%d=%s\n%d=%s\n%d=%s\n%d=%s\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%lu\n%d=%lu\n%d=%d\n%d=%lu\n%d=%lu\n%d=%d\n%d=%lu\n%d=%lu\n%d=%lu\n%d=%d\n%d=%lu\n%d=%lu\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%.5lf\n%d=%.5lf\n%d=%.5lf\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%lu\n%d=%s\n%d=%s\n%d=%lf\n%d=%lf\n%d=%s\n%d=%s\n" , IDO_API_HOSTSTATUSDATA , IDO_DATA_TYPE , hsdata->type @@ -2207,6 +2208,8 @@ int idomod_broker_data(int event_type, void *data) { , (double)retry_interval , IDO_DATA_HOSTCHECKPERIOD , (es[6] == NULL) ? "" : es[6] + , IDO_DATA_CHECKSOURCE + , (es[7] == NULL) ? "" : es[7] ); temp_buffer[IDOMOD_MAX_BUFLEN-1] = '\x0'; @@ -2264,6 +2267,7 @@ int idomod_broker_data(int event_type, void *data) { es[5] = ido_escape_buffer(temp_service->event_handler); es[6] = ido_escape_buffer(temp_service->service_check_command); es[7] = ido_escape_buffer(temp_service->check_period); + es[8] = ido_escape_buffer(temp_service->check_source); if(es[3] != NULL) { if(strlen(es[3]) > IDOMOD_MAX_TEXT_LEN) { @@ -2278,7 +2282,7 @@ int idomod_broker_data(int event_type, void *data) { } snprintf(temp_buffer, IDOMOD_MAX_BUFLEN - 1 - , "\n%d:\n%d=%d\n%d=%d\n%d=%d\n%d=%ld.%ld\n%d=%s\n%d=%s\n%d=%s\n%d=%s\n%d=%s\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%lu\n%d=%lu\n%d=%d\n%d=%lu\n%d=%lu\n%d=%d\n%d=%lu\n%d=%lu\n%d=%lu\n%d=%lu\n%d=%d\n%d=%lu\n%d=%lu\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%.5lf\n%d=%.5lf\n%d=%.5lf\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%lu\n%d=%s\n%d=%s\n%d=%lf\n%d=%lf\n%d=%s\n" + , "\n%d:\n%d=%d\n%d=%d\n%d=%d\n%d=%ld.%ld\n%d=%s\n%d=%s\n%d=%s\n%d=%s\n%d=%s\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%lu\n%d=%lu\n%d=%d\n%d=%lu\n%d=%lu\n%d=%d\n%d=%lu\n%d=%lu\n%d=%lu\n%d=%lu\n%d=%d\n%d=%lu\n%d=%lu\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%.5lf\n%d=%.5lf\n%d=%.5lf\n%d=%d\n%d=%d\n%d=%d\n%d=%d\n%d=%lu\n%d=%s\n%d=%s\n%d=%lf\n%d=%lf\n%d=%s\n%d=%s\n" , IDO_API_SERVICESTATUSDATA , IDO_DATA_TYPE , ssdata->type @@ -2382,6 +2386,8 @@ int idomod_broker_data(int event_type, void *data) { , (double)temp_service->retry_interval , IDO_DATA_SERVICECHECKPERIOD , (es[7] == NULL) ? "" : es[7] + , IDO_DATA_CHECKSOURCE + , (es[8] == NULL) ? "" : es[8] ); temp_buffer[IDOMOD_MAX_BUFLEN-1] = '\x0';