1 /* 2 ** Zabbix 3 ** Copyright (C) 2001-2021 Zabbix SIA 4 ** 5 ** This program is free software; you can redistribute it and/or modify 6 ** it under the terms of the GNU General Public License as published by 7 ** the Free Software Foundation; either version 2 of the License, or 8 ** (at your option) any later version. 9 ** 10 ** This program is distributed in the hope that it will be useful, 11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 ** GNU General Public License for more details. 14 ** 15 ** You should have received a copy of the GNU General Public License 16 ** along with this program; if not, write to the Free Software 17 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 **/ 19 20 #ifndef ZABBIX_DBCONFIG_H 21 #define ZABBIX_DBCONFIG_H 22 23 #ifndef ZBX_DBCONFIG_IMPL 24 # error This header must be used by configuration cache implementation 25 #endif 26 27 typedef struct 28 { 29 zbx_uint64_t triggerid; 30 const char *description; 31 const char *expression; 32 /* cached expression with expanded user macros, can be NULL */ 33 const char *expression_ex; 34 const char *error; 35 int lastchange; 36 unsigned char topoindex; 37 unsigned char priority; 38 unsigned char type; 39 unsigned char value; 40 unsigned char state; 41 unsigned char locked; 42 unsigned char status; 43 unsigned char functional; /* see TRIGGER_FUNCTIONAL_* defines */ 44 } 45 ZBX_DC_TRIGGER; 46 47 typedef struct zbx_dc_trigger_deplist 48 { 49 zbx_uint64_t triggerid; 50 int refcount; 51 ZBX_DC_TRIGGER *trigger; 52 zbx_vector_ptr_t dependencies; 53 } 54 ZBX_DC_TRIGGER_DEPLIST; 55 56 typedef struct 57 { 58 zbx_uint64_t functionid; 59 zbx_uint64_t triggerid; 60 zbx_uint64_t itemid; 61 const char *function; 62 const char *parameter; 63 unsigned char timer; 64 } 65 ZBX_DC_FUNCTION; 66 67 typedef struct 68 { 69 zbx_uint64_t itemid; 70 zbx_uint64_t hostid; 71 zbx_uint64_t interfaceid; 72 zbx_uint64_t lastlogsize; 73 zbx_uint64_t valuemapid; 74 const char *key; 75 const char *port; 76 const char *db_error; 77 ZBX_DC_TRIGGER **triggers; 78 int delay; 79 int nextcheck; 80 int lastclock; 81 int mtime; 82 int data_expected_from; 83 int history; 84 unsigned char type; 85 unsigned char data_type; 86 unsigned char value_type; 87 unsigned char poller_type; 88 unsigned char state; 89 unsigned char db_state; 90 unsigned char inventory_link; 91 unsigned char location; 92 unsigned char flags; 93 unsigned char status; 94 unsigned char unreachable; 95 unsigned char update_triggers; 96 } 97 ZBX_DC_ITEM; 98 99 typedef struct 100 { 101 zbx_uint64_t hostid; 102 const char *key; 103 ZBX_DC_ITEM *item_ptr; 104 } 105 ZBX_DC_ITEM_HK; 106 107 typedef struct 108 { 109 zbx_uint64_t itemid; 110 const char *formula; 111 const char *units; 112 int trends; 113 unsigned char delta; 114 unsigned char multiplier; 115 } 116 ZBX_DC_NUMITEM; 117 118 typedef struct 119 { 120 zbx_uint64_t itemid; 121 const char *snmp_oid; 122 const char *snmp_community; 123 const char *snmpv3_securityname; 124 const char *snmpv3_authpassphrase; 125 const char *snmpv3_privpassphrase; 126 const char *snmpv3_contextname; 127 unsigned char snmpv3_securitylevel; 128 unsigned char snmpv3_authprotocol; 129 unsigned char snmpv3_privprotocol; 130 unsigned char snmp_oid_type; 131 } 132 ZBX_DC_SNMPITEM; 133 134 typedef struct 135 { 136 zbx_uint64_t itemid; 137 const char *ipmi_sensor; 138 } 139 ZBX_DC_IPMIITEM; 140 141 typedef struct 142 { 143 zbx_uint64_t itemid; 144 const char *delay_flex; 145 } 146 ZBX_DC_FLEXITEM; 147 148 typedef struct 149 { 150 zbx_uint64_t itemid; 151 const char *trapper_hosts; 152 } 153 ZBX_DC_TRAPITEM; 154 155 typedef struct 156 { 157 zbx_uint64_t itemid; 158 const char *logtimefmt; 159 } 160 ZBX_DC_LOGITEM; 161 162 typedef struct 163 { 164 zbx_uint64_t itemid; 165 const char *params; 166 const char *username; 167 const char *password; 168 } 169 ZBX_DC_DBITEM; 170 171 typedef struct 172 { 173 zbx_uint64_t itemid; 174 const char *username; 175 const char *publickey; 176 const char *privatekey; 177 const char *password; 178 const char *params; 179 unsigned char authtype; 180 } 181 ZBX_DC_SSHITEM; 182 183 typedef struct 184 { 185 zbx_uint64_t itemid; 186 const char *username; 187 const char *password; 188 const char *params; 189 } 190 ZBX_DC_TELNETITEM; 191 192 typedef struct 193 { 194 zbx_uint64_t itemid; 195 const char *username; 196 const char *password; 197 } 198 ZBX_DC_SIMPLEITEM; 199 200 typedef struct 201 { 202 zbx_uint64_t itemid; 203 const char *username; 204 const char *password; 205 } 206 ZBX_DC_JMXITEM; 207 208 typedef struct 209 { 210 zbx_uint64_t itemid; 211 const char *params; 212 } 213 ZBX_DC_CALCITEM; 214 215 typedef zbx_item_history_value_t ZBX_DC_DELTAITEM; 216 217 #if defined(HAVE_POLARSSL) || defined(HAVE_GNUTLS) || defined(HAVE_OPENSSL) 218 typedef struct 219 { 220 const char *tls_psk_identity; /* pre-shared key identity */ 221 const char *tls_psk; /* pre-shared key value (hex-string) */ 222 unsigned int refcount; /* reference count */ 223 } 224 ZBX_DC_PSK; 225 #endif 226 227 typedef struct 228 { 229 zbx_uint64_t hostid; 230 zbx_uint64_t proxy_hostid; 231 const char *host; 232 const char *name; 233 int maintenance_from; 234 int data_expected_from; 235 int errors_from; 236 int disable_until; 237 int snmp_errors_from; 238 int snmp_disable_until; 239 int ipmi_errors_from; 240 int ipmi_disable_until; 241 int jmx_errors_from; 242 int jmx_disable_until; 243 244 /* item statistics per interface type */ 245 int items_num; 246 int snmp_items_num; 247 int ipmi_items_num; 248 int jmx_items_num; 249 250 /* timestamp of last availability status (available/error) field change on any interface */ 251 int availability_ts; 252 253 unsigned char maintenance_status; 254 unsigned char maintenance_type; 255 unsigned char available; 256 unsigned char snmp_available; 257 unsigned char ipmi_available; 258 unsigned char jmx_available; 259 unsigned char status; 260 261 /* flag to reset host availability to uknown */ 262 unsigned char reset_availability; 263 264 /* flag to force update for all items */ 265 unsigned char update_items; 266 267 /* 'tls_connect' and 'tls_accept' must be respected even if encryption support is not compiled in */ 268 unsigned char tls_connect; 269 unsigned char tls_accept; 270 #if defined(HAVE_POLARSSL) || defined(HAVE_GNUTLS) || defined(HAVE_OPENSSL) 271 const char *tls_issuer; 272 const char *tls_subject; 273 ZBX_DC_PSK *tls_dc_psk; 274 #endif 275 const char *error; 276 const char *snmp_error; 277 const char *ipmi_error; 278 const char *jmx_error; 279 } 280 ZBX_DC_HOST; 281 282 typedef struct 283 { 284 zbx_uint64_t hostid; 285 unsigned char inventory_mode; 286 } 287 ZBX_DC_HOST_INVENTORY; 288 289 typedef struct 290 { 291 const char *host; 292 ZBX_DC_HOST *host_ptr; 293 } 294 ZBX_DC_HOST_H; 295 296 typedef struct 297 { 298 zbx_uint64_t hostid; 299 int proxy_config_nextcheck; 300 int proxy_data_nextcheck; 301 int timediff; 302 int lastaccess; 303 unsigned char location; 304 } 305 ZBX_DC_PROXY; 306 307 typedef struct 308 { 309 zbx_uint64_t hostid; 310 const char *ipmi_username; 311 const char *ipmi_password; 312 signed char ipmi_authtype; 313 unsigned char ipmi_privilege; 314 } 315 ZBX_DC_IPMIHOST; 316 317 typedef struct 318 { 319 zbx_uint64_t hostid; 320 zbx_vector_uint64_t templateids; 321 } 322 ZBX_DC_HTMPL; 323 324 typedef struct 325 { 326 zbx_uint64_t globalmacroid; 327 const char *macro; 328 const char *context; 329 const char *value; 330 } 331 ZBX_DC_GMACRO; 332 333 typedef struct 334 { 335 const char *macro; 336 zbx_vector_ptr_t gmacros; 337 } 338 ZBX_DC_GMACRO_M; 339 340 typedef struct 341 { 342 zbx_uint64_t hostmacroid; 343 zbx_uint64_t hostid; 344 const char *macro; 345 const char *context; 346 const char *value; 347 } 348 ZBX_DC_HMACRO; 349 350 typedef struct 351 { 352 zbx_uint64_t hostid; 353 const char *macro; 354 zbx_vector_ptr_t hmacros; 355 } 356 ZBX_DC_HMACRO_HM; 357 358 typedef struct 359 { 360 zbx_uint64_t interfaceid; 361 zbx_uint64_t hostid; 362 const char *ip; 363 const char *dns; 364 const char *port; 365 unsigned char type; 366 unsigned char main; 367 unsigned char useip; 368 unsigned char bulk; 369 unsigned char max_snmp_succeed; 370 unsigned char min_snmp_fail; 371 } 372 ZBX_DC_INTERFACE; 373 374 typedef struct 375 { 376 zbx_uint64_t hostid; 377 ZBX_DC_INTERFACE *interface_ptr; 378 unsigned char type; 379 } 380 ZBX_DC_INTERFACE_HT; 381 382 typedef struct 383 { 384 const char *addr; 385 zbx_vector_uint64_t interfaceids; 386 } 387 ZBX_DC_INTERFACE_ADDR; 388 389 typedef struct 390 { 391 zbx_uint64_t interfaceid; 392 zbx_vector_uint64_t itemids; 393 } 394 ZBX_DC_INTERFACE_ITEM; 395 396 typedef struct 397 { 398 const char *name; 399 zbx_vector_uint64_t expressionids; 400 } 401 ZBX_DC_REGEXP; 402 403 typedef struct 404 { 405 zbx_uint64_t expressionid; 406 const char *expression; 407 const char *regexp; 408 char delimiter; 409 unsigned char type; 410 unsigned char case_sensitive; 411 } 412 ZBX_DC_EXPRESSION; 413 414 typedef struct 415 { 416 const char *severity_name[TRIGGER_SEVERITY_COUNT]; 417 zbx_uint64_t discovery_groupid; 418 int default_inventory_mode; 419 int refresh_unsupported; 420 unsigned char snmptrap_logging; 421 /* housekeeping related configuration data */ 422 zbx_config_hk_t hk; 423 } 424 ZBX_DC_CONFIG_TABLE; 425 426 typedef struct 427 { 428 zbx_uint64_t conditionid; 429 zbx_uint64_t actionid; 430 431 unsigned char conditiontype; 432 unsigned char operator; 433 const char *value; 434 } 435 zbx_dc_action_condition_t; 436 437 typedef struct 438 { 439 zbx_uint64_t actionid; 440 const char *formula; 441 unsigned char eventsource; 442 unsigned char evaltype; 443 zbx_vector_ptr_t conditions; 444 } 445 zbx_dc_action_t; 446 447 typedef struct 448 { 449 /* timestamp of the last host availability diff sent to sever, used only by proxies */ 450 int availability_diff_ts; 451 452 zbx_hashset_t items; 453 zbx_hashset_t items_hk; /* hostid, key */ 454 zbx_hashset_t numitems; 455 zbx_hashset_t snmpitems; 456 zbx_hashset_t ipmiitems; 457 zbx_hashset_t flexitems; 458 zbx_hashset_t trapitems; 459 zbx_hashset_t logitems; 460 zbx_hashset_t dbitems; 461 zbx_hashset_t sshitems; 462 zbx_hashset_t telnetitems; 463 zbx_hashset_t simpleitems; 464 zbx_hashset_t jmxitems; 465 zbx_hashset_t calcitems; 466 zbx_hashset_t deltaitems; /* history data for delta value calculations */ 467 zbx_hashset_t functions; 468 zbx_hashset_t triggers; 469 zbx_hashset_t trigdeps; 470 zbx_vector_ptr_t *time_triggers; 471 zbx_hashset_t hosts; 472 zbx_hashset_t hosts_h; /* for searching hosts by 'host' name */ 473 zbx_hashset_t hosts_p; /* for searching proxies by 'host' name */ 474 zbx_hashset_t proxies; 475 zbx_hashset_t host_inventories; 476 zbx_hashset_t ipmihosts; 477 zbx_hashset_t htmpls; 478 zbx_hashset_t gmacros; 479 zbx_hashset_t gmacros_m; /* macro */ 480 zbx_hashset_t hmacros; 481 zbx_hashset_t hmacros_hm; /* hostid, macro */ 482 zbx_hashset_t interfaces; 483 zbx_hashset_t interfaces_ht; /* hostid, type */ 484 zbx_hashset_t interface_snmpaddrs; /* addr, interfaceids for SNMP interfaces */ 485 zbx_hashset_t interface_snmpitems; /* interfaceid, itemids for SNMP trap items */ 486 zbx_hashset_t regexps; 487 zbx_hashset_t expressions; 488 zbx_hashset_t actions; 489 zbx_hashset_t action_conditions; 490 #if defined(HAVE_POLARSSL) || defined(HAVE_GNUTLS) || defined(HAVE_OPENSSL) 491 zbx_hashset_t psks; /* for keeping PSK-identity and PSK pairs and for searching */ 492 /* by PSK identity */ 493 #endif 494 zbx_binary_heap_t queues[ZBX_POLLER_TYPE_COUNT]; 495 zbx_binary_heap_t pqueue; 496 zbx_vector_uint64_t locked_lld_ruleids; /* for keeping track of lld rules being processed */ 497 ZBX_DC_CONFIG_TABLE *config; 498 } 499 ZBX_DC_CONFIG; 500 501 void DCdump_configuration(ZBX_DC_CONFIG *config); 502 503 #endif 504