1 /** 2 * @file db.h Database declarations for ndo2db daemon 3 */ 4 /* 5 * Copyright 2009-2014 Nagios Core Development Team and Community Contributors 6 * Copyright 2005-2009 Ethan Galstad 7 * 8 * This file is part of NDOUtils. 9 * 10 * NDOUtils is free software: you can redistribute it and/or modify 11 * it under the terms of the GNU General Public License version 2 as 12 * published by the Free Software Foundation. 13 * 14 * NDOUtils is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with NDOUtils. If not, see <http://www.gnu.org/licenses/>. 21 */ 22 23 #ifndef NDO2DB_DB_H_INCLUDED 24 #define NDO2DB_DB_H_INCLUDED 25 26 #include "config.h" 27 #include "ndo2db.h" 28 29 typedef struct ndo2db_dbconfig_struct{ 30 int server_type; 31 int port; 32 char *host; 33 char *socket; 34 char *username; 35 char *password; 36 char *dbname; 37 char *dbprefix; 38 unsigned long max_timedevents_age; 39 unsigned long max_systemcommands_age; 40 unsigned long max_servicechecks_age; 41 unsigned long max_hostchecks_age; 42 unsigned long max_eventhandlers_age; 43 unsigned long max_externalcommands_age; 44 unsigned long max_notifications_age; 45 unsigned long max_contactnotifications_age; 46 unsigned long max_contactnotificationmethods_age; 47 unsigned long max_logentries_age; 48 unsigned long max_acknowledgements_age; 49 }ndo2db_dbconfig; 50 51 /*************** DB server types ***************/ 52 53 #define NDO2DB_DBTABLE_INSTANCES 0 54 #define NDO2DB_DBTABLE_CONNINFO 1 55 #define NDO2DB_DBTABLE_OBJECTS 2 56 #define NDO2DB_DBTABLE_OBJECTTYPES 3 57 #define NDO2DB_DBTABLE_LOGENTRIES 4 58 #define NDO2DB_DBTABLE_SYSTEMCOMMANDS 5 59 #define NDO2DB_DBTABLE_EVENTHANDLERS 6 60 #define NDO2DB_DBTABLE_SERVICECHECKS 7 61 #define NDO2DB_DBTABLE_HOSTCHECKS 8 62 #define NDO2DB_DBTABLE_PROGRAMSTATUS 9 63 #define NDO2DB_DBTABLE_EXTERNALCOMMANDS 10 64 #define NDO2DB_DBTABLE_SERVICESTATUS 11 65 #define NDO2DB_DBTABLE_HOSTSTATUS 12 66 #define NDO2DB_DBTABLE_PROCESSEVENTS 13 67 #define NDO2DB_DBTABLE_TIMEDEVENTS 14 68 #define NDO2DB_DBTABLE_TIMEDEVENTQUEUE 15 69 #define NDO2DB_DBTABLE_FLAPPINGHISTORY 16 70 #define NDO2DB_DBTABLE_COMMENTHISTORY 17 71 #define NDO2DB_DBTABLE_COMMENTS 18 72 #define NDO2DB_DBTABLE_NOTIFICATIONS 19 73 #define NDO2DB_DBTABLE_CONTACTNOTIFICATIONS 20 74 #define NDO2DB_DBTABLE_CONTACTNOTIFICATIONMETHODS 21 75 #define NDO2DB_DBTABLE_ACKNOWLEDGEMENTS 22 76 #define NDO2DB_DBTABLE_STATEHISTORY 23 77 #define NDO2DB_DBTABLE_DOWNTIMEHISTORY 24 78 #define NDO2DB_DBTABLE_SCHEDULEDDOWNTIME 25 79 #define NDO2DB_DBTABLE_CONFIGFILES 26 80 #define NDO2DB_DBTABLE_CONFIGFILEVARIABLES 27 81 #define NDO2DB_DBTABLE_RUNTIMEVARIABLES 28 82 #define NDO2DB_DBTABLE_CONTACTSTATUS 29 83 #define NDO2DB_DBTABLE_CUSTOMVARIABLESTATUS 30 84 #define NDO2DB_DBTABLE_RESERVED31 31 85 #define NDO2DB_DBTABLE_RESERVED32 32 86 #define NDO2DB_DBTABLE_RESERVED33 33 87 #define NDO2DB_DBTABLE_RESERVED34 34 88 #define NDO2DB_DBTABLE_RESERVED35 35 89 #define NDO2DB_DBTABLE_RESERVED36 36 90 #define NDO2DB_DBTABLE_RESERVED37 37 91 #define NDO2DB_DBTABLE_RESERVED38 38 92 #define NDO2DB_DBTABLE_RESERVED39 39 93 94 #define NDO2DB_DBTABLE_COMMANDS 40 95 #define NDO2DB_DBTABLE_TIMEPERIODS 41 96 #define NDO2DB_DBTABLE_TIMEPERIODTIMERANGES 42 97 #define NDO2DB_DBTABLE_CONTACTGROUPS 43 98 #define NDO2DB_DBTABLE_CONTACTGROUPMEMBERS 44 99 #define NDO2DB_DBTABLE_HOSTGROUPS 45 100 #define NDO2DB_DBTABLE_HOSTGROUPMEMBERS 46 101 #define NDO2DB_DBTABLE_SERVICEGROUPS 47 102 #define NDO2DB_DBTABLE_SERVICEGROUPMEMBERS 48 103 #define NDO2DB_DBTABLE_HOSTESCALATIONS 49 104 #define NDO2DB_DBTABLE_HOSTESCALATIONCONTACTS 50 105 #define NDO2DB_DBTABLE_SERVICEESCALATIONS 51 106 #define NDO2DB_DBTABLE_SERVICEESCALATIONCONTACTS 52 107 #define NDO2DB_DBTABLE_HOSTDEPENDENCIES 53 108 #define NDO2DB_DBTABLE_SERVICEDEPENDENCIES 54 109 #define NDO2DB_DBTABLE_CONTACTS 55 110 #define NDO2DB_DBTABLE_CONTACTADDRESSES 56 111 #define NDO2DB_DBTABLE_CONTACTNOTIFICATIONCOMMANDS 57 112 #define NDO2DB_DBTABLE_HOSTS 58 113 #define NDO2DB_DBTABLE_HOSTPARENTHOSTS 59 114 #define NDO2DB_DBTABLE_HOSTCONTACTS 60 115 #define NDO2DB_DBTABLE_SERVICES 61 116 #define NDO2DB_DBTABLE_SERVICECONTACTS 62 117 #define NDO2DB_DBTABLE_CUSTOMVARIABLES 63 118 #define NDO2DB_DBTABLE_HOSTCONTACTGROUPS 64 119 #define NDO2DB_DBTABLE_SERVICECONTACTGROUPS 65 120 #define NDO2DB_DBTABLE_HOSTESCALATIONCONTACTGROUPS 66 121 #define NDO2DB_DBTABLE_SERVICEESCALATIONCONTACTGROUPS 67 122 #define NDO2DB_DBTABLE_SERVICEPARENTSERVICES 68 123 124 #define NDO2DB_MAX_DBTABLES 69 125 126 127 /**************** Object types *****************/ 128 129 #define NDO2DB_OBJECTTYPE_HOST 1 130 #define NDO2DB_OBJECTTYPE_SERVICE 2 131 #define NDO2DB_OBJECTTYPE_HOSTGROUP 3 132 #define NDO2DB_OBJECTTYPE_SERVICEGROUP 4 133 #define NDO2DB_OBJECTTYPE_HOSTESCALATION 5 134 #define NDO2DB_OBJECTTYPE_SERVICEESCALATION 6 135 #define NDO2DB_OBJECTTYPE_HOSTDEPENDENCY 7 136 #define NDO2DB_OBJECTTYPE_SERVICEDEPENDENCY 8 137 #define NDO2DB_OBJECTTYPE_TIMEPERIOD 9 138 #define NDO2DB_OBJECTTYPE_CONTACT 10 139 #define NDO2DB_OBJECTTYPE_CONTACTGROUP 11 140 #define NDO2DB_OBJECTTYPE_COMMAND 12 141 142 143 144 int ndo2db_db_init(ndo2db_idi *); 145 int ndo2db_db_deinit(ndo2db_idi *); 146 147 int ndo2db_db_connect(ndo2db_idi *); 148 int ndo2db_db_disconnect(ndo2db_idi *); 149 150 int ndo2db_db_hello(ndo2db_idi *); 151 int ndo2db_db_goodbye(ndo2db_idi *); 152 int ndo2db_db_checkin(ndo2db_idi *); 153 154 char *ndo2db_db_escape_string(ndo2db_idi *,char *); 155 char *ndo2db_db_timet_to_sql(ndo2db_idi *,time_t); 156 char *ndo2db_db_sql_to_timet(ndo2db_idi *,char *); 157 int ndo2db_db_query(ndo2db_idi *,char *); 158 int ndo2db_db_free_query(ndo2db_idi *); 159 int ndo2db_handle_db_error(ndo2db_idi *,int); 160 161 int ndo2db_db_clear_table(ndo2db_idi *,char *); 162 int ndo2db_db_get_latest_data_time(ndo2db_idi *,char *,char *,unsigned long *); 163 int ndo2db_db_perform_maintenance(ndo2db_idi *); 164 int ndo2db_db_trim_data_table(ndo2db_idi *,char *,char *,unsigned long); 165 166 extern int ndo2db_log_debug_info(int, int, const char *, ...); 167 #endif 168