00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef _IDO2DB_DB_H
00010 #define _IDO2DB_DB_H
00011
00012 #include "../../../include/config.h"
00013 #include "ido2db.h"
00014
00015 typedef struct ido2db_dbconfig_struct{
00016 int server_type;
00017 int port;
00018 char *host;
00019 char *username;
00020 char *password;
00021 char *dbname;
00022 char *dbprefix;
00023 char *dbserver;
00024 unsigned long max_timedevents_age;
00025 unsigned long max_systemcommands_age;
00026 unsigned long max_servicechecks_age;
00027 unsigned long max_hostchecks_age;
00028 unsigned long max_eventhandlers_age;
00029 unsigned long max_externalcommands_age;
00030 unsigned long max_logentries_age;
00031 unsigned long max_acknowledgements_age;
00032 unsigned long trim_db_interval;
00033 unsigned long housekeeping_thread_startup_delay;
00034 unsigned long clean_realtime_tables_on_core_startup;
00035 unsigned long clean_config_tables_on_core_startup;
00036 unsigned long oci_errors_to_syslog;
00037 }ido2db_dbconfig;
00038
00039
00040
00041 #define IDO2DB_DBTABLE_INSTANCES 0
00042 #define IDO2DB_DBTABLE_CONNINFO 1
00043 #define IDO2DB_DBTABLE_OBJECTS 2
00044 #define IDO2DB_DBTABLE_OBJECTTYPES 3
00045 #define IDO2DB_DBTABLE_LOGENTRIES 4
00046 #define IDO2DB_DBTABLE_SYSTEMCOMMANDS 5
00047 #define IDO2DB_DBTABLE_EVENTHANDLERS 6
00048 #define IDO2DB_DBTABLE_SERVICECHECKS 7
00049 #define IDO2DB_DBTABLE_HOSTCHECKS 8
00050 #define IDO2DB_DBTABLE_PROGRAMSTATUS 9
00051 #define IDO2DB_DBTABLE_EXTERNALCOMMANDS 10
00052 #define IDO2DB_DBTABLE_SERVICESTATUS 11
00053 #define IDO2DB_DBTABLE_HOSTSTATUS 12
00054 #define IDO2DB_DBTABLE_PROCESSEVENTS 13
00055 #define IDO2DB_DBTABLE_TIMEDEVENTS 14
00056 #define IDO2DB_DBTABLE_TIMEDEVENTQUEUE 15
00057 #define IDO2DB_DBTABLE_FLAPPINGHISTORY 16
00058 #define IDO2DB_DBTABLE_COMMENTHISTORY 17
00059 #define IDO2DB_DBTABLE_COMMENTS 18
00060 #define IDO2DB_DBTABLE_NOTIFICATIONS 19
00061 #define IDO2DB_DBTABLE_CONTACTNOTIFICATIONS 20
00062 #define IDO2DB_DBTABLE_CONTACTNOTIFICATIONMETHODS 21
00063 #define IDO2DB_DBTABLE_ACKNOWLEDGEMENTS 22
00064 #define IDO2DB_DBTABLE_STATEHISTORY 23
00065 #define IDO2DB_DBTABLE_DOWNTIMEHISTORY 24
00066 #define IDO2DB_DBTABLE_SCHEDULEDDOWNTIME 25
00067 #define IDO2DB_DBTABLE_CONFIGFILES 26
00068 #define IDO2DB_DBTABLE_CONFIGFILEVARIABLES 27
00069 #define IDO2DB_DBTABLE_RUNTIMEVARIABLES 28
00070 #define IDO2DB_DBTABLE_CONTACTSTATUS 29
00071 #define IDO2DB_DBTABLE_CUSTOMVARIABLESTATUS 30
00072 #define IDO2DB_DBTABLE_RESERVED31 31
00073 #define IDO2DB_DBTABLE_RESERVED32 32
00074 #define IDO2DB_DBTABLE_RESERVED33 33
00075 #define IDO2DB_DBTABLE_RESERVED34 34
00076 #define IDO2DB_DBTABLE_RESERVED35 35
00077 #define IDO2DB_DBTABLE_RESERVED36 36
00078 #define IDO2DB_DBTABLE_RESERVED37 37
00079 #define IDO2DB_DBTABLE_RESERVED38 38
00080 #define IDO2DB_DBTABLE_RESERVED39 39
00081
00082 #define IDO2DB_DBTABLE_COMMANDS 40
00083 #define IDO2DB_DBTABLE_TIMEPERIODS 41
00084 #define IDO2DB_DBTABLE_TIMEPERIODTIMERANGES 42
00085 #define IDO2DB_DBTABLE_CONTACTGROUPS 43
00086 #define IDO2DB_DBTABLE_CONTACTGROUPMEMBERS 44
00087 #define IDO2DB_DBTABLE_HOSTGROUPS 45
00088 #define IDO2DB_DBTABLE_HOSTGROUPMEMBERS 46
00089 #define IDO2DB_DBTABLE_SERVICEGROUPS 47
00090 #define IDO2DB_DBTABLE_SERVICEGROUPMEMBERS 48
00091 #define IDO2DB_DBTABLE_HOSTESCALATIONS 49
00092 #define IDO2DB_DBTABLE_HOSTESCALATIONCONTACTS 50
00093 #define IDO2DB_DBTABLE_SERVICEESCALATIONS 51
00094 #define IDO2DB_DBTABLE_SERVICEESCALATIONCONTACTS 52
00095 #define IDO2DB_DBTABLE_HOSTDEPENDENCIES 53
00096 #define IDO2DB_DBTABLE_SERVICEDEPENDENCIES 54
00097 #define IDO2DB_DBTABLE_CONTACTS 55
00098 #define IDO2DB_DBTABLE_CONTACTADDRESSES 56
00099 #define IDO2DB_DBTABLE_CONTACTNOTIFICATIONCOMMANDS 57
00100 #define IDO2DB_DBTABLE_HOSTS 58
00101 #define IDO2DB_DBTABLE_HOSTPARENTHOSTS 59
00102 #define IDO2DB_DBTABLE_HOSTCONTACTS 60
00103 #define IDO2DB_DBTABLE_SERVICES 61
00104 #define IDO2DB_DBTABLE_SERVICECONTACTS 62
00105 #define IDO2DB_DBTABLE_CUSTOMVARIABLES 63
00106 #define IDO2DB_DBTABLE_HOSTCONTACTGROUPS 64
00107 #define IDO2DB_DBTABLE_SERVICECONTACTGROUPS 65
00108 #define IDO2DB_DBTABLE_HOSTESCALATIONCONTACTGROUPS 66
00109 #define IDO2DB_DBTABLE_SERVICEESCALATIONCONTACTGROUPS 67
00110 #define IDO2DB_DBTABLE_DBVERSION 68
00111
00112 #define IDO2DB_MAX_DBTABLES 69
00113
00114
00115
00116
00117 #define IDO2DB_OBJECTTYPE_HOST 1
00118 #define IDO2DB_OBJECTTYPE_SERVICE 2
00119 #define IDO2DB_OBJECTTYPE_HOSTGROUP 3
00120 #define IDO2DB_OBJECTTYPE_SERVICEGROUP 4
00121 #define IDO2DB_OBJECTTYPE_HOSTESCALATION 5
00122 #define IDO2DB_OBJECTTYPE_SERVICEESCALATION 6
00123 #define IDO2DB_OBJECTTYPE_HOSTDEPENDENCY 7
00124 #define IDO2DB_OBJECTTYPE_SERVICEDEPENDENCY 8
00125 #define IDO2DB_OBJECTTYPE_TIMEPERIOD 9
00126 #define IDO2DB_OBJECTTYPE_CONTACT 10
00127 #define IDO2DB_OBJECTTYPE_CONTACTGROUP 11
00128 #define IDO2DB_OBJECTTYPE_COMMAND 12
00129
00130
00131
00132 int ido2db_db_init(ido2db_idi *);
00133 int ido2db_db_deinit(ido2db_idi *);
00134
00135 int ido2db_db_connect(ido2db_idi *);
00136 int ido2db_db_is_connected(ido2db_idi *);
00137 int ido2db_db_reconnect(ido2db_idi *);
00138 int ido2db_db_disconnect(ido2db_idi *);
00139
00140 int ido2db_db_hello(ido2db_idi *);
00141 int ido2db_thread_db_hello(ido2db_idi *);
00142 int ido2db_db_goodbye(ido2db_idi *);
00143 int ido2db_db_checkin(ido2db_idi *);
00144
00145 char *ido2db_db_escape_string(ido2db_idi *,char *);
00146 char *ido2db_db_timet_to_sql(ido2db_idi *,time_t);
00147 char *ido2db_db_sql_to_timet(ido2db_idi *,char *);
00148 int ido2db_db_query(ido2db_idi *,char *);
00149 int ido2db_db_free_query(ido2db_idi *);
00150 int ido2db_handle_db_error(ido2db_idi *);
00151
00152 int ido2db_db_clear_table(ido2db_idi *,char *);
00153 int ido2db_db_get_latest_data_time(ido2db_idi *,char *,char *,unsigned long *);
00154 int ido2db_db_perform_maintenance(ido2db_idi *);
00155 int ido2db_db_trim_data_table(ido2db_idi *,char *,char *,unsigned long);
00156
00157 #ifdef USE_ORACLE
00158 void ido2db_ocilib_err_handler(OCI_Error *);
00159 unsigned long ido2db_ocilib_insert_id(ido2db_idi *, char *);
00160 int ido2db_oci_prepared_statement_bind_null_param(OCI_Statement *, char *);
00161 #endif
00162
00163 #endif