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