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_DBCACHE_H
21 #define ZABBIX_DBCACHE_H
22 
23 #include "db.h"
24 #include "comms.h"
25 #include "sysinfo.h"
26 #include "zbxalgo.h"
27 #include "zbxjson.h"
28 #include "memalloc.h"
29 #include "zbxeval.h"
30 
31 #define ZBX_SYNC_DONE		0
32 #define	ZBX_SYNC_MORE		1
33 
34 #define	ZBX_NO_POLLER			255
35 #define	ZBX_POLLER_TYPE_NORMAL		0
36 #define	ZBX_POLLER_TYPE_UNREACHABLE	1
37 #define	ZBX_POLLER_TYPE_IPMI		2
38 #define	ZBX_POLLER_TYPE_PINGER		3
39 #define	ZBX_POLLER_TYPE_JAVA		4
40 #define	ZBX_POLLER_TYPE_HISTORY		5
41 #define	ZBX_POLLER_TYPE_COUNT		6	/* number of poller types */
42 
43 #define MAX_JAVA_ITEMS		32
44 #define MAX_SNMP_ITEMS		128
45 #define MAX_POLLER_ITEMS	128	/* MAX(MAX_JAVA_ITEMS, MAX_SNMP_ITEMS) */
46 #define MAX_PINGER_ITEMS	128
47 
48 #define ZBX_TRIGGER_DEPENDENCY_LEVELS_MAX	32
49 
50 #define ZBX_TRIGGER_DEPENDENCY_FAIL		1
51 #define ZBX_TRIGGER_DEPENDENCY_UNRESOLVED	2
52 
53 #define ZBX_SNMPTRAP_LOGGING_ENABLED	1
54 
55 extern int	CONFIG_TIMEOUT;
56 
57 extern zbx_uint64_t	CONFIG_CONF_CACHE_SIZE;
58 extern zbx_uint64_t	CONFIG_HISTORY_CACHE_SIZE;
59 extern zbx_uint64_t	CONFIG_HISTORY_INDEX_CACHE_SIZE;
60 extern zbx_uint64_t	CONFIG_TRENDS_CACHE_SIZE;
61 
62 extern int	CONFIG_POLLER_FORKS;
63 extern int	CONFIG_UNREACHABLE_POLLER_FORKS;
64 extern int	CONFIG_IPMIPOLLER_FORKS;
65 extern int	CONFIG_JAVAPOLLER_FORKS;
66 extern int	CONFIG_PINGER_FORKS;
67 extern int	CONFIG_UNAVAILABLE_DELAY;
68 extern int	CONFIG_UNREACHABLE_PERIOD;
69 extern int	CONFIG_UNREACHABLE_DELAY;
70 extern int	CONFIG_HISTSYNCER_FORKS;
71 extern int	CONFIG_PROXYCONFIG_FREQUENCY;
72 extern int	CONFIG_PROXYDATA_FREQUENCY;
73 extern int	CONFIG_HISTORYPOLLER_FORKS;
74 
75 typedef struct
76 {
77 	zbx_uint64_t	interfaceid;
78 	char		ip_orig[INTERFACE_IP_LEN_MAX];
79 	char		dns_orig[INTERFACE_DNS_LEN_MAX];
80 	char		port_orig[INTERFACE_PORT_LEN_MAX];
81 	char		*addr;
82 	unsigned short	port;
83 	unsigned char	useip;
84 	unsigned char	type;
85 	unsigned char	main;
86 	unsigned char	available;
87 	int		disable_until;
88 	char		error[INTERFACE_ERROR_LEN_MAX];
89 	int		errors_from;
90 }
91 DC_INTERFACE;
92 
93 typedef struct
94 {
95 	zbx_uint64_t	interfaceid;
96 	char		*addr;
97 	unsigned char	type;
98 	unsigned char	main;
99 	unsigned char	bulk;
100 	unsigned char	snmp_version;
101 	unsigned char	useip;
102 	char		ip_orig[INTERFACE_IP_LEN_MAX];
103 	char		dns_orig[INTERFACE_DNS_LEN_MAX];
104 	char		port_orig[INTERFACE_PORT_LEN_MAX];
105 }
106 DC_INTERFACE2;
107 
108 typedef struct
109 {
110 	zbx_uint64_t	hostid;
111 	zbx_uint64_t	proxy_hostid;
112 	char		host[HOST_HOST_LEN_MAX];
113 	char		name[HOST_NAME_LEN * ZBX_MAX_BYTES_IN_UTF8_CHAR + 1];
114 	unsigned char	maintenance_status;
115 	unsigned char	maintenance_type;
116 	int		maintenance_from;
117 	signed char	ipmi_authtype;
118 	unsigned char	ipmi_privilege;
119 	char		ipmi_username[HOST_IPMI_USERNAME_LEN_MAX];
120 	char		ipmi_password[HOST_IPMI_PASSWORD_LEN_MAX];
121 	char		inventory_mode;
122 	unsigned char	status;
123 	unsigned char	tls_connect;
124 	unsigned char	tls_accept;
125 #if defined(HAVE_GNUTLS) || defined(HAVE_OPENSSL)
126 	char		tls_issuer[HOST_TLS_ISSUER_LEN_MAX];
127 	char		tls_subject[HOST_TLS_SUBJECT_LEN_MAX];
128 	char		tls_psk_identity[HOST_TLS_PSK_IDENTITY_LEN_MAX];
129 	char		tls_psk[HOST_TLS_PSK_LEN_MAX];
130 #endif
131 }
132 DC_HOST;
133 
134 typedef struct
135 {
136 	DC_HOST			host;
137 	DC_INTERFACE		interface;
138 	zbx_uint64_t		itemid;
139 	zbx_uint64_t		lastlogsize;
140 	zbx_uint64_t		valuemapid;
141 	unsigned char		type;
142 	unsigned char		snmp_version;
143 	unsigned char		value_type;
144 	unsigned char		state;
145 	unsigned char		snmpv3_securitylevel;
146 	unsigned char		authtype;
147 	unsigned char		flags;
148 	unsigned char		snmpv3_authprotocol;
149 	unsigned char		snmpv3_privprotocol;
150 	unsigned char		inventory_link;
151 	unsigned char		status;
152 	unsigned char		history;
153 	unsigned char		trends;
154 	unsigned char		follow_redirects;
155 	unsigned char		post_type;
156 	unsigned char		retrieve_mode;
157 	unsigned char		request_method;
158 	unsigned char		output_format;
159 	unsigned char		verify_peer;
160 	unsigned char		verify_host;
161 	unsigned char		allow_traps;
162 	char			key_orig[ITEM_KEY_LEN * ZBX_MAX_BYTES_IN_UTF8_CHAR + 1], *key;
163 	char			*units;
164 	char			*delay;
165 	int			history_sec;
166 	int			trends_sec;
167 	int			mtime;
168 	char			trapper_hosts[ITEM_TRAPPER_HOSTS_LEN_MAX];
169 	char			logtimefmt[ITEM_LOGTIMEFMT_LEN_MAX];
170 	char			snmp_community_orig[ITEM_SNMP_COMMUNITY_LEN_MAX], *snmp_community;
171 	char			snmp_oid_orig[ITEM_SNMP_OID_LEN_MAX], *snmp_oid;
172 	char			snmpv3_securityname_orig[ITEM_SNMPV3_SECURITYNAME_LEN_MAX], *snmpv3_securityname;
173 	char			snmpv3_authpassphrase_orig[ITEM_SNMPV3_AUTHPASSPHRASE_LEN_MAX], *snmpv3_authpassphrase;
174 	char			snmpv3_privpassphrase_orig[ITEM_SNMPV3_PRIVPASSPHRASE_LEN_MAX], *snmpv3_privpassphrase;
175 	char			ipmi_sensor[ITEM_IPMI_SENSOR_LEN_MAX];
176 	char			*params;
177 	char			username_orig[ITEM_USERNAME_LEN_MAX], *username;
178 	char			publickey_orig[ITEM_PUBLICKEY_LEN_MAX], *publickey;
179 	char			privatekey_orig[ITEM_PRIVATEKEY_LEN_MAX], *privatekey;
180 	char			password_orig[ITEM_PASSWORD_LEN_MAX], *password;
181 	char			snmpv3_contextname_orig[ITEM_SNMPV3_CONTEXTNAME_LEN_MAX], *snmpv3_contextname;
182 	char			jmx_endpoint_orig[ITEM_JMX_ENDPOINT_LEN_MAX], *jmx_endpoint;
183 	char			timeout_orig[ITEM_TIMEOUT_LEN_MAX], *timeout;
184 	char			url_orig[ITEM_URL_LEN_MAX], *url;
185 	char			query_fields_orig[ITEM_QUERY_FIELDS_LEN_MAX], *query_fields;
186 	char			*posts;
187 	char			status_codes_orig[ITEM_STATUS_CODES_LEN_MAX], *status_codes;
188 	char			http_proxy_orig[ITEM_HTTP_PROXY_LEN_MAX], *http_proxy;
189 	char			*headers;
190 	char			ssl_cert_file_orig[ITEM_SSL_CERT_FILE_LEN_MAX], *ssl_cert_file;
191 	char			ssl_key_file_orig[ITEM_SSL_KEY_FILE_LEN_MAX], *ssl_key_file;
192 	char			ssl_key_password_orig[ITEM_SSL_KEY_PASSWORD_LEN_MAX], *ssl_key_password;
193 	char			*script_params;
194 	char			*error;
195 	unsigned char		*formula_bin;
196 }
197 DC_ITEM;
198 
199 typedef struct
200 {
201 	zbx_uint64_t	functionid;
202 	zbx_uint64_t	triggerid;
203 	zbx_uint64_t	itemid;
204 	char		*function;
205 	char		*parameter;
206 }
207 DC_FUNCTION;
208 
209 typedef struct
210 {
211 	char	*tag;
212 	char	*value;
213 }
214 zbx_tag_t;
215 
216 typedef struct
217 {
218 	zbx_uint64_t	hostid;
219 	zbx_uint64_t	itemid;
220 	zbx_tag_t	tag;
221 }
222 zbx_item_tag_t;
223 
224 #define ZBX_DC_TRIGGER_PROBLEM_EXPRESSION	0x1	/* this flag shows that trigger value recalculation is  */
225 							/* initiated by a time-based function or a new value of */
226 							/* an item in problem expression */
227 
228 typedef struct _DC_TRIGGER
229 {
230 	zbx_uint64_t		triggerid;
231 	char			*description;
232 	char			*expression;
233 	char			*recovery_expression;
234 
235 	char			*error;
236 	char			*new_error;
237 	char			*correlation_tag;
238 	char			*opdata;
239 	char			*event_name;
240 	unsigned char		*expression_bin;
241 	unsigned char		*recovery_expression_bin;
242 	zbx_timespec_t		timespec;
243 	int			lastchange;
244 	unsigned char		topoindex;
245 	unsigned char		priority;
246 	unsigned char		type;
247 	unsigned char		value;
248 	unsigned char		state;
249 	unsigned char		new_value;
250 	unsigned char		status;
251 	unsigned char		recovery_mode;
252 	unsigned char		correlation_mode;
253 
254 	unsigned char		flags;
255 
256 	zbx_vector_ptr_t	tags;
257 
258 	zbx_eval_context_t	*eval_ctx;
259 	zbx_eval_context_t	*eval_ctx_r;
260 }
261 DC_TRIGGER;
262 
263 /* needed to collect and pass data about items that are involved in generating problem events */
264 typedef struct
265 {
266 	zbx_uint64_t		triggerid;
267 	zbx_vector_uint64_t	itemids;
268 }
269 zbx_trigger_items_t;
270 
271 typedef struct
272 {
273 	zbx_uint64_t	hostid;
274 	char		host[HOST_HOST_LEN_MAX];
275 	int		proxy_config_nextcheck;
276 	int		proxy_data_nextcheck;
277 	int		proxy_tasks_nextcheck;
278 	int		last_cfg_error_time;	/* time when passive proxy misconfiguration error was seen */
279 						/* or 0 if no error */
280 	int		version;
281 	int		lastaccess;
282 	char		addr_orig[INTERFACE_ADDR_LEN_MAX];
283 	char		port_orig[INTERFACE_PORT_LEN_MAX];
284 	char		*addr;
285 	unsigned short	port;
286 
287 	unsigned char	auto_compress;
288 	unsigned char	tls_connect;
289 	unsigned char	tls_accept;
290 
291 #if defined(HAVE_GNUTLS) || defined(HAVE_OPENSSL)
292 	char		tls_issuer[HOST_TLS_ISSUER_LEN_MAX];
293 	char		tls_subject[HOST_TLS_SUBJECT_LEN_MAX];
294 	char		tls_psk_identity[HOST_TLS_PSK_IDENTITY_LEN_MAX];
295 	char		tls_psk[HOST_TLS_PSK_LEN_MAX];
296 #endif
297 	char		proxy_address[HOST_PROXY_ADDRESS_LEN_MAX];
298 	int		last_version_error_time;
299 }
300 DC_PROXY;
301 
302 #define ZBX_ACTION_OPCLASS_NONE			0
303 #define ZBX_ACTION_OPCLASS_NORMAL		1
304 #define ZBX_ACTION_OPCLASS_RECOVERY		2
305 #define ZBX_ACTION_OPCLASS_ACKNOWLEDGE		4
306 
307 typedef struct
308 {
309 	zbx_uint64_t		actionid;
310 	char			*formula;
311 	unsigned char		eventsource;
312 	unsigned char		evaltype;
313 	unsigned char		opflags;
314 	zbx_vector_ptr_t	conditions;
315 }
316 zbx_action_eval_t;
317 
318 typedef struct
319 {
320 	char	*host;
321 	char	*key;
322 }
323 zbx_host_key_t;
324 
325 /* housekeeping related configuration data */
326 typedef struct
327 {
328 	int		events_trigger;
329 	int		events_internal;
330 	int		events_discovery;
331 	int		events_autoreg;
332 	int		services;
333 	int		audit;
334 	int		sessions;
335 	int		trends;
336 	int		history;
337 
338 	unsigned char	services_mode;
339 	unsigned char	audit_mode;
340 	unsigned char	sessions_mode;
341 	unsigned char	events_mode;
342 	unsigned char	trends_mode;
343 	unsigned char	trends_global;
344 	unsigned char	history_mode;
345 	unsigned char	history_global;
346 }
347 zbx_config_hk_t;
348 
349 typedef struct
350 {
351 	char		*extension;
352 	unsigned char	history_compression_status;
353 	int		history_compress_older;
354 }
355 zbx_config_db_t;
356 
357 /* global configuration data (loaded from config table) */
358 typedef struct
359 {
360 	/* the fields set by zbx_config_get() function, see ZBX_CONFIG_FLAGS_ defines */
361 	zbx_uint64_t	flags;
362 
363 	char		**severity_name;
364 	zbx_uint64_t	discovery_groupid;
365 	int		default_inventory_mode;
366 	unsigned char	snmptrap_logging;
367 	unsigned char	autoreg_tls_accept;
368 	char		*default_timezone;
369 
370 	/* database configuration data for ZBX_CONFIG_DB_EXTENSION_* extensions */
371 	zbx_config_db_t	db;
372 
373 	/* housekeeping related configuration data */
374 	zbx_config_hk_t	hk;
375 }
376 zbx_config_t;
377 
378 #define ZBX_CONFIG_FLAGS_SEVERITY_NAME			__UINT64_C(0x0000000000000001)
379 #define ZBX_CONFIG_FLAGS_DISCOVERY_GROUPID		__UINT64_C(0x0000000000000002)
380 #define ZBX_CONFIG_FLAGS_DEFAULT_INVENTORY_MODE		__UINT64_C(0x0000000000000004)
381 #define ZBX_CONFIG_FLAGS_SNMPTRAP_LOGGING		__UINT64_C(0x0000000000000010)
382 #define ZBX_CONFIG_FLAGS_HOUSEKEEPER			__UINT64_C(0x0000000000000020)
383 #define ZBX_CONFIG_FLAGS_DB_EXTENSION			__UINT64_C(0x0000000000000040)
384 #define ZBX_CONFIG_FLAGS_AUTOREG_TLS_ACCEPT		__UINT64_C(0x0000000000000080)
385 #define ZBX_CONFIG_FLAGS_DEFAULT_TIMEZONE		__UINT64_C(0x0000000000000100)
386 
387 /* possible values for database extensions (if flag ZBX_CONFIG_FLAGS_DB_EXTENSION set) */
388 #define ZBX_CONFIG_DB_EXTENSION_TIMESCALE		"timescaledb"
389 
390 typedef struct
391 {
392 	zbx_uint64_t	hostid;
393 	unsigned char	idx;
394 	const char	*field_name;
395 	char		*value;
396 }
397 zbx_inventory_value_t;
398 
399 typedef struct
400 {
401 	char	*tag;
402 }
403 zbx_corr_condition_tag_t;
404 
405 typedef struct
406 {
407 	char		*tag;
408 	char		*value;
409 	unsigned char	op;
410 }
411 zbx_corr_condition_tag_value_t;
412 
413 typedef struct
414 {
415 	zbx_uint64_t	groupid;
416 	unsigned char	op;
417 }
418 zbx_corr_condition_group_t;
419 
420 typedef struct
421 {
422 	char	*oldtag;
423 	char	*newtag;
424 }
425 zbx_corr_condition_tag_pair_t;
426 
427 typedef union
428 {
429 	zbx_corr_condition_tag_t	tag;
430 	zbx_corr_condition_tag_value_t	tag_value;
431 	zbx_corr_condition_group_t	group;
432 	zbx_corr_condition_tag_pair_t	tag_pair;
433 }
434 zbx_corr_condition_data_t;
435 
436 typedef struct
437 {
438 	zbx_uint64_t			corr_conditionid;
439 	int				type;
440 	zbx_corr_condition_data_t	data;
441 }
442 zbx_corr_condition_t;
443 
444 typedef struct
445 {
446 	unsigned char	type;
447 }
448 zbx_corr_operation_t;
449 
450 typedef struct
451 {
452 	zbx_uint64_t		correlationid;
453 	char			*name;
454 	char			*formula;
455 	unsigned char		evaltype;
456 
457 	zbx_vector_ptr_t	conditions;
458 	zbx_vector_ptr_t	operations;
459 }
460 zbx_correlation_t;
461 
462 typedef struct
463 {
464 	zbx_vector_ptr_t	correlations;
465 	zbx_hashset_t		conditions;
466 
467 	/* Configuration synchronization timestamp of the rules. */
468 	/* Update the cache if this timesamp is less than the    */
469 	/* current configuration synchronization timestamp.      */
470 	int			sync_ts;
471 }
472 zbx_correlation_rules_t;
473 
474 /* value_avg_t structure is used for item average value trend calculations. */
475 /*                                                                          */
476 /* For double values the average value is calculated on the fly with the    */
477 /* following formula: avg = (dbl * count + value) / (count + 1) and stored  */
478 /* into dbl member.                                                         */
479 /* For uint64 values the item values are summed into ui64 member and the    */
480 /* average value is calculated before flushing trends to database:          */
481 /* avg = ui64 / count                                                       */
482 typedef union
483 {
484 	double		dbl;
485 	zbx_uint128_t	ui64;
486 }
487 value_avg_t;
488 
489 typedef struct
490 {
491 	zbx_uint64_t	itemid;
492 	history_value_t	value_min;
493 	value_avg_t	value_avg;
494 	history_value_t	value_max;
495 	int		clock;
496 	int		num;
497 	int		disable_from;
498 	unsigned char	value_type;
499 }
500 ZBX_DC_TREND;
501 
502 typedef struct
503 {
504 	zbx_uint64_t	itemid;
505 	history_value_t	value;
506 	zbx_uint64_t	lastlogsize;
507 	zbx_timespec_t	ts;
508 	int		mtime;
509 	unsigned char	value_type;
510 	unsigned char	flags;		/* see ZBX_DC_FLAG_* */
511 	unsigned char	state;
512 	int		ttl;		/* time-to-live of the history value */
513 }
514 ZBX_DC_HISTORY;
515 
516 /* item queue data */
517 typedef struct
518 {
519 	zbx_uint64_t	itemid;
520 	zbx_uint64_t	proxy_hostid;
521 	int		type;
522 	int		nextcheck;
523 }
524 zbx_queue_item_t;
525 
526 typedef union
527 {
528 	zbx_uint64_t	ui64;
529 	double		dbl;
530 }
531 zbx_counter_value_t;
532 
533 typedef struct
534 {
535 	zbx_uint64_t		proxyid;
536 	zbx_counter_value_t	counter_value;
537 }
538 zbx_proxy_counter_t;
539 
540 typedef enum
541 {
542 	ZBX_COUNTER_TYPE_UI64,
543 	ZBX_COUNTER_TYPE_DBL
544 }
545 zbx_counter_type_t;
546 
547 typedef struct
548 {
549 	unsigned char	type;
550 	unsigned char	error_handler;
551 	char		*params;
552 	char		*error_handler_params;
553 }
554 zbx_preproc_op_t;
555 
556 typedef struct
557 {
558 	zbx_uint64_t		itemid;
559 	unsigned char		type;
560 	unsigned char		value_type;
561 
562 	int			dep_itemids_num;
563 	int			preproc_ops_num;
564 	int			update_time;
565 
566 	zbx_uint64_pair_t	*dep_itemids;
567 	zbx_preproc_op_t	*preproc_ops;
568 }
569 zbx_preproc_item_t;
570 
571 /* the configuration cache statistics */
572 typedef struct
573 {
574 	zbx_uint64_t	hosts;
575 	zbx_uint64_t	items;
576 	zbx_uint64_t	items_unsupported;
577 	double		requiredperformance;
578 }
579 zbx_config_cache_info_t;
580 
581 typedef struct
582 {
583 	zbx_uint64_t	history_counter;	/* the total number of processed values */
584 	zbx_uint64_t	history_float_counter;	/* the number of processed float values */
585 	zbx_uint64_t	history_uint_counter;	/* the number of processed uint values */
586 	zbx_uint64_t	history_str_counter;	/* the number of processed str values */
587 	zbx_uint64_t	history_log_counter;	/* the number of processed log values */
588 	zbx_uint64_t	history_text_counter;	/* the number of processed text values */
589 	zbx_uint64_t	notsupported_counter;	/* the number of processed not supported items */
590 }
591 ZBX_DC_STATS;
592 
593 /* the write cache statistics */
594 typedef struct
595 {
596 	ZBX_DC_STATS	stats;
597 	zbx_uint64_t	history_free;
598 	zbx_uint64_t	history_total;
599 	zbx_uint64_t	index_free;
600 	zbx_uint64_t	index_total;
601 	zbx_uint64_t	trend_free;
602 	zbx_uint64_t	trend_total;
603 }
604 zbx_wcache_info_t;
605 
606 int	is_item_processed_by_server(unsigned char type, const char *key);
607 int	zbx_is_counted_in_item_queue(unsigned char type, const char *key);
608 int	in_maintenance_without_data_collection(unsigned char maintenance_status, unsigned char maintenance_type,
609 		unsigned char type);
610 void	dc_add_history(zbx_uint64_t itemid, unsigned char item_value_type, unsigned char item_flags,
611 		AGENT_RESULT *result, const zbx_timespec_t *ts, unsigned char state, const char *error);
612 void	dc_flush_history(void);
613 void	zbx_sync_history_cache(int *values_num, int *triggers_num, int *more);
614 void	zbx_log_sync_history_cache_progress(void);
615 int	init_database_cache(char **error);
616 void	free_database_cache(void);
617 
618 #define ZBX_STATS_HISTORY_COUNTER	0
619 #define ZBX_STATS_HISTORY_FLOAT_COUNTER	1
620 #define ZBX_STATS_HISTORY_UINT_COUNTER	2
621 #define ZBX_STATS_HISTORY_STR_COUNTER	3
622 #define ZBX_STATS_HISTORY_LOG_COUNTER	4
623 #define ZBX_STATS_HISTORY_TEXT_COUNTER	5
624 #define ZBX_STATS_NOTSUPPORTED_COUNTER	6
625 #define ZBX_STATS_HISTORY_TOTAL		7
626 #define ZBX_STATS_HISTORY_USED		8
627 #define ZBX_STATS_HISTORY_FREE		9
628 #define ZBX_STATS_HISTORY_PUSED		10
629 #define ZBX_STATS_HISTORY_PFREE		11
630 #define ZBX_STATS_TREND_TOTAL		12
631 #define ZBX_STATS_TREND_USED		13
632 #define ZBX_STATS_TREND_FREE		14
633 #define ZBX_STATS_TREND_PUSED		15
634 #define ZBX_STATS_TREND_PFREE		16
635 #define ZBX_STATS_HISTORY_INDEX_TOTAL	17
636 #define ZBX_STATS_HISTORY_INDEX_USED	18
637 #define ZBX_STATS_HISTORY_INDEX_FREE	19
638 #define ZBX_STATS_HISTORY_INDEX_PUSED	20
639 #define ZBX_STATS_HISTORY_INDEX_PFREE	21
640 void	*DCget_stats(int request);
641 void	DCget_stats_all(zbx_wcache_info_t *wcache_info);
642 
643 zbx_uint64_t	DCget_nextid(const char *table_name, int num);
644 
645 /* initial sync, get all data */
646 #define ZBX_DBSYNC_INIT		0
647 /* update sync, get changed data */
648 #define ZBX_DBSYNC_UPDATE	1
649 #define ZBX_SYNC_SECRETS	2
650 
651 #define ZBX_ITEM_GET_MISC		0x001
652 #define ZBX_ITEM_GET_DELAY		0x002
653 #define ZBX_ITEM_GET_EMPTY_ERROR	0x004
654 #define ZBX_ITEM_GET_NUM		0x008
655 #define ZBX_ITEM_GET_EMPTY_UNITS	0x010
656 #define ZBX_ITEM_GET_LOGTIMEFMT		0x020
657 #define ZBX_ITEM_GET_POLLINFO		0x040
658 #define ZBX_ITEM_GET_INTERFACE		0x080
659 #define ZBX_ITEM_GET_HOSTNAME		0x100
660 #define ZBX_ITEM_GET_HOSTINFO		0x200
661 #define ZBX_ITEM_GET_MAINTENANCE	0x400
662 #define ZBX_ITEM_GET_INVENTORY		0x800
663 
664 #define ZBX_ITEM_GET_ALL		(~(unsigned int)0)
665 
666 #define ZBX_ITEM_GET_SYNC		(ZBX_ITEM_GET_INVENTORY|ZBX_ITEM_GET_NUM)
667 #define ZBX_ITEM_GET_SYNC_EXPORT	(ZBX_ITEM_GET_INVENTORY|ZBX_ITEM_GET_NUM|ZBX_ITEM_GET_HOSTNAME)
668 
669 #define ZBX_ITEM_GET_PROCESS		(ZBX_ITEM_GET_MAINTENANCE|ZBX_ITEM_GET_MISC|ZBX_ITEM_GET_LOGTIMEFMT)
670 
671 void	DCsync_configuration(unsigned char mode, const struct zbx_json_parse *jp_kvs_paths);
672 int	init_configuration_cache(char **error);
673 void	free_configuration_cache(void);
674 
675 void	DCconfig_get_triggers_by_triggerids(DC_TRIGGER *triggers, const zbx_uint64_t *triggerids, int *errcode,
676 		size_t num);
677 void	DCconfig_clean_items(DC_ITEM *items, int *errcodes, size_t num);
678 int	DCget_host_by_hostid(DC_HOST *host, zbx_uint64_t hostid);
679 int	DCconfig_get_hostid_by_name(const char *host, zbx_uint64_t *hostid);
680 void	DCconfig_get_hosts_by_itemids(DC_HOST *hosts, const zbx_uint64_t *itemids, int *errcodes, size_t num);
681 void	DCconfig_get_items_by_keys(DC_ITEM *items, zbx_host_key_t *keys, int *errcodes, size_t num);
682 void	DCconfig_get_items_by_itemids(DC_ITEM *items, const zbx_uint64_t *itemids, int *errcodes, size_t num);
683 void	DCconfig_get_items_by_itemids_partial(DC_ITEM *items, const zbx_uint64_t *itemids, int *errcodes, size_t num,
684 		unsigned int mode);
685 void	DCconfig_get_preprocessable_items(zbx_hashset_t *items, int *timestamp);
686 void	DCconfig_get_functions_by_functionids(DC_FUNCTION *functions,
687 		zbx_uint64_t *functionids, int *errcodes, size_t num);
688 void	DCconfig_clean_functions(DC_FUNCTION *functions, int *errcodes, size_t num);
689 void	DCconfig_clean_triggers(DC_TRIGGER *triggers, int *errcodes, size_t num);
690 int	DCconfig_lock_triggers_by_history_items(zbx_vector_ptr_t *history_items, zbx_vector_uint64_t *triggerids);
691 void	DCconfig_lock_triggers_by_triggerids(zbx_vector_uint64_t *triggerids_in, zbx_vector_uint64_t *triggerids_out);
692 void	DCconfig_unlock_triggers(const zbx_vector_uint64_t *triggerids);
693 void	DCconfig_unlock_all_triggers(void);
694 void	DCconfig_get_triggers_by_itemids(zbx_hashset_t *trigger_info, zbx_vector_ptr_t *trigger_order,
695 		const zbx_uint64_t *itemids, const zbx_timespec_t *timespecs, int itemids_num);
696 int	DCconfig_trigger_exists(zbx_uint64_t triggerid);
697 void	DCfree_triggers(zbx_vector_ptr_t *triggers);
698 void	DCconfig_update_interface_snmp_stats(zbx_uint64_t interfaceid, int max_snmp_succeed, int min_snmp_fail);
699 int	DCconfig_get_suggested_snmp_vars(zbx_uint64_t interfaceid, int *bulk);
700 int	DCconfig_get_interface_by_type(DC_INTERFACE *interface, zbx_uint64_t hostid, unsigned char type);
701 int	DCconfig_get_interface(DC_INTERFACE *interface, zbx_uint64_t hostid, zbx_uint64_t itemid);
702 int	DCconfig_get_poller_nextcheck(unsigned char poller_type);
703 int	DCconfig_get_poller_items(unsigned char poller_type, DC_ITEM **items);
704 int	DCconfig_get_ipmi_poller_items(int now, DC_ITEM *items, int items_num, int *nextcheck);
705 int	DCconfig_get_snmp_interfaceids_by_addr(const char *addr, zbx_uint64_t **interfaceids);
706 size_t	DCconfig_get_snmp_items_by_interfaceid(zbx_uint64_t interfaceid, DC_ITEM **items);
707 
708 #define ZBX_HK_OPTION_DISABLED		0
709 #define ZBX_HK_OPTION_ENABLED		1
710 
711 /* options for hk.history_mode, trends_mode */
712 #define ZBX_HK_MODE_DISABLED		ZBX_HK_OPTION_DISABLED
713 #define ZBX_HK_MODE_REGULAR		ZBX_HK_OPTION_ENABLED
714 #define ZBX_HK_MODE_PARTITION		2
715 
716 #define ZBX_HK_HISTORY_MIN	SEC_PER_HOUR
717 #define ZBX_HK_TRENDS_MIN	SEC_PER_DAY
718 #define ZBX_HK_PERIOD_MAX	(25 * SEC_PER_YEAR)
719 
720 void	DCrequeue_items(const zbx_uint64_t *itemids, const int *lastclocks,
721 		const int *errcodes, size_t num);
722 void	DCpoller_requeue_items(const zbx_uint64_t *itemids, const int *lastclocks,
723 		const int *errcodes, size_t num, unsigned char poller_type, int *nextcheck);
724 void	zbx_dc_requeue_unreachable_items(zbx_uint64_t *itemids, size_t itemids_num);
725 int	DCconfig_activate_host(DC_ITEM *item);
726 int	DCconfig_deactivate_host(DC_ITEM *item, int now);
727 
728 int	DCconfig_check_trigger_dependencies(zbx_uint64_t triggerid);
729 
730 void	DCconfig_triggers_apply_changes(zbx_vector_ptr_t *trigger_diff);
731 void	DCconfig_items_apply_changes(const zbx_vector_ptr_t *item_diff);
732 
733 void	DCconfig_update_inventory_values(const zbx_vector_ptr_t *inventory_values);
734 int	DCget_host_inventory_value_by_itemid(zbx_uint64_t itemid, char **replace_to, int value_idx);
735 int	DCget_host_inventory_value_by_hostid(zbx_uint64_t hostid, char **replace_to, int value_idx);
736 
737 #define ZBX_CONFSTATS_BUFFER_TOTAL	1
738 #define ZBX_CONFSTATS_BUFFER_USED	2
739 #define ZBX_CONFSTATS_BUFFER_FREE	3
740 #define ZBX_CONFSTATS_BUFFER_PUSED	4
741 #define ZBX_CONFSTATS_BUFFER_PFREE	5
742 void	*DCconfig_get_stats(int request);
743 
744 int	DCconfig_get_last_sync_time(void);
745 void	DCconfig_wait_sync(void);
746 int	DCconfig_get_proxypoller_hosts(DC_PROXY *proxies, int max_hosts);
747 int	DCconfig_get_proxypoller_nextcheck(void);
748 
749 #define ZBX_PROXY_CONFIG_NEXTCHECK	0x01
750 #define ZBX_PROXY_DATA_NEXTCHECK	0x02
751 #define ZBX_PROXY_TASKS_NEXTCHECK	0x04
752 void	DCrequeue_proxy(zbx_uint64_t hostid, unsigned char update_nextcheck, int proxy_conn_err);
753 int	DCcheck_proxy_permissions(const char *host, const zbx_socket_t *sock, zbx_uint64_t *hostid, char **error);
754 
755 #if defined(HAVE_GNUTLS) || defined(HAVE_OPENSSL)
756 size_t	DCget_psk_by_identity(const unsigned char *psk_identity, unsigned char *psk_buf, unsigned int *psk_usage);
757 #endif
758 void	DCget_autoregistration_psk(char *psk_identity_buf, size_t psk_identity_buf_len,
759 		unsigned char *psk_buf, size_t psk_buf_len);
760 
761 #define ZBX_MACRO_ENV_SECURE	0
762 #define ZBX_MACRO_ENV_NONSECURE	1
763 
764 #define ZBX_MACRO_VALUE_TEXT	0
765 #define ZBX_MACRO_VALUE_SECRET	1
766 #define ZBX_MACRO_VALUE_VAULT	2
767 
768 #define ZBX_MACRO_SECRET_MASK	"******"
769 
770 void	DCget_user_macro(const zbx_uint64_t *hostids, int hostids_num, const char *macro, char **replace_to);
771 char	*zbx_dc_expand_func_params_user_macros(zbx_uint64_t hostid, const char *params);
772 
773 int	DCinterface_activate(zbx_uint64_t interfaceid, const zbx_timespec_t *ts, zbx_agent_availability_t *in,
774 		zbx_agent_availability_t *out);
775 
776 int	DCinterface_deactivate(zbx_uint64_t interfaceid, const zbx_timespec_t *ts, zbx_agent_availability_t *in,
777 		zbx_agent_availability_t *out, const char *error_msg);
778 
779 #define ZBX_QUEUE_FROM_DEFAULT	6	/* default lower limit for delay (in seconds) */
780 #define ZBX_QUEUE_TO_INFINITY	-1	/* no upper limit for delay */
781 void	DCfree_item_queue(zbx_vector_ptr_t *queue);
782 int	DCget_item_queue(zbx_vector_ptr_t *queue, int from, int to);
783 
784 zbx_uint64_t	DCget_item_count(zbx_uint64_t hostid);
785 zbx_uint64_t	DCget_item_unsupported_count(zbx_uint64_t hostid);
786 zbx_uint64_t	DCget_trigger_count(void);
787 double		DCget_required_performance(void);
788 zbx_uint64_t	DCget_host_count(void);
789 void		DCget_count_stats_all(zbx_config_cache_info_t *stats);
790 
791 void	DCget_status(zbx_vector_ptr_t *hosts_monitored, zbx_vector_ptr_t *hosts_not_monitored,
792 		zbx_vector_ptr_t *items_active_normal, zbx_vector_ptr_t *items_active_notsupported,
793 		zbx_vector_ptr_t *items_disabled, zbx_uint64_t *triggers_enabled_ok,
794 		zbx_uint64_t *triggers_enabled_problem, zbx_uint64_t *triggers_disabled,
795 		zbx_vector_ptr_t *required_performance);
796 
797 void	DCget_expressions_by_names(zbx_vector_ptr_t *expressions, const char * const *names, int names_num);
798 void	DCget_expressions_by_name(zbx_vector_ptr_t *expressions, const char *name);
799 
800 int	DCget_data_expected_from(zbx_uint64_t itemid, int *seconds);
801 
802 void	DCget_hostids_by_functionids(zbx_vector_uint64_t *functionids, zbx_vector_uint64_t *hostids);
803 void	DCget_hosts_by_functionids(const zbx_vector_uint64_t *functionids, zbx_hashset_t *hosts);
804 
805 int	DCget_proxy_nodata_win(zbx_uint64_t hostid, zbx_proxy_suppress_t *nodata_win, int *lastaccess);
806 int	DCget_proxy_delay(zbx_uint64_t hostid, int *delay);
807 int	DCget_proxy_delay_by_name(const char *name, int *delay, char **error);
808 
809 unsigned int	DCget_internal_action_count(void);
810 
811 /* global configuration support */
812 #define ZBX_DISCOVERY_GROUPID_UNDEFINED	0
813 void	zbx_config_get(zbx_config_t *cfg, zbx_uint64_t flags);
814 void	zbx_config_clean(zbx_config_t *cfg);
815 void	zbx_config_get_hk_mode(unsigned char *history_mode, unsigned char *trends_mode);
816 
817 int	DCset_interfaces_availability(zbx_vector_availability_ptr_t *availabilities);
818 
819 int	DCreset_interfaces_availability(zbx_vector_availability_ptr_t *interfaces);
820 void	DCupdate_interfaces_availability(void);
821 
822 void	zbx_dc_get_actions_eval(zbx_vector_ptr_t *actions, unsigned char opflags);
823 
824 int	DCget_interfaces_availability(zbx_vector_ptr_t *interfaces, int *ts);
825 void	DCtouch_interfaces_availability(const zbx_vector_uint64_t *interfaceids);
826 
827 void	zbx_interface_availability_init(zbx_interface_availability_t *availability, zbx_uint64_t interfaceid);
828 void	zbx_interface_availability_clean(zbx_interface_availability_t *ia);
829 void	zbx_interface_availability_free(zbx_interface_availability_t *availability);
830 int	zbx_interface_availability_is_set(const zbx_interface_availability_t *ia);
831 
832 void	zbx_set_availability_diff_ts(int ts);
833 
834 void	zbx_dc_correlation_rules_init(zbx_correlation_rules_t *rules);
835 void	zbx_dc_correlation_rules_clean(zbx_correlation_rules_t *rules);
836 void	zbx_dc_correlation_rules_free(zbx_correlation_rules_t *rules);
837 void	zbx_dc_correlation_rules_get(zbx_correlation_rules_t *rules);
838 
839 void	zbx_dc_get_nested_hostgroupids(zbx_uint64_t *groupids, int groupids_num, zbx_vector_uint64_t *nested_groupids);
840 void	zbx_dc_get_hostids_by_group_name(const char *name, zbx_vector_uint64_t *hostids);
841 
842 #define ZBX_HC_ITEM_STATUS_NORMAL	0
843 #define ZBX_HC_ITEM_STATUS_BUSY		1
844 
845 #define ZBX_DC_FLAG_META	0x01	/* contains meta information (lastlogsize and mtime) */
846 #define ZBX_DC_FLAG_NOVALUE	0x02	/* entry contains no value */
847 #define ZBX_DC_FLAG_LLD		0x04	/* low-level discovery value */
848 #define ZBX_DC_FLAG_UNDEF	0x08	/* unsupported or undefined (delta calculation failed) value */
849 #define ZBX_DC_FLAG_NOHISTORY	0x10	/* values should not be kept in history */
850 #define ZBX_DC_FLAG_NOTRENDS	0x20	/* values should not be kept in trends */
851 
852 typedef struct zbx_hc_data
853 {
854 	history_value_t	value;
855 	zbx_uint64_t	lastlogsize;
856 	zbx_timespec_t	ts;
857 	int		mtime;
858 	unsigned char	value_type;
859 	unsigned char	flags;
860 	unsigned char	state;
861 
862 	struct zbx_hc_data	*next;
863 }
864 zbx_hc_data_t;
865 
866 typedef struct
867 {
868 	zbx_uint64_t	itemid;
869 	unsigned char	status;
870 	int		values_num;
871 
872 	zbx_hc_data_t	*tail;
873 	zbx_hc_data_t	*head;
874 }
875 zbx_hc_item_t;
876 
877 void	zbx_free_tag(zbx_tag_t *tag);
878 void	zbx_free_item_tag(zbx_item_tag_t *item_tag);
879 
880 int	zbx_dc_get_active_proxy_by_name(const char *name, DC_PROXY *proxy, char **error);
881 void	zbx_dc_update_proxy_version(zbx_uint64_t hostid, int version);
882 
883 typedef struct
884 {
885 	zbx_timespec_t	ts;
886 	char		*value;	/* NULL in case of meta record (see "meta" field below) */
887 	char		*source;
888 	zbx_uint64_t	lastlogsize;
889 	zbx_uint64_t	id;
890 	int		mtime;
891 	int		timestamp;
892 	int		severity;
893 	int		logeventid;
894 	unsigned char	state;
895 	unsigned char	meta;	/* non-zero if contains meta information (lastlogsize and mtime) */
896 }
897 zbx_agent_value_t;
898 
899 void	zbx_dc_items_update_nextcheck(DC_ITEM *items, zbx_agent_value_t *values, int *errcodes, size_t values_num);
900 int	zbx_dc_get_host_interfaces(zbx_uint64_t hostid, DC_INTERFACE2 **interfaces, int *n);
901 
902 void	zbx_dc_update_proxy(zbx_proxy_diff_t *diff);
903 void	zbx_dc_get_proxy_lastaccess(zbx_vector_uint64_pair_t *lastaccess);
904 void	zbx_dc_proxy_update_nodata(zbx_vector_uint64_pair_t *subscriptions);
905 
906 typedef struct
907 {
908 	zbx_uint64_t		triggerid;
909 	unsigned char		status;
910 	zbx_vector_uint64_t	masterids;
911 }
912 zbx_trigger_dep_t;
913 
914 void	zbx_dc_get_trigger_dependencies(const zbx_vector_uint64_t *triggerids, zbx_vector_ptr_t *deps);
915 
916 void	zbx_dc_reschedule_items(const zbx_vector_uint64_t *itemids, int nextcheck, zbx_uint64_t *proxy_hostids);
917 
918 /* data session support */
919 
920 typedef struct
921 {
922 	zbx_uint64_t	hostid;
923 	zbx_uint64_t	last_valueid;
924 	const char	*token;
925 	time_t		lastaccess;
926 }
927 zbx_data_session_t;
928 
929 const char	*zbx_dc_get_session_token(void);
930 zbx_data_session_t	*zbx_dc_get_or_create_data_session(zbx_uint64_t hostid, const char *token);
931 void	zbx_dc_cleanup_data_sessions(void);
932 
933 /* maintenance support */
934 
935 typedef struct
936 {
937 	zbx_uint64_t	hostid;
938 	zbx_uint64_t	maintenanceid;
939 	int		maintenance_from;
940 	unsigned char	maintenance_type;
941 	unsigned char	maintenance_status;
942 
943 	unsigned int	flags;
944 #define ZBX_FLAG_HOST_MAINTENANCE_UPDATE_MAINTENANCEID		0x0001
945 #define ZBX_FLAG_HOST_MAINTENANCE_UPDATE_MAINTENANCE_FROM	0x0002
946 #define ZBX_FLAG_HOST_MAINTENANCE_UPDATE_MAINTENANCE_TYPE	0x0003
947 #define ZBX_FLAG_HOST_MAINTENANCE_UPDATE_MAINTENANCE_STATUS	0x0004
948 }
949 zbx_host_maintenance_diff_t;
950 
951 /* event maintenance query data, used to get event maintenances from cache */
952 typedef struct
953 {
954 	zbx_uint64_t			eventid;		/* [IN] eventid */
955 	zbx_uint64_t			r_eventid;		/* [-] recovery eventid */
956 	zbx_uint64_t			triggerid;		/* [-] triggerid */
957 	zbx_vector_uint64_t		functionids;		/* [IN] associated functionids */
958 	zbx_vector_ptr_t		tags;			/* [IN] event tags */
959 	zbx_vector_uint64_pair_t	maintenances;		/* [OUT] actual maintenance data for the event in */
960 								/* (maintenanceid, suppress_until) pairs */
961 }
962 zbx_event_suppress_query_t;
963 
964 #define ZBX_MAINTENANCE_UPDATE_TRUE	1
965 #define ZBX_MAINTENANCE_UPDATE_FALSE	0
966 
967 void	zbx_event_suppress_query_free(zbx_event_suppress_query_t *query);
968 int	zbx_dc_update_maintenances(void);
969 void	zbx_dc_get_host_maintenance_updates(const zbx_vector_uint64_t *maintenanceids, zbx_vector_ptr_t *updates);
970 void	zbx_dc_flush_host_maintenance_updates(const zbx_vector_ptr_t *updates);
971 int	zbx_dc_get_event_maintenances(zbx_vector_ptr_t *event_queries, const zbx_vector_uint64_t *maintenanceids);
972 int	zbx_dc_get_running_maintenanceids(zbx_vector_uint64_t *maintenanceids);
973 
974 void	zbx_dc_maintenance_set_update_flags(void);
975 void	zbx_dc_maintenance_reset_update_flag(int timer);
976 int	zbx_dc_maintenance_check_update_flag(int timer);
977 int	zbx_dc_maintenance_check_update_flags(void);
978 
979 int	zbx_dc_maintenance_has_tags(void);
980 
981 typedef struct
982 {
983 	char	*lld_macro;
984 	char	*path;
985 }
986 zbx_lld_macro_path_t;
987 
988 int	zbx_lld_macro_paths_get(zbx_uint64_t lld_ruleid, zbx_vector_ptr_t *lld_macro_paths, char **error);
989 void	zbx_lld_macro_path_free(zbx_lld_macro_path_t *lld_macro_path);
990 int	zbx_lld_macro_value_by_name(const struct zbx_json_parse *jp_row, const zbx_vector_ptr_t *lld_macro_paths,
991 		const char *macro, char **value);
992 int	zbx_lld_macro_paths_compare(const void *d1, const void *d2);
993 
994 void	zbx_dc_get_item_tags(zbx_uint64_t itemid, zbx_vector_ptr_t *item_tags);
995 void	zbx_dc_get_item_tags_by_functionids(const zbx_uint64_t *functionids, size_t functionids_num,
996 		zbx_vector_ptr_t *item_tags);
997 void	zbx_dc_get_item_tags(zbx_uint64_t itemid, zbx_vector_ptr_t *item_tags);
998 
999 unsigned char	zbx_dc_set_macro_env(unsigned char env);
1000 
1001 const char	*zbx_dc_get_instanceid(void);
1002 
1003 char	*zbx_dc_expand_user_macros(const char *text, zbx_uint64_t hostid);
1004 char	*zbx_dc_expand_user_macros_in_func_params(const char *params, zbx_uint64_t hostid);
1005 int	zbx_dc_expand_user_macros_len(const char *text, size_t text_len, zbx_uint64_t *hostids, int hostids_num,
1006 		char **value, char **error);
1007 
1008 
1009 /* diagnostic data */
1010 void	zbx_hc_get_diag_stats(zbx_uint64_t *items_num, zbx_uint64_t *values_num);
1011 void	zbx_hc_get_mem_stats(zbx_mem_stats_t *data, zbx_mem_stats_t *index);
1012 void	zbx_hc_get_items(zbx_vector_uint64_pair_t *items);
1013 
1014 typedef struct
1015 {
1016 	zbx_uint64_t		objectid;
1017 	zbx_uint64_t		triggerid;
1018 	zbx_uint32_t		type;
1019 	zbx_time_unit_t		trend_base;
1020 	unsigned char		lock;		/* 1 if the timer has locked trigger, 0 otherwise */
1021 	int			revision;	/* revision */
1022 	zbx_timespec_t		eval_ts;	/* the history time for which trigger must be recalculated */
1023 	zbx_timespec_t		exec_ts;	/* real time when the timer must be executed */
1024 	const char		*parameter;	/* function parameters (for trend functions) */
1025 }
1026 zbx_trigger_timer_t;
1027 
1028 void	zbx_dc_reschedule_trigger_timers(zbx_vector_ptr_t *timers, int now);
1029 void	zbx_dc_get_trigger_timers(zbx_vector_ptr_t *timers, int now, int soft_limit, int hard_limit);
1030 void	zbx_dc_clear_timer_queue(zbx_vector_ptr_t *timers);
1031 void	zbx_dc_get_triggers_by_timers(zbx_hashset_t *trigger_info, zbx_vector_ptr_t *trigger_order,
1032 		const zbx_vector_ptr_t *timers);
1033 void	zbx_dc_free_timers(zbx_vector_ptr_t *timers);
1034 
1035 int	zbx_db_trigger_queue_locked(void);
1036 void	zbx_db_trigger_queue_unlock(void);
1037 
1038 void	zbx_get_host_interfaces_availability(zbx_uint64_t	hostid, zbx_agent_availability_t *agents);
1039 
1040 int	zbx_hc_check_proxy(zbx_uint64_t proxyid);
1041 
1042 void	zbx_dc_eval_expand_user_macros(zbx_eval_context_t *ctx);
1043 
1044 #endif
1045