diff options
author | Andrejs Kozlovs <andrejs.kozlovs@zabbix.com> | 2022-11-04 10:45:04 +0300 |
---|---|---|
committer | Andrejs Kozlovs <andrejs.kozlovs@zabbix.com> | 2022-11-04 10:45:33 +0300 |
commit | 6c2e0ea8f575888e229b40d09420bf563e709592 (patch) | |
tree | 38112fe386b97a61dce96c765fc4b4462733119c /include | |
parent | f222ac6f3e5c05834b41c73a1b589fb291f5d69c (diff) |
.......... [DEV-2135] refactored dbcache part 1
Diffstat (limited to 'include')
-rw-r--r-- | include/preproc.h | 2 | ||||
-rw-r--r-- | include/zbxcacheconfig.h (renamed from include/dbcache.h) | 169 | ||||
-rw-r--r-- | include/zbxcachehistory.h | 136 | ||||
-rw-r--r-- | include/zbxcachevalue.h | 122 | ||||
-rw-r--r-- | include/zbxdbhigh.h | 26 | ||||
-rw-r--r-- | include/zbxdbwrap.h | 21 | ||||
-rw-r--r-- | include/zbxhistory.h | 14 | ||||
-rw-r--r-- | include/zbxserver.h | 2 | ||||
-rw-r--r-- | include/zbxtrends.h | 2 |
9 files changed, 313 insertions, 181 deletions
diff --git a/include/preproc.h b/include/preproc.h index 662110dbcb6..4db4fc1901a 100644 --- a/include/preproc.h +++ b/include/preproc.h @@ -21,7 +21,7 @@ #define ZABBIX_PREPROC_H #include "module.h" -#include "dbcache.h" +#include "zbxcacheconfig.h" /* preprocessing step execution result */ typedef struct diff --git a/include/dbcache.h b/include/zbxcacheconfig.h index a99d998c39d..59be3a38d8b 100644 --- a/include/dbcache.h +++ b/include/zbxcacheconfig.h @@ -1,9 +1,8 @@ /* -** Zabbix ** Copyright (C) 2001-2022 Zabbix SIA ** ** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by +* it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** @@ -17,19 +16,15 @@ ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ -#ifndef ZABBIX_DBCACHE_H -#define ZABBIX_DBCACHE_H +#ifndef ZABBIX_CACHECONFIG_H +#define ZABBIX_CACHECONFIG_H #include "zbxdbhigh.h" #include "zbxcomms.h" -#include "zbxshmem.h" #include "zbxeval.h" #include "zbxavailability.h" #include "zbxversion.h" -#define ZBX_SYNC_DONE 0 -#define ZBX_SYNC_MORE 1 - #define ZBX_NO_POLLER 255 #define ZBX_POLLER_TYPE_NORMAL 0 #define ZBX_POLLER_TYPE_UNREACHABLE 1 @@ -60,10 +55,6 @@ zbx_session_type_t; #define ZBX_SNMPTRAP_LOGGING_ENABLED 1 -#define ZBX_IPC_SERVICE_CONFIG "config" -#define ZBX_IPC_CONFIG_RELOAD_REQUEST 1 -#define ZBX_IPC_CONFIG_RELOAD_RESPONSE 2 - #define ZBX_AGENT_ZABBIX (INTERFACE_TYPE_AGENT - 1) #define ZBX_AGENT_SNMP (INTERFACE_TYPE_SNMP - 1) #define ZBX_AGENT_IPMI (INTERFACE_TYPE_IPMI - 1) @@ -74,9 +65,6 @@ zbx_session_type_t; extern int CONFIG_TIMEOUT; extern zbx_uint64_t CONFIG_CONF_CACHE_SIZE; -extern zbx_uint64_t CONFIG_HISTORY_CACHE_SIZE; -extern zbx_uint64_t CONFIG_HISTORY_INDEX_CACHE_SIZE; -extern zbx_uint64_t CONFIG_TRENDS_CACHE_SIZE; extern int CONFIG_POLLER_FORKS; extern int CONFIG_UNREACHABLE_POLLER_FORKS; @@ -283,14 +271,6 @@ typedef struct _DC_TRIGGER } DC_TRIGGER; -/* needed to collect and pass data about items that are involved in generating problem events */ -typedef struct -{ - zbx_uint64_t triggerid; - zbx_vector_uint64_t itemids; -} -zbx_trigger_items_t; - typedef struct { zbx_uint64_t hostid; @@ -327,20 +307,6 @@ typedef struct } DC_PROXY; -typedef struct -{ - zbx_uint64_t autoreg_hostid; - zbx_uint64_t hostid; - char *host; - char *ip; - char *dns; - char *host_metadata; - int now; - unsigned short port; - unsigned short flag; - unsigned int connection_type; -} -zbx_autoreg_host_t; #define ZBX_ACTION_OPCLASS_NONE 0 #define ZBX_ACTION_OPCLASS_NORMAL 1 @@ -514,48 +480,6 @@ typedef struct } zbx_correlation_rules_t; -/* value_avg_t structure is used for item average value trend calculations. */ -/* */ -/* For double values the average value is calculated on the fly with the */ -/* following formula: avg = (dbl * count + value) / (count + 1) and stored */ -/* into dbl member. */ -/* For uint64 values the item values are summed into ui64 member and the */ -/* average value is calculated before flushing trends to database: */ -/* avg = ui64 / count */ -typedef union -{ - double dbl; - zbx_uint128_t ui64; -} -value_avg_t; - -typedef struct -{ - zbx_uint64_t itemid; - history_value_t value_min; - value_avg_t value_avg; - history_value_t value_max; - int clock; - int num; - int disable_from; - unsigned char value_type; -} -ZBX_DC_TREND; - -typedef struct -{ - zbx_uint64_t itemid; - history_value_t value; - zbx_uint64_t lastlogsize; - zbx_timespec_t ts; - int mtime; - unsigned char value_type; - unsigned char flags; /* see ZBX_DC_FLAG_* */ - unsigned char state; - int ttl; /* time-to-live of the history value */ -} -ZBX_DC_HISTORY; - /* item queue data */ typedef struct { @@ -580,13 +504,6 @@ typedef struct } zbx_proxy_counter_t; -typedef enum -{ - ZBX_COUNTER_TYPE_UI64, - ZBX_COUNTER_TYPE_DBL -} -zbx_counter_type_t; - typedef struct { unsigned char type; @@ -623,31 +540,6 @@ typedef struct } zbx_config_cache_info_t; -typedef struct -{ - zbx_uint64_t history_counter; /* the total number of processed values */ - zbx_uint64_t history_float_counter; /* the number of processed float values */ - zbx_uint64_t history_uint_counter; /* the number of processed uint values */ - zbx_uint64_t history_str_counter; /* the number of processed str values */ - zbx_uint64_t history_log_counter; /* the number of processed log values */ - zbx_uint64_t history_text_counter; /* the number of processed text values */ - zbx_uint64_t notsupported_counter; /* the number of processed not supported items */ -} -ZBX_DC_STATS; - -/* the write cache statistics */ -typedef struct -{ - ZBX_DC_STATS stats; - zbx_uint64_t history_free; - zbx_uint64_t history_total; - zbx_uint64_t index_free; - zbx_uint64_t index_total; - zbx_uint64_t trend_free; - zbx_uint64_t trend_total; -} -zbx_wcache_info_t; - int is_item_processed_by_server(unsigned char type, const char *key); int zbx_is_counted_in_item_queue(unsigned char type, const char *key); int in_maintenance_without_data_collection(unsigned char maintenance_status, unsigned char maintenance_type, @@ -655,46 +547,10 @@ int in_maintenance_without_data_collection(unsigned char maintenance_status, uns void dc_add_history(zbx_uint64_t itemid, unsigned char item_value_type, unsigned char item_flags, AGENT_RESULT *result, const zbx_timespec_t *ts, unsigned char state, const char *error); void dc_flush_history(void); -void zbx_sync_history_cache(int *values_num, int *triggers_num, int *more); -void zbx_log_sync_history_cache_progress(void); #define ZBX_SYNC_NONE 0 #define ZBX_SYNC_ALL 1 -int init_database_cache(char **error); -void free_database_cache(int); - -void change_proxy_history_count(int change_count); -void reset_proxy_history_count(int reset); -int get_proxy_history_count(void); - -#define ZBX_STATS_HISTORY_COUNTER 0 -#define ZBX_STATS_HISTORY_FLOAT_COUNTER 1 -#define ZBX_STATS_HISTORY_UINT_COUNTER 2 -#define ZBX_STATS_HISTORY_STR_COUNTER 3 -#define ZBX_STATS_HISTORY_LOG_COUNTER 4 -#define ZBX_STATS_HISTORY_TEXT_COUNTER 5 -#define ZBX_STATS_NOTSUPPORTED_COUNTER 6 -#define ZBX_STATS_HISTORY_TOTAL 7 -#define ZBX_STATS_HISTORY_USED 8 -#define ZBX_STATS_HISTORY_FREE 9 -#define ZBX_STATS_HISTORY_PUSED 10 -#define ZBX_STATS_HISTORY_PFREE 11 -#define ZBX_STATS_TREND_TOTAL 12 -#define ZBX_STATS_TREND_USED 13 -#define ZBX_STATS_TREND_FREE 14 -#define ZBX_STATS_TREND_PUSED 15 -#define ZBX_STATS_TREND_PFREE 16 -#define ZBX_STATS_HISTORY_INDEX_TOTAL 17 -#define ZBX_STATS_HISTORY_INDEX_USED 18 -#define ZBX_STATS_HISTORY_INDEX_FREE 19 -#define ZBX_STATS_HISTORY_INDEX_PUSED 20 -#define ZBX_STATS_HISTORY_INDEX_PFREE 21 -void *DCget_stats(int request); -void DCget_stats_all(zbx_wcache_info_t *wcache_info); - -zbx_uint64_t DCget_nextid(const char *table_name, int num); - /* initial sync, get all data */ #define ZBX_DBSYNC_INIT 0 /* update sync, get changed data */ @@ -800,8 +656,6 @@ void DCrequeue_items(const zbx_uint64_t *itemids, const int *lastclocks, void DCpoller_requeue_items(const zbx_uint64_t *itemids, const int *lastclocks, const int *errcodes, size_t num, unsigned char poller_type, int *nextcheck); void zbx_dc_requeue_unreachable_items(zbx_uint64_t *itemids, size_t itemids_num); -int DCconfig_activate_host(DC_ITEM *item); -int DCconfig_deactivate_host(DC_ITEM *item, int now); int DCconfig_check_trigger_dependencies(zbx_uint64_t triggerid); @@ -898,7 +752,6 @@ void zbx_config_get_hk_mode(unsigned char *history_mode, unsigned char *trends_m int DCset_interfaces_availability(zbx_vector_availability_ptr_t *availabilities); int DCreset_interfaces_availability(zbx_vector_availability_ptr_t *interfaces); -void DCupdate_interfaces_availability(void); void zbx_dc_get_actions_eval(zbx_vector_ptr_t *actions, unsigned char opflags); @@ -953,7 +806,6 @@ zbx_hc_item_t; void zbx_free_item_tag(zbx_item_tag_t *item_tag); int zbx_dc_get_active_proxy_by_name(const char *name, DC_PROXY *proxy, char **error); -void zbx_dc_update_proxy_version(zbx_uint64_t hostid, int version); typedef struct { @@ -1088,11 +940,6 @@ void zbx_dc_get_item_tags_by_functionids(const zbx_uint64_t *functionids, size_t const char *zbx_dc_get_instanceid(void); -/* diagnostic data */ -void zbx_hc_get_diag_stats(zbx_uint64_t *items_num, zbx_uint64_t *values_num); -void zbx_hc_get_mem_stats(zbx_shmem_stats_t *data, zbx_shmem_stats_t *index); -void zbx_hc_get_items(zbx_vector_uint64_pair_t *items); - typedef struct { zbx_uint64_t objectid; @@ -1116,21 +963,11 @@ void zbx_dc_get_triggers_by_timers(zbx_hashset_t *trigger_info, zbx_vector_ptr_t const zbx_vector_ptr_t *timers); void zbx_dc_free_timers(zbx_vector_ptr_t *timers); -int zbx_db_trigger_queue_locked(void); -void zbx_db_trigger_queue_unlock(void); - void zbx_get_host_interfaces_availability(zbx_uint64_t hostid, zbx_agent_availability_t *agents); -int zbx_hc_check_proxy(zbx_uint64_t proxyid); - typedef int (*zbx_trigger_func_t)(zbx_variant_t *, const DC_ITEM *, const char *, const char *, const zbx_timespec_t *, char **); -void zbx_db_trigger_explain_expression(const ZBX_DB_TRIGGER *trigger, char **expression, - zbx_trigger_func_t eval_func_cb, int recovery); -void zbx_db_trigger_get_function_value(const ZBX_DB_TRIGGER *trigger, int index, char **value, - zbx_trigger_func_t eval_func_cb, int recovery); - /* external user macro cache API */ typedef struct zbx_dc_um_handle_t zbx_dc_um_handle_t; diff --git a/include/zbxcachehistory.h b/include/zbxcachehistory.h new file mode 100644 index 00000000000..b944d93294c --- /dev/null +++ b/include/zbxcachehistory.h @@ -0,0 +1,136 @@ +/* +** Zabbix +** Copyright (C) 2001-2022 Zabbix SIA +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +**/ + +#ifndef ZABBIX_CACHEHISTORY_H +#define ZABBIX_CACHEHISTORY_H + +#include "zbxcacheconfig.h" +#include "zbxshmem.h" + +#define ZBX_SYNC_DONE 0 +#define ZBX_SYNC_MORE 1 + +extern zbx_uint64_t CONFIG_HISTORY_CACHE_SIZE; +extern zbx_uint64_t CONFIG_HISTORY_INDEX_CACHE_SIZE; +extern zbx_uint64_t CONFIG_TRENDS_CACHE_SIZE; + +/* value_avg_t structure is used for item average value trend calculations. */ +/* */ +/* For double values the average value is calculated on the fly with the */ +/* following formula: avg = (dbl * count + value) / (count + 1) and stored */ +/* into dbl member. */ +/* For uint64 values the item values are summed into ui64 member and the */ +/* average value is calculated before flushing trends to database: */ +/* avg = ui64 / count */ +typedef union +{ + double dbl; + zbx_uint128_t ui64; +} +value_avg_t; + +typedef struct +{ + zbx_uint64_t itemid; + history_value_t value_min; + value_avg_t value_avg; + history_value_t value_max; + int clock; + int num; + int disable_from; + unsigned char value_type; +} +ZBX_DC_TREND; + +typedef struct +{ + zbx_uint64_t history_counter; /* the total number of processed values */ + zbx_uint64_t history_float_counter; /* the number of processed float values */ + zbx_uint64_t history_uint_counter; /* the number of processed uint values */ + zbx_uint64_t history_str_counter; /* the number of processed str values */ + zbx_uint64_t history_log_counter; /* the number of processed log values */ + zbx_uint64_t history_text_counter; /* the number of processed text values */ + zbx_uint64_t notsupported_counter; /* the number of processed not supported items */ +} +ZBX_DC_STATS; + +/* the write cache statistics */ +typedef struct +{ + ZBX_DC_STATS stats; + zbx_uint64_t history_free; + zbx_uint64_t history_total; + zbx_uint64_t index_free; + zbx_uint64_t index_total; + zbx_uint64_t trend_free; + zbx_uint64_t trend_total; +} +zbx_wcache_info_t; + +void zbx_sync_history_cache(int *values_num, int *triggers_num, int *more); +void zbx_log_sync_history_cache_progress(void); + +#define ZBX_SYNC_NONE 0 +#define ZBX_SYNC_ALL 1 + +int init_database_cache(char **error); +void free_database_cache(int); + +void change_proxy_history_count(int change_count); +void reset_proxy_history_count(int reset); +int get_proxy_history_count(void); + +#define ZBX_STATS_HISTORY_COUNTER 0 +#define ZBX_STATS_HISTORY_FLOAT_COUNTER 1 +#define ZBX_STATS_HISTORY_UINT_COUNTER 2 +#define ZBX_STATS_HISTORY_STR_COUNTER 3 +#define ZBX_STATS_HISTORY_LOG_COUNTER 4 +#define ZBX_STATS_HISTORY_TEXT_COUNTER 5 +#define ZBX_STATS_NOTSUPPORTED_COUNTER 6 +#define ZBX_STATS_HISTORY_TOTAL 7 +#define ZBX_STATS_HISTORY_USED 8 +#define ZBX_STATS_HISTORY_FREE 9 +#define ZBX_STATS_HISTORY_PUSED 10 +#define ZBX_STATS_HISTORY_PFREE 11 +#define ZBX_STATS_TREND_TOTAL 12 +#define ZBX_STATS_TREND_USED 13 +#define ZBX_STATS_TREND_FREE 14 +#define ZBX_STATS_TREND_PUSED 15 +#define ZBX_STATS_TREND_PFREE 16 +#define ZBX_STATS_HISTORY_INDEX_TOTAL 17 +#define ZBX_STATS_HISTORY_INDEX_USED 18 +#define ZBX_STATS_HISTORY_INDEX_FREE 19 +#define ZBX_STATS_HISTORY_INDEX_PUSED 20 +#define ZBX_STATS_HISTORY_INDEX_PFREE 21 +void *DCget_stats(int request); +void DCget_stats_all(zbx_wcache_info_t *wcache_info); + +zbx_uint64_t DCget_nextid(const char *table_name, int num); + +void DCupdate_interfaces_availability(void); + +void zbx_hc_get_diag_stats(zbx_uint64_t *items_num, zbx_uint64_t *values_num); +void zbx_hc_get_mem_stats(zbx_shmem_stats_t *data, zbx_shmem_stats_t *index); +void zbx_hc_get_items(zbx_vector_uint64_pair_t *items); + +int zbx_db_trigger_queue_locked(void); +void zbx_db_trigger_queue_unlock(void); + +int zbx_hc_check_proxy(zbx_uint64_t proxyid); +#endif diff --git a/include/zbxcachevalue.h b/include/zbxcachevalue.h new file mode 100644 index 00000000000..8afbb280dfc --- /dev/null +++ b/include/zbxcachevalue.h @@ -0,0 +1,122 @@ +/* +** Zabbix +** Copyright (C) 2001-2022 Zabbix SIA +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +**/ + +#ifndef ZABBIX_CACHEVALUE_H +#define ZABBIX_CACHEVALUE_H + +#include "zbxtypes.h" +#include "zbxalgo.h" +#include "zbxhistory.h" +#include "zbxshmem.h" + +/* + * The Value Cache provides read caching of item historical data residing in history + * tables. No components must read history tables manually. Instead all history data + * must be read from the Value Cache. + * + * Usage notes: + * + * Initialization + * + * The value cache must be initialized at the start of the program with zbx_vc_init() + * function. To ensure proper removal of shared memory the value cache must be destroyed + * upon a program exit with zbx_vc_destroy() function. + * + * Adding data + * + * Whenever a new item value is added to system (history tables) the item value must be + * also added added to Value Cache with zbx_dc_add_value() function to keep it up to date. + * + * Retrieving data + * + * The history data is accessed with zbx_vc_get_values() and zbx_vc_get_value() + * functions. Afterwards the retrieved history data must be freed by the caller by using + * either zbx_history_record_vector_destroy() function (free the zbx_vc_get_values() + * call output) or zbx_history_record_clear() function (free the zbx_vc_get_value() call output). + * + * Locking + * + * The cache ensures synchronization between processes by using automatic locks whenever + * a cache function (zbx_vc_*) is called and by providing manual cache locking functionality + * with zbx_vc_lock()/zbx_vc_unlock() functions. + * + */ + +#define ZBX_VC_MODE_NORMAL 0 +#define ZBX_VC_MODE_LOWMEM 1 + +/* indicates that all values from database are cached */ +#define ZBX_ITEM_STATUS_CACHED_ALL 1 + +/* the cache statistics */ +typedef struct +{ + /* Value cache misses are new values cached during request and hits are calculated by */ + /* subtracting misses from the total number of values returned (0 if the number of */ + /* returned values is less than misses. */ + /* When performing count based requests the number of cached values might be greater */ + /* than number of returned values. This can skew the hits/misses ratio towards misses. */ + zbx_uint64_t hits; + zbx_uint64_t misses; + + zbx_uint64_t total_size; + zbx_uint64_t free_size; + + /* value cache operating mode - see ZBX_VC_MODE_* defines */ + int mode; +} +zbx_vc_stats_t; + +/* item diagnostic statistics */ +typedef struct +{ + zbx_uint64_t itemid; + int values_num; + int hourly_num; +} +zbx_vc_item_stats_t; + +int zbx_vc_init(char **error); + +void zbx_vc_destroy(void); + +void zbx_vc_reset(void); + +void zbx_vc_enable(void); + +void zbx_vc_disable(void); + +int zbx_vc_get_values(zbx_uint64_t itemid, unsigned char value_type, zbx_vector_history_record_t *values, + int seconds, int count, const zbx_timespec_t *ts); + +int zbx_vc_get_value(zbx_uint64_t itemid, unsigned char value_type, const zbx_timespec_t *ts, + zbx_history_record_t *value); + +int zbx_vc_add_values(zbx_vector_ptr_t *history, int *ret_flush); + +int zbx_vc_get_statistics(zbx_vc_stats_t *stats); + +void zbx_vc_remove_items_by_ids(zbx_vector_uint64_t *itemids); + +void zbx_vc_get_diag_stats(zbx_uint64_t *items_num, zbx_uint64_t *values_num, int *mode); +void zbx_vc_get_mem_stats(zbx_shmem_stats_t *mem); +void zbx_vc_get_item_stats(zbx_vector_ptr_t *stats); +void zbx_vc_flush_stats(void); + +#endif diff --git a/include/zbxdbhigh.h b/include/zbxdbhigh.h index cba6dacf19d..03067c163fd 100644 --- a/include/zbxdbhigh.h +++ b/include/zbxdbhigh.h @@ -640,10 +640,6 @@ typedef struct } zbx_item_diff_t; -void zbx_db_trigger_get_expression(const ZBX_DB_TRIGGER *trigger, char **expression); -void zbx_db_trigger_get_recovery_expression(const ZBX_DB_TRIGGER *trigger, char **expression); -void zbx_db_trigger_clean(ZBX_DB_TRIGGER *trigger); - typedef struct { zbx_uint64_t hostid; @@ -775,13 +771,6 @@ void zbx_load_lld_override_operations(const zbx_vector_uint64_t *overrideids, ch #define ZBX_TIMEZONE_DEFAULT_VALUE "default" -void zbx_db_trigger_get_all_functionids(const ZBX_DB_TRIGGER *trigger, zbx_vector_uint64_t *functionids); -void zbx_db_trigger_get_functionids(const ZBX_DB_TRIGGER *trigger, zbx_vector_uint64_t *functionids); -int zbx_db_trigger_get_all_hostids(const ZBX_DB_TRIGGER *trigger, const zbx_vector_uint64_t **hostids); -int zbx_db_trigger_get_constant(const ZBX_DB_TRIGGER *trigger, int index, char **out); -int zbx_db_trigger_get_itemid(const ZBX_DB_TRIGGER *trigger, int index, zbx_uint64_t *itemid); -void zbx_db_trigger_get_itemids(const ZBX_DB_TRIGGER *trigger, zbx_vector_uint64_t *itemids); - int zbx_db_check_version_info(struct zbx_db_version_info_t *info, int allow_unsupported); void zbx_db_version_info_clear(struct zbx_db_version_info_t *version_info); @@ -832,4 +821,19 @@ int zbx_get_proxy_protocol_version_int(const char *version_str); #define ZBX_CONDITION_TYPE_SERVICE 27 #define ZBX_CONDITION_TYPE_SERVICE_NAME 28 +typedef struct +{ + zbx_uint64_t autoreg_hostid; + zbx_uint64_t hostid; + char *host; + char *ip; + char *dns; + char *host_metadata; + int now; + unsigned short port; + unsigned short flag; + unsigned int connection_type; +} +zbx_autoreg_host_t; + #endif /* ZABBIX_DBHIGH_H */ diff --git a/include/zbxdbwrap.h b/include/zbxdbwrap.h index aa3edf00ba3..6c68c328dc6 100644 --- a/include/zbxdbwrap.h +++ b/include/zbxdbwrap.h @@ -21,7 +21,7 @@ #define ZABBIX_DBWRAP_H #include "zbxdbhigh.h" -#include "dbcache.h" +#include "zbxcachehistory.h" #define ZBX_PROXYMODE_ACTIVE 0 #define ZBX_PROXYMODE_PASSIVE 1 @@ -101,4 +101,23 @@ void zbx_db_free_event(ZBX_DB_EVENT *event); void zbx_db_get_eventid_r_eventid_pairs(zbx_vector_uint64_t *eventids, zbx_vector_uint64_pair_t *event_pairs, zbx_vector_uint64_t *r_eventids); +void zbx_db_trigger_get_all_functionids(const ZBX_DB_TRIGGER *trigger, zbx_vector_uint64_t *functionids); +void zbx_db_trigger_get_functionids(const ZBX_DB_TRIGGER *trigger, zbx_vector_uint64_t *functionids); +int zbx_db_trigger_get_constant(const ZBX_DB_TRIGGER *trigger, int index, char **out); +int zbx_db_trigger_get_all_hostids(const ZBX_DB_TRIGGER *trigger, const zbx_vector_uint64_t **hostids); +int zbx_db_trigger_get_itemid(const ZBX_DB_TRIGGER *trigger, int index, zbx_uint64_t *itemid); +void zbx_db_trigger_get_itemids(const ZBX_DB_TRIGGER *trigger, zbx_vector_uint64_t *itemids); + +void zbx_db_trigger_get_expression(const ZBX_DB_TRIGGER *trigger, char **expression); +void zbx_db_trigger_get_recovery_expression(const ZBX_DB_TRIGGER *trigger, char **expression); +void zbx_db_trigger_clean(ZBX_DB_TRIGGER *trigger); + +typedef int (*zbx_trigger_func_t)(zbx_variant_t *, const DC_ITEM *, const char *, const char *, + const zbx_timespec_t *, char **); + +void zbx_db_trigger_explain_expression(const ZBX_DB_TRIGGER *trigger, char **expression, + zbx_trigger_func_t eval_func_cb, int recovery); +void zbx_db_trigger_get_function_value(const ZBX_DB_TRIGGER *trigger, int index, char **value, + zbx_trigger_func_t eval_func_cb, int recovery); + #endif /* ZABBIX_DBWRAP_H */ diff --git a/include/zbxhistory.h b/include/zbxhistory.h index e5407471841..ce2b7097d31 100644 --- a/include/zbxhistory.h +++ b/include/zbxhistory.h @@ -67,4 +67,18 @@ void zbx_history_check_version(struct zbx_json *json, int *result); #define FLUSH_FAIL -1 #define FLUSH_DUPL_REJECTED -2 +typedef struct +{ + zbx_uint64_t itemid; + history_value_t value; + zbx_uint64_t lastlogsize; + zbx_timespec_t ts; + int mtime; + unsigned char value_type; + unsigned char flags; /* see ZBX_DC_FLAG_* */ + unsigned char state; + int ttl; /* time-to-live of the history value */ +} +ZBX_DC_HISTORY; + #endif diff --git a/include/zbxserver.h b/include/zbxserver.h index 3ee7a23f38f..2f164e5caf2 100644 --- a/include/zbxserver.h +++ b/include/zbxserver.h @@ -20,7 +20,7 @@ #ifndef ZABBIX_ZBXSERVER_H #define ZABBIX_ZBXSERVER_H -#include "dbcache.h" +#include "zbxcachehistory.h" #include "zbxvariant.h" #define MACRO_TYPE_MESSAGE_NORMAL 0x00000001 diff --git a/include/zbxtrends.h b/include/zbxtrends.h index cfda9865b6f..b3e097a9633 100644 --- a/include/zbxtrends.h +++ b/include/zbxtrends.h @@ -20,7 +20,7 @@ #ifndef ZABBIX_ZBXTRENDS_H #define ZABBIX_ZBXTRENDS_H -#include "dbcache.h" +#include "zbxcachehistory.h" #include "zbxtime.h" int zbx_trends_parse_base(const char *params, zbx_time_unit_t *base, char **error); |