diff options
author | Andrejs Kozlovs <andrejs.kozlovs@zabbix.com> | 2022-11-09 10:58:50 +0300 |
---|---|---|
committer | Andrejs Kozlovs <andrejs.kozlovs@zabbix.com> | 2022-11-09 10:58:50 +0300 |
commit | dea20639a8b3f51b17a219213dbb47a0ac178ecb (patch) | |
tree | 861173b9f07cb6c4c562a6f2fa3190b01d4895b2 | |
parent | d136fbbbe6cd01ae26c017e4750ce2b830a907ee (diff) | |
parent | 39d00691a0a0af2b4de3dfc33a2509e773478f8e (diff) |
.......... [DEV-2135] refactored dbcache part 1
Merge in ZBX/zabbix from feature/DEV-2135-6.3-1 to master
* commit '39d00691a0a0af2b4de3dfc33a2509e773478f8e':
.......... [DEV-2135] fixed PR warnings
.......... [DEV-2135] removed unnecessary typedef
.......... [DEV-2135] fixed some coding stype issues
.......... [DEV-2135] fixed commit hooks
.......... [DEV-2135] refactored dbcache part 1
129 files changed, 1208 insertions, 1074 deletions
diff --git a/configure.ac b/configure.ac index 200cbacd121..1a13a5d0365 100644 --- a/configure.ac +++ b/configure.ac @@ -1953,7 +1953,9 @@ AC_CONFIG_FILES([ src/libs/zbxcrypto/Makefile src/libs/zbxcyberark/Makefile src/libs/zbxdb/Makefile - src/libs/zbxdbcache/Makefile + src/libs/zbxcacheconfig/Makefile + src/libs/zbxcachehistory/Makefile + src/libs/zbxcachevalue/Makefile src/libs/zbxdbhigh/Makefile src/libs/zbxdbwrap/Makefile src/libs/zbxdbschema/Makefile 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..347131dffb7 100644 --- a/include/dbcache.h +++ b/include/zbxcacheconfig.h @@ -17,19 +17,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 +56,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 +66,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 +272,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 +308,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 +481,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 +505,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 +541,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 +548,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 +657,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 +753,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 +807,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 +941,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 +964,8 @@ 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/src/libs/zbxdbcache/valuecache.h b/include/zbxcachevalue.h index d61e1b52d22..8afbb280dfc 100644 --- a/src/libs/zbxdbcache/valuecache.h +++ b/include/zbxcachevalue.h @@ -17,8 +17,8 @@ ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ -#ifndef ZABBIX_VALUECACHE_H -#define ZABBIX_VALUECACHE_H +#ifndef ZABBIX_CACHEVALUE_H +#define ZABBIX_CACHEVALUE_H #include "zbxtypes.h" #include "zbxalgo.h" @@ -119,4 +119,4 @@ 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 /* ZABBIX_VALUECACHE_H */ +#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..9b058ed9846 100644 --- a/include/zbxdbwrap.h +++ b/include/zbxdbwrap.h @@ -21,7 +21,7 @@ #define ZABBIX_DBWRAP_H #include "zbxdbhigh.h" -#include "dbcache.h" +#include "zbxcacheconfig.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); diff --git a/src/libs/Makefile.am b/src/libs/Makefile.am index 9b2cc851f83..ed18d3c695a 100644 --- a/src/libs/Makefile.am +++ b/src/libs/Makefile.am @@ -12,7 +12,9 @@ DIST_SUBDIRS = \ zbxcrypto \ zbxcyberark \ zbxdb \ - zbxdbcache \ + zbxcacheconfig \ + zbxcachehistory \ + zbxcachevalue \ zbxdbhigh \ zbxdbwrap \ zbxdbschema \ @@ -68,7 +70,9 @@ SERVER_SUBDIRS = \ zbxcompress \ zbxcyberark \ zbxdb \ - zbxdbcache \ + zbxcacheconfig \ + zbxcachehistory \ + zbxcachevalue \ zbxdbhigh \ zbxdbwrap \ zbxdbschema \ @@ -111,7 +115,9 @@ PROXY_SUBDIRS = \ zbxcompress \ zbxcyberark \ zbxdb \ - zbxdbcache \ + zbxcacheconfig \ + zbxcachehistory \ + zbxcachevalue \ zbxdbhigh \ zbxdbwrap \ zbxdbschema \ diff --git a/src/libs/zbxaudit/audit.c b/src/libs/zbxaudit/audit.c index c729833829f..d0257a6fcfe 100644 --- a/src/libs/zbxaudit/audit.c +++ b/src/libs/zbxaudit/audit.c @@ -22,7 +22,7 @@ #include "log.h" #include "zbxjson.h" -#include "dbcache.h" +#include "zbxcacheconfig.h" #include "zbxnum.h" #define AUDIT_USERID __UINT64_C(0) diff --git a/src/libs/zbxdbcache/Makefile.am b/src/libs/zbxcacheconfig/Makefile.am index 60d3f944ed4..48a54ca35c7 100644 --- a/src/libs/zbxdbcache/Makefile.am +++ b/src/libs/zbxcacheconfig/Makefile.am @@ -1,9 +1,8 @@ ## Process this file with automake to produce Makefile.in -noinst_LIBRARIES = libzbxdbcache.a +noinst_LIBRARIES = libzbxcacheconfig.a -libzbxdbcache_a_SOURCES = \ - dbcache.c \ +libzbxcacheconfig_a_SOURCES = \ dbconfig.c \ dbconfig.h \ dbconfig_dump.c \ @@ -11,12 +10,10 @@ libzbxdbcache_a_SOURCES = \ dbsync.c \ dbsync.h \ lld_macro.c \ - valuecache.c \ - valuecache.h \ user_macro.c \ user_macro.h -libzbxdbcache_a_CFLAGS = \ +libzbxcacheconfig_a_CFLAGS = \ -I$(top_srcdir)/src/zabbix_server/ \ $(TLS_CFLAGS) \ $(TEST_FLAGS) diff --git a/src/libs/zbxdbcache/dbconfig.c b/src/libs/zbxcacheconfig/dbconfig.c index ef9651f33e4..dd550a688b1 100644 --- a/src/libs/zbxdbcache/dbconfig.c +++ b/src/libs/zbxcacheconfig/dbconfig.c @@ -25,7 +25,6 @@ #include "zbxregexp.h" #include "cfg.h" #include "zbxcrypto.h" -#include "../zbxkvs/kvs.h" #include "../zbxvault/vault.h" #include "base64.h" #include "zbxdbhigh.h" @@ -40,7 +39,6 @@ #include "zbxtime.h" #include "zbxip.h" #include "zbxsysinfo.h" -#include "events.h" int sync_in_progress = 0; diff --git a/src/libs/zbxdbcache/dbconfig.h b/src/libs/zbxcacheconfig/dbconfig.h index b9d3e5a77e2..c378a559511 100644 --- a/src/libs/zbxdbcache/dbconfig.h +++ b/src/libs/zbxcacheconfig/dbconfig.h @@ -20,10 +20,11 @@ #ifndef ZABBIX_DBCONFIG_H #define ZABBIX_DBCONFIG_H +#include "zbxcacheconfig.h" +#include "user_macro.h" + #include "zbxmutexs.h" #include "zbxalgo.h" -#include "dbcache.h" -#include "user_macro.h" #include "zbxversion.h" #define ZBX_MAINTENANCE_IDLE 0 @@ -891,7 +892,7 @@ typedef struct zbx_hashset_t autoreg_hosts; zbx_hashset_t host_inventories; zbx_hashset_t host_inventories_auto; /* For caching of automatically populated host inventories. */ - /* Configuration syncer will read host_inventories without */ + /* Configuration syncer will read host_inventories without */ /* locking cache and therefore it cannot be updated by */ /* by history syncers when new data is received. */ zbx_hashset_t ipmihosts; diff --git a/src/libs/zbxdbcache/dbconfig_dump.c b/src/libs/zbxcacheconfig/dbconfig_dump.c index 95f1876ade7..bda02393f27 100644 --- a/src/libs/zbxdbcache/dbconfig_dump.c +++ b/src/libs/zbxcacheconfig/dbconfig_dump.c @@ -16,13 +16,12 @@ ** along with this program; if not, write to the Free Software ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ - +#include "zbxcacheconfig.h" #include "dbconfig.h" #include "zbxcommon.h" #include "log.h" #include "zbxalgo.h" -#include "dbcache.h" static void DCdump_config(void) { diff --git a/src/libs/zbxdbcache/dbconfig_maintenance.c b/src/libs/zbxcacheconfig/dbconfig_maintenance.c index e7094673ed0..ff84f2563cf 100644 --- a/src/libs/zbxdbcache/dbconfig_maintenance.c +++ b/src/libs/zbxcacheconfig/dbconfig_maintenance.c @@ -17,15 +17,14 @@ ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ +#include "zbxcacheconfig.h" #include "dbconfig.h" #include "log.h" #include "zbxalgo.h" -#include "dbcache.h" #include "dbsync.h" #include "zbxnum.h" #include "zbxtime.h" -#include "zbxexpr.h" extern int CONFIG_TIMER_FORKS; diff --git a/src/libs/zbxdbcache/dbsync.c b/src/libs/zbxcacheconfig/dbsync.c index e3e61718a5a..09378fbd712 100644 --- a/src/libs/zbxdbcache/dbsync.c +++ b/src/libs/zbxcacheconfig/dbsync.c @@ -17,11 +17,10 @@ ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ +#include "zbxcacheconfig.h" #include "dbsync.h" #include "log.h" -#include "dbcache.h" -#include "zbxserialize.h" #include "base64.h" #include "zbxeval.h" #include "zbxnum.h" diff --git a/src/libs/zbxdbcache/dbsync.h b/src/libs/zbxcacheconfig/dbsync.h index d92abd060cb..8e992511f1b 100644 --- a/src/libs/zbxdbcache/dbsync.h +++ b/src/libs/zbxcacheconfig/dbsync.h @@ -20,7 +20,6 @@ #ifndef ZABBIX_DBSYNC_H #define ZABBIX_DBSYNC_H -#include "zbxcommon.h" #include "dbconfig.h" /* no changes */ diff --git a/src/libs/zbxdbcache/lld_macro.c b/src/libs/zbxcacheconfig/lld_macro.c index 28a74c3c29d..d44a41e4d6c 100644 --- a/src/libs/zbxdbcache/lld_macro.c +++ b/src/libs/zbxcacheconfig/lld_macro.c @@ -17,9 +17,9 @@ ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ -#include "zbxcommon.h" +#include "zbxcacheconfig.h" -#include "dbcache.h" +#include "zbxcommon.h" #include "log.h" /****************************************************************************** diff --git a/src/libs/zbxdbcache/user_macro.c b/src/libs/zbxcacheconfig/user_macro.c index 1a51243910e..1a51243910e 100644 --- a/src/libs/zbxdbcache/user_macro.c +++ b/src/libs/zbxcacheconfig/user_macro.c diff --git a/src/libs/zbxdbcache/user_macro.h b/src/libs/zbxcacheconfig/user_macro.h index 3ec3defaf07..b710a259222 100644 --- a/src/libs/zbxdbcache/user_macro.h +++ b/src/libs/zbxcacheconfig/user_macro.h @@ -20,7 +20,6 @@ #ifndef ZBX_USER_MACRO_H #define ZBX_USER_MACRO_H -#include "zbxcommon.h" #include "zbxalgo.h" #define ZBX_UM_CACHE_GLOBAL_MACRO_HOSTID 0 diff --git a/src/libs/zbxcachehistory/Makefile.am b/src/libs/zbxcachehistory/Makefile.am new file mode 100644 index 00000000000..7a9626ff77b --- /dev/null +++ b/src/libs/zbxcachehistory/Makefile.am @@ -0,0 +1,11 @@ +## Process this file with automake to produce Makefile.in + +noinst_LIBRARIES = libzbxcachehistory.a + +libzbxcachehistory_a_SOURCES = \ + dbcache.c + +libzbxcachehistory_a_CFLAGS = \ + -I$(top_srcdir)/src/zabbix_server/ \ + $(TLS_CFLAGS) \ + $(TEST_FLAGS) diff --git a/src/libs/zbxdbcache/dbcache.c b/src/libs/zbxcachehistory/dbcache.c index 6f3ce27d541..a402f530547 100644 --- a/src/libs/zbxdbcache/dbcache.c +++ b/src/libs/zbxcachehistory/dbcache.c @@ -17,17 +17,16 @@ ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ -#include "dbcache.h" +#include "zbxcachehistory.h" +#include "zbxcachevalue.h" #include "log.h" #include "zbxmutexs.h" #include "zbxserver.h" #include "events.h" -#include "valuecache.h" #include "zbxmodules.h" #include "module.h" #include "zbxexport.h" -#include "zbxhistory.h" #include "zbxnix.h" #include "zbxavailability.h" #include "zbxtrends.h" diff --git a/src/libs/zbxcachevalue/Makefile.am b/src/libs/zbxcachevalue/Makefile.am new file mode 100644 index 00000000000..c3694cb0c4b --- /dev/null +++ b/src/libs/zbxcachevalue/Makefile.am @@ -0,0 +1,10 @@ +## Process this file with automake to produce Makefile.in + +noinst_LIBRARIES = libzbxcachevalue.a + +libzbxcachevalue_a_SOURCES = \ + valuecache.c + +libzbxcachevalue_a_CFLAGS = \ + $(TLS_CFLAGS) \ + $(TEST_FLAGS) diff --git a/src/libs/zbxdbcache/valuecache.c b/src/libs/zbxcachevalue/valuecache.c index d6bbe498676..a1bc65634cc 100644 --- a/src/libs/zbxdbcache/valuecache.c +++ b/src/libs/zbxcachevalue/valuecache.c @@ -17,10 +17,9 @@ ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ -#include "valuecache.h" +#include "zbxcachevalue.h" #include "log.h" -#include "dbcache.h" #include "zbxmutexs.h" #include "zbxtime.h" diff --git a/src/libs/zbxdbhigh/db.c b/src/libs/zbxdbhigh/db.c index 06d1afdd089..c19ace6d3cb 100644 --- a/src/libs/zbxdbhigh/db.c +++ b/src/libs/zbxdbhigh/db.c @@ -22,7 +22,6 @@ #include "log.h" #include "events.h" #include "zbxthreads.h" -#include "dbcache.h" #include "cfg.h" #include "zbxcrypto.h" #include "zbxnum.h" diff --git a/src/libs/zbxdbhigh/trigger.c b/src/libs/zbxdbhigh/trigger.c index dcb2eeb7bd7..096c838bcce 100644 --- a/src/libs/zbxdbhigh/trigger.c +++ b/src/libs/zbxdbhigh/trigger.c @@ -20,9 +20,7 @@ #include "zbxdbhigh.h" #include "log.h" -#include "dbcache.h" #include "events.h" -#include "zbxserver.h" #include "zbxnum.h" /****************************************************************************** @@ -130,731 +128,3 @@ void zbx_append_trigger_diff(zbx_vector_ptr_t *trigger_diff, zbx_uint64_t trigge zbx_vector_ptr_append(trigger_diff, diff); } - -/* temporary cache of trigger related data */ -typedef struct -{ - zbx_uint32_t init; - zbx_uint32_t done; - zbx_eval_context_t eval_ctx; - zbx_eval_context_t eval_ctx_r; - zbx_vector_uint64_t hostids; -} -zbx_trigger_cache_t; - -/* related trigger data caching states */ -typedef enum -{ - ZBX_TRIGGER_CACHE_EVAL_CTX, - ZBX_TRIGGER_CACHE_EVAL_CTX_R, - ZBX_TRIGGER_CACHE_EVAL_CTX_MACROS, - ZBX_TRIGGER_CACHE_EVAL_CTX_R_MACROS, - ZBX_TRIGGER_CACHE_HOSTIDS, -} -zbx_trigger_cache_state_t; - -static int db_trigger_expand_macros(const ZBX_DB_TRIGGER *trigger, zbx_eval_context_t *ctx); - -/****************************************************************************** - * * - * Purpose: get trigger cache with the requested data cached * - * * - * Parameters: trigger - [IN] the trigger * - * state - [IN] the required cache state * - * * - ******************************************************************************/ -static zbx_trigger_cache_t *db_trigger_get_cache(const ZBX_DB_TRIGGER *trigger, zbx_trigger_cache_state_t state) -{ - zbx_trigger_cache_t *cache; - char *error = NULL; - zbx_uint32_t flag = 1 << state; - zbx_vector_uint64_t functionids; - - if (NULL == trigger->cache) - { - cache = (zbx_trigger_cache_t *)zbx_malloc(NULL, sizeof(zbx_trigger_cache_t)); - cache->init = cache->done = 0; - ((ZBX_DB_TRIGGER *)trigger)->cache = cache; - } - else - cache = (zbx_trigger_cache_t *)trigger->cache; - - if (0 != (cache->init & flag)) - return 0 != (cache->done & flag) ? cache : NULL; - - cache->init |= flag; - - switch (state) - { - case ZBX_TRIGGER_CACHE_EVAL_CTX: - if ('\0' == *trigger->expression) - return NULL; - - if (FAIL == zbx_eval_parse_expression(&cache->eval_ctx, trigger->expression, - ZBX_EVAL_TRIGGER_EXPRESSION, &error)) - { - zbx_free(error); - return NULL; - } - break; - case ZBX_TRIGGER_CACHE_EVAL_CTX_R: - if ('\0' == *trigger->recovery_expression) - return NULL; - - if (FAIL == zbx_eval_parse_expression(&cache->eval_ctx_r, trigger->recovery_expression, - ZBX_EVAL_TRIGGER_EXPRESSION, &error)) - { - zbx_free(error); - return NULL; - } - break; - case ZBX_TRIGGER_CACHE_EVAL_CTX_MACROS: - if (FAIL == db_trigger_expand_macros(trigger, &cache->eval_ctx)) - return NULL; - - break; - case ZBX_TRIGGER_CACHE_EVAL_CTX_R_MACROS: - if (FAIL == db_trigger_expand_macros(trigger, &cache->eval_ctx_r)) - return NULL; - - break; - case ZBX_TRIGGER_CACHE_HOSTIDS: - zbx_vector_uint64_create(&cache->hostids); - zbx_vector_uint64_create(&functionids); - zbx_db_trigger_get_all_functionids(trigger, &functionids); - DCget_hostids_by_functionids(&functionids, &cache->hostids); - zbx_vector_uint64_destroy(&functionids); - break; - default: - return NULL; - } - - cache->done |= flag; - - return cache; -} - -/****************************************************************************** - * * - * Purpose: expand macros in trigger expression/recovery expression * - * * - ******************************************************************************/ -static int db_trigger_expand_macros(const ZBX_DB_TRIGGER *trigger, zbx_eval_context_t *ctx) -{ - int i; - ZBX_DB_EVENT db_event; - zbx_dc_um_handle_t *um_handle; - zbx_trigger_cache_t *cache; - - if (NULL == (cache = db_trigger_get_cache(trigger, ZBX_TRIGGER_CACHE_HOSTIDS))) - return FAIL; - - db_event.value = trigger->value; - db_event.object = EVENT_OBJECT_TRIGGER; - - um_handle = zbx_dc_open_user_macros(); - - (void)zbx_eval_expand_user_macros(ctx, cache->hostids.values, cache->hostids.values_num, - (zbx_macro_expand_func_t)zbx_dc_expand_user_macros, um_handle, NULL); - - zbx_dc_close_user_macros(um_handle); - - for (i = 0; i < ctx->stack.values_num; i++) - { - char *value; - zbx_eval_token_t *token = &ctx->stack.values[i]; - - switch (token->type) - { - case ZBX_EVAL_TOKEN_VAR_STR: - if (ZBX_VARIANT_NONE != token->value.type) - { - zbx_variant_convert(&token->value, ZBX_VARIANT_STR); - value = token->value.data.str; - zbx_variant_set_none(&token->value); - break; - } - value = zbx_substr_unquote(ctx->expression, token->loc.l, token->loc.r); - break; - case ZBX_EVAL_TOKEN_VAR_MACRO: - value = zbx_substr_unquote(ctx->expression, token->loc.l, token->loc.r); - break; - default: - continue; - } - - if (SUCCEED == zbx_substitute_simple_macros(NULL, &db_event, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, &value, MACRO_TYPE_TRIGGER_EXPRESSION, NULL, 0)) - { - zbx_variant_clear(&token->value); - zbx_variant_set_str(&token->value, value); - } - else - zbx_free(value); - } - - return SUCCEED; -} - -/****************************************************************************** - * * - * Purpose: free trigger cache * - * * - * Parameters: cache - [IN] the trigger cache * - * * - ******************************************************************************/ -static void trigger_cache_free(zbx_trigger_cache_t *cache) -{ - if (0 != (cache->done & (1 << ZBX_TRIGGER_CACHE_EVAL_CTX))) - zbx_eval_clear(&cache->eval_ctx); - - if (0 != (cache->done & (1 << ZBX_TRIGGER_CACHE_EVAL_CTX_R))) - zbx_eval_clear(&cache->eval_ctx_r); - - if (0 != (cache->done & (1 << ZBX_TRIGGER_CACHE_HOSTIDS))) - zbx_vector_uint64_destroy(&cache->hostids); - - zbx_free(cache); -} - -/****************************************************************************** - * * - * Purpose: get functionids from trigger expression and recovery expression * - * * - * Parameters: trigger - [IN] the trigger * - * functionids - [OUT] the extracted functionids * - * * - * Comments: This function will cache parsed expressions in the trigger. * - * * - ******************************************************************************/ -void zbx_db_trigger_get_all_functionids(const ZBX_DB_TRIGGER *trigger, zbx_vector_uint64_t *functionids) -{ - zbx_trigger_cache_t *cache; - - if (NULL != (cache = db_trigger_get_cache(trigger, ZBX_TRIGGER_CACHE_EVAL_CTX))) - zbx_eval_get_functionids(&cache->eval_ctx, functionids); - - if (NULL != (cache = db_trigger_get_cache(trigger, ZBX_TRIGGER_CACHE_EVAL_CTX_R))) - zbx_eval_get_functionids(&cache->eval_ctx_r, functionids); - - zbx_vector_uint64_sort(functionids, ZBX_DEFAULT_UINT64_COMPARE_FUNC); - zbx_vector_uint64_uniq(functionids, ZBX_DEFAULT_UINT64_COMPARE_FUNC); -} - -/****************************************************************************** - * * - * Purpose: get functionids from trigger expression * - * * - * Parameters: trigger - [IN] the trigger * - * functionids - [OUT] the extracted functionids * - * * - * Comments: This function will cache parsed expressions in the trigger. * - * * - ******************************************************************************/ -void zbx_db_trigger_get_functionids(const ZBX_DB_TRIGGER *trigger, zbx_vector_uint64_t *functionids) -{ - zbx_trigger_cache_t *cache; - - if (NULL != (cache = db_trigger_get_cache(trigger, ZBX_TRIGGER_CACHE_EVAL_CTX))) - zbx_eval_get_functionids(&cache->eval_ctx, functionids); - - zbx_vector_uint64_sort(functionids, ZBX_DEFAULT_UINT64_COMPARE_FUNC); - zbx_vector_uint64_uniq(functionids, ZBX_DEFAULT_UINT64_COMPARE_FUNC); -} -/****************************************************************************** - * * - * Purpose: get trigger expression constant at the specified location * - * * - * Parameters: trigger - [IN] the trigger * - * index - [IN] the constant index, starting with 1 * - * out - [IN] the constant value, if exists * - * * - * Return value: SUCCEED - the expression was parsed and constant extracted * - * (if the index was valid) * - * FAIL - the expression failed to parse * - * * - * Comments: This function will cache parsed expressions in the trigger. * - * * - ******************************************************************************/ -int zbx_db_trigger_get_constant(const ZBX_DB_TRIGGER *trigger, int index, char **out) -{ - zbx_trigger_cache_t *cache; - - if (NULL == (cache = db_trigger_get_cache(trigger, ZBX_TRIGGER_CACHE_EVAL_CTX_MACROS))) - return FAIL; - - zbx_eval_get_constant(&cache->eval_ctx, index, out); - - return SUCCEED; -} - -/****************************************************************************** - * * - * Purpose: get the Nth function item from trigger expression * - * * - * Parameters: trigger - [IN] the trigger * - * index - [IN] the function index * - * itemid - [IN] the function itemid * - * * - * Comments: SUCCEED - the itemid was extracted successfully * - * FAIL - otherwise * - * * - ******************************************************************************/ -int zbx_db_trigger_get_itemid(const ZBX_DB_TRIGGER *trigger, int index, zbx_uint64_t *itemid) -{ - int i, ret = FAIL; - zbx_trigger_cache_t *cache; - - if (NULL == (cache = db_trigger_get_cache(trigger, ZBX_TRIGGER_CACHE_EVAL_CTX))) - return FAIL; - - for (i = 0; i < cache->eval_ctx.stack.values_num; i++) - { - zbx_eval_token_t *token = &cache->eval_ctx.stack.values[i]; - zbx_uint64_t functionid; - DC_FUNCTION function; - int errcode; - - if (ZBX_EVAL_TOKEN_FUNCTIONID != token->type || (int)token->opt + 1 != index) - continue; - - switch (token->value.type) - { - case ZBX_VARIANT_UI64: - functionid = token->value.data.ui64; - break; - case ZBX_VARIANT_NONE: - if (SUCCEED != zbx_is_uint64_n(cache->eval_ctx.expression + token->loc.l + 1, - token->loc.r - token->loc.l - 1, &functionid)) - { - return FAIL; - } - zbx_variant_set_ui64(&token->value, functionid); - break; - default: - return FAIL; - } - - DCconfig_get_functions_by_functionids(&function, &functionid, &errcode, 1); - - if (SUCCEED == errcode) - { - *itemid = function.itemid; - ret = SUCCEED; - } - - DCconfig_clean_functions(&function, &errcode, 1); - break; - } - - return ret; -} - -/****************************************************************************** - * * - * Purpose: get unique itemids of trigger functions in the order they are * - * written in expression * - * * - * Parameters: trigger - [IN] the trigger * - * itemids - [IN] the function itemids * - * * - ******************************************************************************/ -void zbx_db_trigger_get_itemids(const ZBX_DB_TRIGGER *trigger, zbx_vector_uint64_t *itemids) -{ - zbx_vector_uint64_t functionids, functionids_ordered; - zbx_trigger_cache_t *cache; - - if (NULL == (cache = db_trigger_get_cache(trigger, ZBX_TRIGGER_CACHE_EVAL_CTX))) - return; - - zbx_vector_uint64_create(&functionids); - zbx_vector_uint64_create(&functionids_ordered); - - zbx_eval_get_functionids_ordered(&cache->eval_ctx, &functionids_ordered); - - if (0 != functionids_ordered.values_num) - { - DC_FUNCTION *functions; - int i, *errcodes, index; - - zbx_vector_uint64_append_array(&functionids, functionids_ordered.values, - functionids_ordered.values_num); - - zbx_vector_uint64_sort(&functionids, ZBX_DEFAULT_UINT64_COMPARE_FUNC); - zbx_vector_uint64_uniq(&functionids, ZBX_DEFAULT_UINT64_COMPARE_FUNC); - - functions = (DC_FUNCTION *)zbx_malloc(NULL, sizeof(DC_FUNCTION) * functionids.values_num); - errcodes = (int *)zbx_malloc(NULL, sizeof(int) * functionids.values_num); - - DCconfig_get_functions_by_functionids(functions, functionids.values, errcodes, - functionids.values_num); - - for (i = 0; i < functionids_ordered.values_num; i++) - { - if (-1 == (index = zbx_vector_uint64_bsearch(&functionids, functionids_ordered.values[i], - ZBX_DEFAULT_UINT64_COMPARE_FUNC))) - { - THIS_SHOULD_NEVER_HAPPEN; - continue; - } - - if (SUCCEED != errcodes[index]) - continue; - - if (FAIL == zbx_vector_uint64_search(itemids, functions[index].itemid, - ZBX_DEFAULT_UINT64_COMPARE_FUNC)) - { - zbx_vector_uint64_append(itemids, functions[index].itemid); - } - } - - DCconfig_clean_functions(functions, errcodes, functionids.values_num); - zbx_free(functions); - zbx_free(errcodes); - } - - zbx_vector_uint64_destroy(&functionids_ordered); - zbx_vector_uint64_destroy(&functionids); -} - -/****************************************************************************** - * * - * Purpose: get hostids from trigger expression and recovery expression * - * * - * Parameters: trigger - [IN] the trigger * - * hostids - [OUT] the extracted hostids * - * * - * Return value: SUCCEED - the hostids vector was returned (but can be empty * - * FAIL - otherwise * - * * - * Comments: This function will cache parsed expressions in the trigger. * - * * - ******************************************************************************/ -int zbx_db_trigger_get_all_hostids(const ZBX_DB_TRIGGER *trigger, const zbx_vector_uint64_t **hostids) -{ - zbx_trigger_cache_t *cache; - - if (NULL == (cache = db_trigger_get_cache(trigger, ZBX_TRIGGER_CACHE_HOSTIDS))) - return FAIL; - - *hostids = &cache->hostids; - return SUCCEED; -} - -/****************************************************************************** - * * - * Purpose: frees resources allocated to store trigger data * - * * - * Parameters: trigger - * - * * - ******************************************************************************/ -void zbx_db_trigger_clean(ZBX_DB_TRIGGER *trigger) -{ - zbx_free(trigger->description); - zbx_free(trigger->expression); - zbx_free(trigger->recovery_expression); - zbx_free(trigger->comments); - zbx_free(trigger->url); - zbx_free(trigger->url_name); - zbx_free(trigger->opdata); - zbx_free(trigger->event_name); - - if (NULL != trigger->cache) - trigger_cache_free((zbx_trigger_cache_t *)trigger->cache); -} - -/****************************************************************************** - * * - * Purpose: get original trigger expression/recovery expression with expanded * - * functions * - * * - * Parameters: ctx - [IN] the parsed expression * - * expression - [OUT] the trigger expression * - * * - ******************************************************************************/ -static void db_trigger_get_expression(const zbx_eval_context_t *ctx, char **expression) -{ - int i; - zbx_eval_context_t local_ctx; - - zbx_eval_copy(&local_ctx, ctx, ctx->expression); - local_ctx.rules |= ZBX_EVAL_COMPOSE_MASK_ERROR; - - for (i = 0; i < local_ctx.stack.values_num; i++) - { - zbx_eval_token_t *token = &local_ctx.stack.values[i]; - zbx_uint64_t functionid; - DC_FUNCTION function; - DC_ITEM item; - int err_func, err_item; - - if (ZBX_EVAL_TOKEN_FUNCTIONID != token->type) - { - /* reset cached token values to get the original expression */ - zbx_variant_clear(&token->value); - continue; - } - - switch (token->value.type) - { - case ZBX_VARIANT_UI64: - functionid = token->value.data.ui64; - break; - case ZBX_VARIANT_NONE: - if (SUCCEED != zbx_is_uint64_n(local_ctx.expression + token->loc.l + 1, - token->loc.r - token->loc.l - 1, &functionid)) - { - continue; - } - break; - default: - continue; - } - - DCconfig_get_functions_by_functionids(&function, &functionid, &err_func, 1); - - if (SUCCEED == err_func) - { - DCconfig_get_items_by_itemids(&item, &function.itemid, &err_item, 1); - - if (SUCCEED == err_item) - { - char *func = NULL; - size_t func_alloc = 0, func_offset = 0; - - zbx_snprintf_alloc(&func, &func_alloc, &func_offset, "%s(/%s/%s", - function.function, item.host.host, item.key_orig); - - if ('\0' != *function.parameter) - zbx_snprintf_alloc(&func, &func_alloc, &func_offset, ",%s", function.parameter); - - zbx_chrcpy_alloc(&func, &func_alloc, &func_offset,')'); - - zbx_variant_clear(&token->value); - zbx_variant_set_str(&token->value, func); - DCconfig_clean_items(&item, &err_item, 1); - } - else - { - zbx_variant_clear(&token->value); - zbx_variant_set_error(&token->value, zbx_dsprintf(NULL, "item id:" ZBX_FS_UI64 - " deleted", function.itemid)); - } - - DCconfig_clean_functions(&function, &err_func, 1); - } - else - { - zbx_variant_clear(&token->value); - zbx_variant_set_error(&token->value, zbx_dsprintf(NULL, "function id:" ZBX_FS_UI64 " deleted", - functionid)); - } - } - - zbx_eval_compose_expression(&local_ctx, expression); - - zbx_eval_clear(&local_ctx); -} - -/****************************************************************************** - * * - * Purpose: get original trigger expression with expanded functions * - * * - * Parameters: trigger - [IN] the trigger * - * expression - [OUT] the trigger expression * - * * - ******************************************************************************/ -void zbx_db_trigger_get_expression(const ZBX_DB_TRIGGER *trigger, char **expression) -{ - zbx_trigger_cache_t *cache; - - if (NULL == (cache = db_trigger_get_cache(trigger, ZBX_TRIGGER_CACHE_EVAL_CTX))) - *expression = zbx_strdup(NULL, trigger->expression); - else - db_trigger_get_expression(&cache->eval_ctx, expression); -} - -/****************************************************************************** - * * - * Purpose: get original trigger recovery expression with expanded functions * - * * - * Parameters: trigger - [IN] the trigger * - * expression - [OUT] the trigger expression * - * * - ******************************************************************************/ -void zbx_db_trigger_get_recovery_expression(const ZBX_DB_TRIGGER *trigger, char **expression) -{ - zbx_trigger_cache_t *cache; - - if (NULL == (cache = db_trigger_get_cache(trigger, ZBX_TRIGGER_CACHE_EVAL_CTX_R))) - *expression = zbx_strdup(NULL, trigger->recovery_expression); - else - db_trigger_get_expression(&cache->eval_ctx_r, expression); -} - -static void evaluate_function_by_id(zbx_uint64_t functionid, char **value, zbx_trigger_func_t eval_func_cb) -{ - DC_ITEM item; - DC_FUNCTION function; - int err_func, err_item; - - DCconfig_get_functions_by_functionids(&function, &functionid, &err_func, 1); - - if (SUCCEED == err_func) - { - DCconfig_get_items_by_itemids(&item, &function.itemid, &err_item, 1); - - if (SUCCEED == err_item) - { - char *error = NULL, *parameter = NULL; - zbx_variant_t var; - zbx_timespec_t ts; - - parameter = zbx_dc_expand_user_macros_in_func_params(function.parameter, item.host.hostid); - zbx_timespec(&ts); - - if (SUCCEED == eval_func_cb(&var, &item, function.function, parameter, &ts, &error) && - ZBX_VARIANT_NONE != var.type) - { - *value = zbx_strdup(NULL, zbx_variant_value_desc(&var)); - zbx_variant_clear(&var); - } - else - zbx_free(error); - - zbx_free(parameter); - DCconfig_clean_items(&item, &err_item, 1); - } - - DCconfig_clean_functions(&function, &err_func, 1); - } - - if (NULL == *value) - *value = zbx_strdup(NULL, "*UNKNOWN*"); -} - -static void db_trigger_explain_expression(const zbx_eval_context_t *ctx, char **expression, - zbx_trigger_func_t eval_func_cb) -{ - int i; - zbx_eval_context_t local_ctx; - - zbx_eval_copy(&local_ctx, ctx, ctx->expression); - local_ctx.rules |= ZBX_EVAL_COMPOSE_MASK_ERROR; - - for (i = 0; i < local_ctx.stack.values_num; i++) - { - zbx_eval_token_t *token = &local_ctx.stack.values[i]; - char *value = NULL; - zbx_uint64_t functionid; - - if (ZBX_EVAL_TOKEN_FUNCTIONID != token->type) - continue; - - switch (token->value.type) - { - case ZBX_VARIANT_UI64: - functionid = token->value.data.ui64; - break; - case ZBX_VARIANT_NONE: - if (SUCCEED != zbx_is_uint64_n(local_ctx.expression + token->loc.l + 1, - token->loc.r - token->loc.l - 1, &functionid)) - { - continue; - } - break; - default: - continue; - } - - zbx_variant_clear(&token->value); - evaluate_function_by_id(functionid, &value, eval_func_cb); - zbx_variant_set_str(&token->value, value); - } - - zbx_eval_compose_expression(&local_ctx, expression); - - zbx_eval_clear(&local_ctx); -} - -static void db_trigger_get_function_value(const zbx_eval_context_t *ctx, int index, char **value_ret, - zbx_trigger_func_t eval_func_cb) -{ - int i; - zbx_eval_context_t local_ctx; - - zbx_eval_copy(&local_ctx, ctx, ctx->expression); - - for (i = 0; i < local_ctx.stack.values_num; i++) - { - zbx_eval_token_t *token = &local_ctx.stack.values[i]; - zbx_uint64_t functionid; - - if (ZBX_EVAL_TOKEN_FUNCTIONID != token->type || (int)token->opt + 1 != index) - continue; - - switch (token->value.type) - { - case ZBX_VARIANT_UI64: - functionid = token->value.data.ui64; - break; - case ZBX_VARIANT_NONE: - if (SUCCEED != zbx_is_uint64_n(local_ctx.expression + token->loc.l + 1, - token->loc.r - token->loc.l - 1, &functionid)) - { - continue; - } - break; - default: - continue; - } - - evaluate_function_by_id(functionid, value_ret, eval_func_cb); - break; - } - - zbx_eval_clear(&local_ctx); - - if (NULL == *value_ret) - *value_ret = zbx_strdup(NULL, "*UNKNOWN*"); -} - -void zbx_db_trigger_explain_expression(const ZBX_DB_TRIGGER *trigger, char **expression, - zbx_trigger_func_t eval_func_cb, int recovery) -{ - zbx_trigger_cache_t *cache; - zbx_trigger_cache_state_t state; - const zbx_eval_context_t *ctx; - - state = (1 == recovery) ? ZBX_TRIGGER_CACHE_EVAL_CTX_R_MACROS : ZBX_TRIGGER_CACHE_EVAL_CTX_MACROS; - - if (NULL == (cache = db_trigger_get_cache(trigger, state))) - { - *expression = zbx_strdup(NULL, "*UNKNOWN*"); - return; - } - - ctx = (1 == recovery) ? &cache->eval_ctx_r : &cache->eval_ctx; - - db_trigger_explain_expression(ctx, expression, eval_func_cb); -} - -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) -{ - zbx_trigger_cache_t *cache; - zbx_trigger_cache_state_t state; - const zbx_eval_context_t *ctx; - - state = (1 == recovery) ? ZBX_TRIGGER_CACHE_EVAL_CTX_R : ZBX_TRIGGER_CACHE_EVAL_CTX; - - if (NULL == (cache = db_trigger_get_cache(trigger, state))) - { - *value = zbx_strdup(NULL, "*UNKNOWN*"); - return; - } - - ctx = (1 == recovery) ? &cache->eval_ctx_r : &cache->eval_ctx; - - db_trigger_get_function_value(ctx, index, value, eval_func_cb); -} diff --git a/src/libs/zbxdbwrap/Makefile.am b/src/libs/zbxdbwrap/Makefile.am index c670b84edb0..0e7b3916836 100644 --- a/src/libs/zbxdbwrap/Makefile.am +++ b/src/libs/zbxdbwrap/Makefile.am @@ -7,6 +7,7 @@ libzbxdbwrap_a_SOURCES = \ event.c \ template_item.c \ template.h \ + trigger.c \ trigger_dep_linking.c \ trigger_dep_linking.h \ trigger_linking.c \ diff --git a/src/libs/zbxdbwrap/host.c b/src/libs/zbxdbwrap/host.c index 92fe7972450..f9236e5ae76 100644 --- a/src/libs/zbxdbwrap/host.c +++ b/src/libs/zbxdbwrap/host.c @@ -21,7 +21,7 @@ #include "zbxdbwrap.h" #include "log.h" -#include "dbcache.h" +#include "zbxcacheconfig.h" #include "zbxserver.h" #include "audit/zbxaudit_host.h" #include "audit/zbxaudit_item.h" diff --git a/src/libs/zbxdbwrap/template_item.c b/src/libs/zbxdbwrap/template_item.c index 9500bb99dbb..37db1c92c0a 100644 --- a/src/libs/zbxdbwrap/template_item.c +++ b/src/libs/zbxdbwrap/template_item.c @@ -20,7 +20,7 @@ #include "zbxdbhigh.h" #include "log.h" -#include "dbcache.h" +#include "zbxcacheconfig.h" #include "audit/zbxaudit.h" #include "audit/zbxaudit_item.h" #include "zbxnum.h" diff --git a/src/libs/zbxdbwrap/trigger.c b/src/libs/zbxdbwrap/trigger.c new file mode 100644 index 00000000000..f0f4b81431c --- /dev/null +++ b/src/libs/zbxdbwrap/trigger.c @@ -0,0 +1,754 @@ +/* +** 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. +**/ + +#include "zbxdbhigh.h" + +#include "log.h" +#include "zbxdbwrap.h" +#include "events.h" +#include "zbxserver.h" +#include "zbxnum.h" + +/* temporary cache of trigger related data */ +typedef struct +{ + zbx_uint32_t init; + zbx_uint32_t done; + zbx_eval_context_t eval_ctx; + zbx_eval_context_t eval_ctx_r; + zbx_vector_uint64_t hostids; +} +zbx_trigger_cache_t; + +/* related trigger data caching states */ +typedef enum +{ + ZBX_TRIGGER_CACHE_EVAL_CTX, + ZBX_TRIGGER_CACHE_EVAL_CTX_R, + ZBX_TRIGGER_CACHE_EVAL_CTX_MACROS, + ZBX_TRIGGER_CACHE_EVAL_CTX_R_MACROS, + ZBX_TRIGGER_CACHE_HOSTIDS, +} +zbx_trigger_cache_state_t; + +static int db_trigger_expand_macros(const ZBX_DB_TRIGGER *trigger, zbx_eval_context_t *ctx); + +/****************************************************************************** + * * + * Purpose: get trigger cache with the requested data cached * + * * + * Parameters: trigger - [IN] the trigger * + * state - [IN] the required cache state * + * * + ******************************************************************************/ +static zbx_trigger_cache_t *db_trigger_get_cache(const ZBX_DB_TRIGGER *trigger, zbx_trigger_cache_state_t state) +{ + zbx_trigger_cache_t *cache; + char *error = NULL; + zbx_uint32_t flag = 1 << state; + zbx_vector_uint64_t functionids; + + if (NULL == trigger->cache) + { + cache = (zbx_trigger_cache_t *)zbx_malloc(NULL, sizeof(zbx_trigger_cache_t)); + cache->init = cache->done = 0; + ((ZBX_DB_TRIGGER *)trigger)->cache = cache; + } + else + cache = (zbx_trigger_cache_t *)trigger->cache; + + if (0 != (cache->init & flag)) + return 0 != (cache->done & flag) ? cache : NULL; + + cache->init |= flag; + + switch (state) + { + case ZBX_TRIGGER_CACHE_EVAL_CTX: + if ('\0' == *trigger->expression) + return NULL; + + if (FAIL == zbx_eval_parse_expression(&cache->eval_ctx, trigger->expression, + ZBX_EVAL_TRIGGER_EXPRESSION, &error)) + { + zbx_free(error); + return NULL; + } + break; + case ZBX_TRIGGER_CACHE_EVAL_CTX_R: + if ('\0' == *trigger->recovery_expression) + return NULL; + + if (FAIL == zbx_eval_parse_expression(&cache->eval_ctx_r, trigger->recovery_expression, + ZBX_EVAL_TRIGGER_EXPRESSION, &error)) + { + zbx_free(error); + return NULL; + } + break; + case ZBX_TRIGGER_CACHE_EVAL_CTX_MACROS: + if (FAIL == db_trigger_expand_macros(trigger, &cache->eval_ctx)) + return NULL; + + break; + case ZBX_TRIGGER_CACHE_EVAL_CTX_R_MACROS: + if (FAIL == db_trigger_expand_macros(trigger, &cache->eval_ctx_r)) + return NULL; + + break; + case ZBX_TRIGGER_CACHE_HOSTIDS: + zbx_vector_uint64_create(&cache->hostids); + zbx_vector_uint64_create(&functionids); + zbx_db_trigger_get_all_functionids(trigger, &functionids); + DCget_hostids_by_functionids(&functionids, &cache->hostids); + zbx_vector_uint64_destroy(&functionids); + break; + default: + return NULL; + } + + cache->done |= flag; + + return cache; +} + +/****************************************************************************** + * * + * Purpose: expand macros in trigger expression/recovery expression * + * * + ******************************************************************************/ +static int db_trigger_expand_macros(const ZBX_DB_TRIGGER *trigger, zbx_eval_context_t *ctx) +{ + int i; + ZBX_DB_EVENT db_event; + zbx_dc_um_handle_t *um_handle; + zbx_trigger_cache_t *cache; + + if (NULL == (cache = db_trigger_get_cache(trigger, ZBX_TRIGGER_CACHE_HOSTIDS))) + return FAIL; + + db_event.value = trigger->value; + db_event.object = EVENT_OBJECT_TRIGGER; + + um_handle = zbx_dc_open_user_macros(); + + (void)zbx_eval_expand_user_macros(ctx, cache->hostids.values, cache->hostids.values_num, + (zbx_macro_expand_func_t)zbx_dc_expand_user_macros, um_handle, NULL); + + zbx_dc_close_user_macros(um_handle); + + for (i = 0; i < ctx->stack.values_num; i++) + { + char *value; + zbx_eval_token_t *token = &ctx->stack.values[i]; + + switch (token->type) + { + case ZBX_EVAL_TOKEN_VAR_STR: + if (ZBX_VARIANT_NONE != token->value.type) + { + zbx_variant_convert(&token->value, ZBX_VARIANT_STR); + value = token->value.data.str; + zbx_variant_set_none(&token->value); + break; + } + value = zbx_substr_unquote(ctx->expression, token->loc.l, token->loc.r); + break; + case ZBX_EVAL_TOKEN_VAR_MACRO: + value = zbx_substr_unquote(ctx->expression, token->loc.l, token->loc.r); + break; + default: + continue; + } + + if (SUCCEED == zbx_substitute_simple_macros(NULL, &db_event, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, &value, MACRO_TYPE_TRIGGER_EXPRESSION, NULL, 0)) + { + zbx_variant_clear(&token->value); + zbx_variant_set_str(&token->value, value); + } + else + zbx_free(value); + } + + return SUCCEED; +} + +/****************************************************************************** + * * + * Purpose: free trigger cache * + * * + * Parameters: cache - [IN] the trigger cache * + * * + ******************************************************************************/ +static void trigger_cache_free(zbx_trigger_cache_t *cache) +{ + if (0 != (cache->done & (1 << ZBX_TRIGGER_CACHE_EVAL_CTX))) + zbx_eval_clear(&cache->eval_ctx); + + if (0 != (cache->done & (1 << ZBX_TRIGGER_CACHE_EVAL_CTX_R))) + zbx_eval_clear(&cache->eval_ctx_r); + + if (0 != (cache->done & (1 << ZBX_TRIGGER_CACHE_HOSTIDS))) + zbx_vector_uint64_destroy(&cache->hostids); + + zbx_free(cache); +} + +/****************************************************************************** + * * + * Purpose: get functionids from trigger expression and recovery expression * + * * + * Parameters: trigger - [IN] the trigger * + * functionids - [OUT] the extracted functionids * + * * + * Comments: This function will cache parsed expressions in the trigger. * + * * + ******************************************************************************/ +void zbx_db_trigger_get_all_functionids(const ZBX_DB_TRIGGER *trigger, zbx_vector_uint64_t *functionids) +{ + zbx_trigger_cache_t *cache; + + if (NULL != (cache = db_trigger_get_cache(trigger, ZBX_TRIGGER_CACHE_EVAL_CTX))) + zbx_eval_get_functionids(&cache->eval_ctx, functionids); + + if (NULL != (cache = db_trigger_get_cache(trigger, ZBX_TRIGGER_CACHE_EVAL_CTX_R))) + zbx_eval_get_functionids(&cache->eval_ctx_r, functionids); + + zbx_vector_uint64_sort(functionids, ZBX_DEFAULT_UINT64_COMPARE_FUNC); + zbx_vector_uint64_uniq(functionids, ZBX_DEFAULT_UINT64_COMPARE_FUNC); +} + +/****************************************************************************** + * * + * Purpose: get functionids from trigger expression * + * * + * Parameters: trigger - [IN] the trigger * + * functionids - [OUT] the extracted functionids * + * * + * Comments: This function will cache parsed expressions in the trigger. * + * * + ******************************************************************************/ +void zbx_db_trigger_get_functionids(const ZBX_DB_TRIGGER *trigger, zbx_vector_uint64_t *functionids) +{ + zbx_trigger_cache_t *cache; + + if (NULL != (cache = db_trigger_get_cache(trigger, ZBX_TRIGGER_CACHE_EVAL_CTX))) + zbx_eval_get_functionids(&cache->eval_ctx, functionids); + + zbx_vector_uint64_sort(functionids, ZBX_DEFAULT_UINT64_COMPARE_FUNC); + zbx_vector_uint64_uniq(functionids, ZBX_DEFAULT_UINT64_COMPARE_FUNC); +} +/****************************************************************************** + * * + * Purpose: get trigger expression constant at the specified location * + * * + * Parameters: trigger - [IN] the trigger * + * index - [IN] the constant index, starting with 1 * + * out - [IN] the constant value, if exists * + * * + * Return value: SUCCEED - the expression was parsed and constant extracted * + * (if the index was valid) * + * FAIL - the expression failed to parse * + * * + * Comments: This function will cache parsed expressions in the trigger. * + * * + ******************************************************************************/ +int zbx_db_trigger_get_constant(const ZBX_DB_TRIGGER *trigger, int index, char **out) +{ + zbx_trigger_cache_t *cache; + + if (NULL == (cache = db_trigger_get_cache(trigger, ZBX_TRIGGER_CACHE_EVAL_CTX_MACROS))) + return FAIL; + + zbx_eval_get_constant(&cache->eval_ctx, index, out); + + return SUCCEED; +} + +/****************************************************************************** + * * + * Purpose: get the Nth function item from trigger expression * + * * + * Parameters: trigger - [IN] the trigger * + * index - [IN] the function index * + * itemid - [IN] the function itemid * + * * + * Comments: SUCCEED - the itemid was extracted successfully * + * FAIL - otherwise * + * * + ******************************************************************************/ +int zbx_db_trigger_get_itemid(const ZBX_DB_TRIGGER *trigger, int index, zbx_uint64_t *itemid) +{ + int i, ret = FAIL; + zbx_trigger_cache_t *cache; + + if (NULL == (cache = db_trigger_get_cache(trigger, ZBX_TRIGGER_CACHE_EVAL_CTX))) + return FAIL; + + for (i = 0; i < cache->eval_ctx.stack.values_num; i++) + { + zbx_eval_token_t *token = &cache->eval_ctx.stack.values[i]; + zbx_uint64_t functionid; + DC_FUNCTION function; + int errcode; + + if (ZBX_EVAL_TOKEN_FUNCTIONID != token->type || (int)token->opt + 1 != index) + continue; + + switch (token->value.type) + { + case ZBX_VARIANT_UI64: + functionid = token->value.data.ui64; + break; + case ZBX_VARIANT_NONE: + if (SUCCEED != zbx_is_uint64_n(cache->eval_ctx.expression + token->loc.l + 1, + token->loc.r - token->loc.l - 1, &functionid)) + { + return FAIL; + } + zbx_variant_set_ui64(&token->value, functionid); + break; + default: + return FAIL; + } + + DCconfig_get_functions_by_functionids(&function, &functionid, &errcode, 1); + + if (SUCCEED == errcode) + { + *itemid = function.itemid; + ret = SUCCEED; + } + + DCconfig_clean_functions(&function, &errcode, 1); + break; + } + + return ret; +} + +/****************************************************************************** + * * + * Purpose: get unique itemids of trigger functions in the order they are * + * written in expression * + * * + * Parameters: trigger - [IN] the trigger * + * itemids - [IN] the function itemids * + * * + ******************************************************************************/ +void zbx_db_trigger_get_itemids(const ZBX_DB_TRIGGER *trigger, zbx_vector_uint64_t *itemids) +{ + zbx_vector_uint64_t functionids, functionids_ordered; + zbx_trigger_cache_t *cache; + + if (NULL == (cache = db_trigger_get_cache(trigger, ZBX_TRIGGER_CACHE_EVAL_CTX))) + return; + + zbx_vector_uint64_create(&functionids); + zbx_vector_uint64_create(&functionids_ordered); + + zbx_eval_get_functionids_ordered(&cache->eval_ctx, &functionids_ordered); + + if (0 != functionids_ordered.values_num) + { + DC_FUNCTION *functions; + int i, *errcodes, index; + + zbx_vector_uint64_append_array(&functionids, functionids_ordered.values, + functionids_ordered.values_num); + + zbx_vector_uint64_sort(&functionids, ZBX_DEFAULT_UINT64_COMPARE_FUNC); + zbx_vector_uint64_uniq(&functionids, ZBX_DEFAULT_UINT64_COMPARE_FUNC); + + functions = (DC_FUNCTION *)zbx_malloc(NULL, sizeof(DC_FUNCTION) * functionids.values_num); + errcodes = (int *)zbx_malloc(NULL, sizeof(int) * functionids.values_num); + + DCconfig_get_functions_by_functionids(functions, functionids.values, errcodes, + functionids.values_num); + + for (i = 0; i < functionids_ordered.values_num; i++) + { + if (-1 == (index = zbx_vector_uint64_bsearch(&functionids, functionids_ordered.values[i], + ZBX_DEFAULT_UINT64_COMPARE_FUNC))) + { + THIS_SHOULD_NEVER_HAPPEN; + continue; + } + + if (SUCCEED != errcodes[index]) + continue; + + if (FAIL == zbx_vector_uint64_search(itemids, functions[index].itemid, + ZBX_DEFAULT_UINT64_COMPARE_FUNC)) + { + zbx_vector_uint64_append(itemids, functions[index].itemid); + } + } + + DCconfig_clean_functions(functions, errcodes, functionids.values_num); + zbx_free(functions); + zbx_free(errcodes); + } + + zbx_vector_uint64_destroy(&functionids_ordered); + zbx_vector_uint64_destroy(&functionids); +} + +/****************************************************************************** + * * + * Purpose: get hostids from trigger expression and recovery expression * + * * + * Parameters: trigger - [IN] the trigger * + * hostids - [OUT] the extracted hostids * + * * + * Return value: SUCCEED - the hostids vector was returned (but can be empty * + * FAIL - otherwise * + * * + * Comments: This function will cache parsed expressions in the trigger. * + * * + ******************************************************************************/ +int zbx_db_trigger_get_all_hostids(const ZBX_DB_TRIGGER *trigger, const zbx_vector_uint64_t **hostids) +{ + zbx_trigger_cache_t *cache; + + if (NULL == (cache = db_trigger_get_cache(trigger, ZBX_TRIGGER_CACHE_HOSTIDS))) + return FAIL; + + *hostids = &cache->hostids; + return SUCCEED; +} + +/****************************************************************************** + * * + * Purpose: frees resources allocated to store trigger data * + * * + * Parameters: trigger - * + * * + ******************************************************************************/ +void zbx_db_trigger_clean(ZBX_DB_TRIGGER *trigger) +{ + zbx_free(trigger->description); + zbx_free(trigger->expression); + zbx_free(trigger->recovery_expression); + zbx_free(trigger->comments); + zbx_free(trigger->url); + zbx_free(trigger->url_name); + zbx_free(trigger->opdata); + zbx_free(trigger->event_name); + + if (NULL != trigger->cache) + trigger_cache_free((zbx_trigger_cache_t *)trigger->cache); +} + +/****************************************************************************** + * * + * Purpose: get original trigger expression/recovery expression with expanded * + * functions * + * * + * Parameters: ctx - [IN] the parsed expression * + * expression - [OUT] the trigger expression * + * * + ******************************************************************************/ +static void db_trigger_get_expression(const zbx_eval_context_t *ctx, char **expression) +{ + int i; + zbx_eval_context_t local_ctx; + + zbx_eval_copy(&local_ctx, ctx, ctx->expression); + local_ctx.rules |= ZBX_EVAL_COMPOSE_MASK_ERROR; + + for (i = 0; i < local_ctx.stack.values_num; i++) + { + zbx_eval_token_t *token = &local_ctx.stack.values[i]; + zbx_uint64_t functionid; + DC_FUNCTION function; + DC_ITEM item; + int err_func, err_item; + + if (ZBX_EVAL_TOKEN_FUNCTIONID != token->type) + { + /* reset cached token values to get the original expression */ + zbx_variant_clear(&token->value); + continue; + } + + switch (token->value.type) + { + case ZBX_VARIANT_UI64: + functionid = token->value.data.ui64; + break; + case ZBX_VARIANT_NONE: + if (SUCCEED != zbx_is_uint64_n(local_ctx.expression + token->loc.l + 1, + token->loc.r - token->loc.l - 1, &functionid)) + { + continue; + } + break; + default: + continue; + } + + DCconfig_get_functions_by_functionids(&function, &functionid, &err_func, 1); + + if (SUCCEED == err_func) + { + DCconfig_get_items_by_itemids(&item, &function.itemid, &err_item, 1); + + if (SUCCEED == err_item) + { + char *func = NULL; + size_t func_alloc = 0, func_offset = 0; + + zbx_snprintf_alloc(&func, &func_alloc, &func_offset, "%s(/%s/%s", + function.function, item.host.host, item.key_orig); + + if ('\0' != *function.parameter) + zbx_snprintf_alloc(&func, &func_alloc, &func_offset, ",%s", function.parameter); + + zbx_chrcpy_alloc(&func, &func_alloc, &func_offset,')'); + + zbx_variant_clear(&token->value); + zbx_variant_set_str(&token->value, func); + DCconfig_clean_items(&item, &err_item, 1); + } + else + { + zbx_variant_clear(&token->value); + zbx_variant_set_error(&token->value, zbx_dsprintf(NULL, "item id:" ZBX_FS_UI64 + " deleted", function.itemid)); + } + + DCconfig_clean_functions(&function, &err_func, 1); + } + else + { + zbx_variant_clear(&token->value); + zbx_variant_set_error(&token->value, zbx_dsprintf(NULL, "function id:" ZBX_FS_UI64 " deleted", + functionid)); + } + } + + zbx_eval_compose_expression(&local_ctx, expression); + + zbx_eval_clear(&local_ctx); +} + +/****************************************************************************** + * * + * Purpose: get original trigger expression with expanded functions * + * * + * Parameters: trigger - [IN] the trigger * + * expression - [OUT] the trigger expression * + * * + ******************************************************************************/ +void zbx_db_trigger_get_expression(const ZBX_DB_TRIGGER *trigger, char **expression) +{ + zbx_trigger_cache_t *cache; + + if (NULL == (cache = db_trigger_get_cache(trigger, ZBX_TRIGGER_CACHE_EVAL_CTX))) + *expression = zbx_strdup(NULL, trigger->expression); + else + db_trigger_get_expression(&cache->eval_ctx, expression); +} + +/****************************************************************************** + * * + * Purpose: get original trigger recovery expression with expanded functions * + * * + * Parameters: trigger - [IN] the trigger * + * expression - [OUT] the trigger expression * + * * + ******************************************************************************/ +void zbx_db_trigger_get_recovery_expression(const ZBX_DB_TRIGGER *trigger, char **expression) +{ + zbx_trigger_cache_t *cache; + + if (NULL == (cache = db_trigger_get_cache(trigger, ZBX_TRIGGER_CACHE_EVAL_CTX_R))) + *expression = zbx_strdup(NULL, trigger->recovery_expression); + else + db_trigger_get_expression(&cache->eval_ctx_r, expression); +} + +static void evaluate_function_by_id(zbx_uint64_t functionid, char **value, zbx_trigger_func_t eval_func_cb) +{ + DC_ITEM item; + DC_FUNCTION function; + int err_func, err_item; + + DCconfig_get_functions_by_functionids(&function, &functionid, &err_func, 1); + + if (SUCCEED == err_func) + { + DCconfig_get_items_by_itemids(&item, &function.itemid, &err_item, 1); + + if (SUCCEED == err_item) + { + char *error = NULL, *parameter = NULL; + zbx_variant_t var; + zbx_timespec_t ts; + + parameter = zbx_dc_expand_user_macros_in_func_params(function.parameter, item.host.hostid); + zbx_timespec(&ts); + + if (SUCCEED == eval_func_cb(&var, &item, function.function, parameter, &ts, &error) && + ZBX_VARIANT_NONE != var.type) + { + *value = zbx_strdup(NULL, zbx_variant_value_desc(&var)); + zbx_variant_clear(&var); + } + else + zbx_free(error); + + zbx_free(parameter); + DCconfig_clean_items(&item, &err_item, 1); + } + + DCconfig_clean_functions(&function, &err_func, 1); + } + + if (NULL == *value) + *value = zbx_strdup(NULL, "*UNKNOWN*"); +} + +static void db_trigger_explain_expression(const zbx_eval_context_t *ctx, char **expression, + zbx_trigger_func_t eval_func_cb) +{ + int i; + zbx_eval_context_t local_ctx; + + zbx_eval_copy(&local_ctx, ctx, ctx->expression); + local_ctx.rules |= ZBX_EVAL_COMPOSE_MASK_ERROR; + + for (i = 0; i < local_ctx.stack.values_num; i++) + { + zbx_eval_token_t *token = &local_ctx.stack.values[i]; + char *value = NULL; + zbx_uint64_t functionid; + + if (ZBX_EVAL_TOKEN_FUNCTIONID != token->type) + continue; + + switch (token->value.type) + { + case ZBX_VARIANT_UI64: + functionid = token->value.data.ui64; + break; + case ZBX_VARIANT_NONE: + if (SUCCEED != zbx_is_uint64_n(local_ctx.expression + token->loc.l + 1, + token->loc.r - token->loc.l - 1, &functionid)) + { + continue; + } + break; + default: + continue; + } + + zbx_variant_clear(&token->value); + evaluate_function_by_id(functionid, &value, eval_func_cb); + zbx_variant_set_str(&token->value, value); + } + + zbx_eval_compose_expression(&local_ctx, expression); + + zbx_eval_clear(&local_ctx); +} + +static void db_trigger_get_function_value(const zbx_eval_context_t *ctx, int index, char **value_ret, + zbx_trigger_func_t eval_func_cb) +{ + int i; + zbx_eval_context_t local_ctx; + + zbx_eval_copy(&local_ctx, ctx, ctx->expression); + + for (i = 0; i < local_ctx.stack.values_num; i++) + { + zbx_eval_token_t *token = &local_ctx.stack.values[i]; + zbx_uint64_t functionid; + + if (ZBX_EVAL_TOKEN_FUNCTIONID != token->type || (int)token->opt + 1 != index) + continue; + + switch (token->value.type) + { + case ZBX_VARIANT_UI64: + functionid = token->value.data.ui64; + break; + case ZBX_VARIANT_NONE: + if (SUCCEED != zbx_is_uint64_n(local_ctx.expression + token->loc.l + 1, + token->loc.r - token->loc.l - 1, &functionid)) + { + continue; + } + break; + default: + continue; + } + + evaluate_function_by_id(functionid, value_ret, eval_func_cb); + break; + } + + zbx_eval_clear(&local_ctx); + + if (NULL == *value_ret) + *value_ret = zbx_strdup(NULL, "*UNKNOWN*"); +} + +void zbx_db_trigger_explain_expression(const ZBX_DB_TRIGGER *trigger, char **expression, + zbx_trigger_func_t eval_func_cb, int recovery) +{ + zbx_trigger_cache_t *cache; + zbx_trigger_cache_state_t state; + const zbx_eval_context_t *ctx; + + state = (1 == recovery) ? ZBX_TRIGGER_CACHE_EVAL_CTX_R_MACROS : ZBX_TRIGGER_CACHE_EVAL_CTX_MACROS; + + if (NULL == (cache = db_trigger_get_cache(trigger, state))) + { + *expression = zbx_strdup(NULL, "*UNKNOWN*"); + return; + } + + ctx = (1 == recovery) ? &cache->eval_ctx_r : &cache->eval_ctx; + + db_trigger_explain_expression(ctx, expression, eval_func_cb); +} + +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) +{ + zbx_trigger_cache_t *cache; + zbx_trigger_cache_state_t state; + const zbx_eval_context_t *ctx; + + state = (1 == recovery) ? ZBX_TRIGGER_CACHE_EVAL_CTX_R : ZBX_TRIGGER_CACHE_EVAL_CTX; + + if (NULL == (cache = db_trigger_get_cache(trigger, state))) + { + *value = zbx_strdup(NULL, "*UNKNOWN*"); + return; + } + + ctx = (1 == recovery) ? &cache->eval_ctx_r : &cache->eval_ctx; + + db_trigger_get_function_value(ctx, index, value, eval_func_cb); +} diff --git a/src/libs/zbxdiag/diag.c b/src/libs/zbxdiag/diag.c index 840d48d7380..f2b07d9aaaa 100644 --- a/src/libs/zbxdiag/diag.c +++ b/src/libs/zbxdiag/diag.c @@ -22,7 +22,7 @@ #include "zbxjson.h" #include "zbxalgo.h" #include "zbxshmem.h" -#include "dbcache.h" +#include "zbxcachehistory.h" #include "preproc.h" #include "log.h" #include "zbxmutexs.h" diff --git a/src/libs/zbxhistory/history_elastic.c b/src/libs/zbxhistory/history_elastic.c index 80e0e0da478..a98840cecc2 100644 --- a/src/libs/zbxhistory/history_elastic.c +++ b/src/libs/zbxhistory/history_elastic.c @@ -22,7 +22,8 @@ #include "log.h" #include "zbxalgo.h" -#include "dbcache.h" +#include "zbxdb.h" +#include "zbxstr.h" #include "zbxnum.h" /* curl_multi_wait() is supported starting with version 7.28.0 (0x071c00) */ diff --git a/src/libs/zbxhistory/history_sql.c b/src/libs/zbxhistory/history_sql.c index b439ae6f334..770262cb9ba 100644 --- a/src/libs/zbxhistory/history_sql.c +++ b/src/libs/zbxhistory/history_sql.c @@ -22,7 +22,6 @@ #include "zbxalgo.h" #include "zbxdbhigh.h" -#include "dbcache.h" #include "zbxnum.h" typedef struct diff --git a/src/libs/zbxserver/Makefile.am b/src/libs/zbxserver/Makefile.am index 2ade3d4dc3f..d06eb248327 100644 --- a/src/libs/zbxserver/Makefile.am +++ b/src/libs/zbxserver/Makefile.am @@ -21,4 +21,4 @@ libzbxserver_a_SOURCES = \ calc_checks_eval.c \ evaluate_simple.c -libzbxserver_a_CFLAGS = -I$(top_srcdir)/src/libs/zbxdbcache $(LIBXML2_CFLAGS) +libzbxserver_a_CFLAGS = $(LIBXML2_CFLAGS) diff --git a/src/libs/zbxserver/calc_checks_eval.c b/src/libs/zbxserver/calc_checks_eval.c index d7c06b854a2..b8c9b62108f 100644 --- a/src/libs/zbxserver/calc_checks_eval.c +++ b/src/libs/zbxserver/calc_checks_eval.c @@ -20,7 +20,7 @@ #include "zbxserver.h" #include "log.h" -#include "valuecache.h" +#include "zbxcachevalue.h" #include "evalfunc.h" #include "zbxeval.h" #include "expression.h" diff --git a/src/libs/zbxserver/evalfunc.c b/src/libs/zbxserver/evalfunc.c index cc2bf8048c7..ce8886000c0 100644 --- a/src/libs/zbxserver/evalfunc.c +++ b/src/libs/zbxserver/evalfunc.c @@ -23,7 +23,7 @@ #include "log.h" #include "zbxregexp.h" -#include "valuecache.h" +#include "zbxcachevalue.h" #include "zbxtrends.h" #include "anomalystl.h" #include "zbxnum.h" diff --git a/src/libs/zbxserver/evalfunc.h b/src/libs/zbxserver/evalfunc.h index d831bbb6be9..241b38ec9c8 100644 --- a/src/libs/zbxserver/evalfunc.h +++ b/src/libs/zbxserver/evalfunc.h @@ -21,7 +21,7 @@ #define ZABBIX_EVALFUNC_H #include "zbxtypes.h" -#include "dbcache.h" +#include "zbxcacheconfig.h" int zbx_evaluatable_for_notsupported(const char *fn); int zbx_evaluate_RATE(zbx_variant_t *value, DC_ITEM *item, const char *parameters, const zbx_timespec_t *ts, diff --git a/src/libs/zbxserver/expression.c b/src/libs/zbxserver/expression.c index 7156646809f..a6cba156ae6 100644 --- a/src/libs/zbxserver/expression.c +++ b/src/libs/zbxserver/expression.c @@ -25,7 +25,8 @@ #include "zbxregexp.h" #include "zbxvariant.h" #include "zbxeval.h" -#include "valuecache.h" +#include "zbxdbwrap.h" +#include "zbxcachevalue.h" #include "macrofunc.h" #include "zbxxml.h" #include "zbxstr.h" diff --git a/src/libs/zbxserver/get_host_from_event.h b/src/libs/zbxserver/get_host_from_event.h index 92833d07320..fe9cfed34e9 100644 --- a/src/libs/zbxserver/get_host_from_event.h +++ b/src/libs/zbxserver/get_host_from_event.h @@ -20,7 +20,7 @@ #ifndef ZABBIX_GET_HOST_FROM_EVENT_H #define ZABBIX_GET_HOST_FROM_EVENT_H -#include "dbcache.h" +#include "zbxcacheconfig.h" int get_host_from_event(const ZBX_DB_EVENT *event, DC_HOST *host, char *error, size_t max_error_len); diff --git a/src/libs/zbxserver/zabbix_stats.c b/src/libs/zbxserver/zabbix_stats.c index 387366cded8..1cea6932209 100644 --- a/src/libs/zbxserver/zabbix_stats.c +++ b/src/libs/zbxserver/zabbix_stats.c @@ -20,7 +20,7 @@ #include "zbxstats.h" #include "zbxcommon.h" -#include "dbcache.h" +#include "zbxcachehistory.h" #include "zbxself.h" #include "../../zabbix_server/vmware/vmware.h" #include "preproc.h" diff --git a/src/zabbix_proxy/Makefile.am b/src/zabbix_proxy/Makefile.am index 6a1657afdd9..d9409a5df7d 100644 --- a/src/zabbix_proxy/Makefile.am +++ b/src/zabbix_proxy/Makefile.am @@ -58,9 +58,10 @@ zabbix_proxy_LDADD = \ $(top_builddir)/src/libs/zbxsysinfo/$(ARCH)/libspechostnamesysinfo.a \ $(top_builddir)/src/libs/zbxsysinfo/alias/libalias.a \ $(top_builddir)/src/libs/zbxlog/libzbxlog.a \ - $(top_builddir)/src/libs/zbxdbcache/libzbxdbcache.a \ $(top_builddir)/src/libs/zbxserver/libzbxserver.a \ - $(top_builddir)/src/libs/zbxdbcache/libzbxdbcache.a \ + $(top_builddir)/src/libs/zbxcacheconfig/libzbxcacheconfig.a \ + $(top_builddir)/src/libs/zbxcachehistory/libzbxcachehistory.a \ + $(top_builddir)/src/libs/zbxcachevalue/libzbxcachevalue.a \ stats/libzbxserver_proxy.a \ $(top_builddir)/src/libs/zbxeval/libzbxeval.a \ $(top_builddir)/src/libs/zbxserialize/libzbxserialize.a \ diff --git a/src/zabbix_proxy/datasender/datasender.c b/src/zabbix_proxy/datasender/datasender.c index d490f62b23a..010cf551306 100644 --- a/src/zabbix_proxy/datasender/datasender.c +++ b/src/zabbix_proxy/datasender/datasender.c @@ -20,10 +20,10 @@ #include "datasender.h" #include "zbxcommshigh.h" -#include "zbxdbhigh.h" #include "log.h" #include "zbxnix.h" #include "zbxdbwrap.h" +#include "zbxcachehistory.h" #include "zbxself.h" #include "zbxtasks.h" #include "zbxcompress.h" diff --git a/src/zabbix_proxy/housekeeper/housekeeper.c b/src/zabbix_proxy/housekeeper/housekeeper.c index 3573d5635f3..09d787abcc2 100644 --- a/src/zabbix_proxy/housekeeper/housekeeper.c +++ b/src/zabbix_proxy/housekeeper/housekeeper.c @@ -22,7 +22,7 @@ #include "log.h" #include "zbxnix.h" #include "zbxself.h" -#include "dbcache.h" +#include "zbxcacheconfig.h" #include "zbxrtc.h" #include "zbxnum.h" #include "zbxtime.h" diff --git a/src/zabbix_proxy/proxy.c b/src/zabbix_proxy/proxy.c index 6ed5f3e92a8..c0674d7c1c0 100644 --- a/src/zabbix_proxy/proxy.c +++ b/src/zabbix_proxy/proxy.c @@ -21,7 +21,7 @@ #include "cfg.h" #include "zbxdbhigh.h" -#include "dbcache.h" +#include "zbxcacheconfig.h" #include "zbxdbupgrade.h" #include "log.h" #include "zbxgetopt.h" diff --git a/src/zabbix_proxy/proxyconfig/proxyconfig.c b/src/zabbix_proxy/proxyconfig/proxyconfig.c index 0f5f4542ff3..0883fdf4611 100644 --- a/src/zabbix_proxy/proxyconfig/proxyconfig.c +++ b/src/zabbix_proxy/proxyconfig/proxyconfig.c @@ -21,7 +21,7 @@ #include "log.h" #include "zbxnix.h" -#include "zbxdbwrap.h" +#include "zbxcachehistory.h" #include "zbxself.h" #include "zbxtime.h" diff --git a/src/zabbix_proxy/taskmanager/taskmanager.c b/src/zabbix_proxy/taskmanager/taskmanager.c index 3d4075af2f0..321469bd948 100644 --- a/src/zabbix_proxy/taskmanager/taskmanager.c +++ b/src/zabbix_proxy/taskmanager/taskmanager.c @@ -30,7 +30,7 @@ #include "zbxdiag.h" #include "zbxrtc.h" #include "zbxdbwrap.h" -#include "dbcache.h" +#include "zbxcacheconfig.h" #include "zbxnum.h" #include "zbxtime.h" #include "zbx_rtc_constants.h" diff --git a/src/zabbix_server/Makefile.am b/src/zabbix_server/Makefile.am index 9ed2104d3a3..ca7a24f4b8b 100644 --- a/src/zabbix_server/Makefile.am +++ b/src/zabbix_server/Makefile.am @@ -48,7 +48,9 @@ libzbxserver_a_SOURCES = \ libzbxserver_a_CFLAGS = \ -DZABBIX_DAEMON \ - -I$(top_srcdir)/src/libs/zbxdbcache \ + -I$(top_srcdir)/src/libs/zbxcacheconfig \ + -I$(top_srcdir)/src/libs/zbxcachehistory \ + -I$(top_srcdir)/src/libs/zbxcachevalue \ $(TLS_CFLAGS) zabbix_server_SOURCES = server.c @@ -93,9 +95,13 @@ zabbix_server_LDADD = \ $(top_builddir)/src/libs/zbxsysinfo/simple/libsimplesysinfo.a \ $(top_builddir)/src/libs/zbxsysinfo/alias/libalias.a \ $(top_builddir)/src/libs/zbxlog/libzbxlog.a \ - $(top_builddir)/src/libs/zbxdbcache/libzbxdbcache.a \ + $(top_builddir)/src/libs/zbxcacheconfig/libzbxcacheconfig.a \ + $(top_builddir)/src/libs/zbxcachehistory/libzbxcachehistory.a \ + $(top_builddir)/src/libs/zbxcachevalue/libzbxcachevalue.a \ $(top_builddir)/src/libs/zbxserver/libzbxserver.a \ - $(top_builddir)/src/libs/zbxdbcache/libzbxdbcache.a \ + $(top_builddir)/src/libs/zbxcacheconfig/libzbxcacheconfig.a \ + $(top_builddir)/src/libs/zbxcachehistory/libzbxcachehistory.a \ + $(top_builddir)/src/libs/zbxcachevalue/libzbxcachevalue.a \ preprocessor/libpreprocessor.a \ $(top_builddir)/src/libs/zbxvariant/libzbxvariant.a \ $(top_builddir)/src/libs/zbxeval/libzbxeval.a \ diff --git a/src/zabbix_server/alerter/alert_syncer.c b/src/zabbix_server/alerter/alert_syncer.c index 13a1baf8bfc..f39a1d22a34 100644 --- a/src/zabbix_server/alerter/alert_syncer.c +++ b/src/zabbix_server/alerter/alert_syncer.c @@ -25,7 +25,7 @@ #include "log.h" #include "alerter_protocol.h" #include "zbxservice.h" -#include "dbcache.h" +#include "zbxcacheconfig.h" #include "zbxnum.h" #include "zbxtime.h" #include "zbxexpr.h" diff --git a/src/zabbix_server/alerter/alerter.c b/src/zabbix_server/alerter/alerter.c index 37723179f6f..2c2308e35fa 100644 --- a/src/zabbix_server/alerter/alerter.c +++ b/src/zabbix_server/alerter/alerter.c @@ -25,7 +25,7 @@ #include "zbxself.h" #include "zbxexec.h" #include "zbxipcservice.h" -#include "dbcache.h" +#include "zbxcacheconfig.h" #include "alerter_protocol.h" #include "zbxembed.h" #include "zbxhash.h" diff --git a/src/zabbix_server/dbconfig/Makefile.am b/src/zabbix_server/dbconfig/Makefile.am index 279f9f08e16..a0c642ab807 100644 --- a/src/zabbix_server/dbconfig/Makefile.am +++ b/src/zabbix_server/dbconfig/Makefile.am @@ -6,4 +6,7 @@ libzbxdbconfig_a_SOURCES = \ dbconfig.c \ dbconfig.h -libzbxdbconfig_a_CFLAGS = -I$(top_srcdir)/src/libs/zbxdbcache +libzbxdbconfig_a_CFLAGS = \ + -I$(top_srcdir)/src/libs/zbxcacheconfig \ + -I$(top_srcdir)/src/libs/zbxcachehistory \ + -I$(top_srcdir)/src/libs/zbxcachevalue diff --git a/src/zabbix_server/dbconfig/dbconfig.c b/src/zabbix_server/dbconfig/dbconfig.c index 4adf29693ec..a973e6323c1 100644 --- a/src/zabbix_server/dbconfig/dbconfig.c +++ b/src/zabbix_server/dbconfig/dbconfig.c @@ -22,11 +22,11 @@ #include "zbxnix.h" #include "zbxself.h" #include "log.h" -#include "dbcache.h" +#include "zbxcachehistory.h" #include "zbxrtc.h" #include "zbxtime.h" #include "zbx_rtc_constants.h" -#include "valuecache.h" +#include "zbxcachevalue.h" extern int CONFIG_CONFSYNCER_FREQUENCY; extern unsigned char program_type; diff --git a/src/zabbix_server/dbsyncer/dbsyncer.c b/src/zabbix_server/dbsyncer/dbsyncer.c index 75853919921..060e9758642 100644 --- a/src/zabbix_server/dbsyncer/dbsyncer.c +++ b/src/zabbix_server/dbsyncer/dbsyncer.c @@ -23,7 +23,7 @@ #include "zbxnix.h" #include "zbxself.h" #include "zbxtime.h" -#include "dbcache.h" +#include "zbxcachehistory.h" #include "zbxexport.h" extern int CONFIG_HISTSYNCER_FREQUENCY; diff --git a/src/zabbix_server/diag/diag_server.c b/src/zabbix_server/diag/diag_server.c index 3864613a711..09f2afa0794 100644 --- a/src/zabbix_server/diag/diag_server.c +++ b/src/zabbix_server/diag/diag_server.c @@ -20,7 +20,7 @@ #include "zbxdiag.h" #include "diag_server.h" -#include "../../libs/zbxdbcache/valuecache.h" +#include "zbxcachevalue.h" #include "zbxlld.h" #include "zbxalert.h" #include "zbxtime.h" diff --git a/src/zabbix_server/events.c b/src/zabbix_server/events.c index 17a20b8fd00..5152d181513 100644 --- a/src/zabbix_server/events.c +++ b/src/zabbix_server/events.c @@ -27,6 +27,7 @@ #include "zbxservice.h" #include "zbxnum.h" #include "zbxexpr.h" +#include "zbxdbwrap.h" /* event recovery data */ typedef struct diff --git a/src/zabbix_server/housekeeper/history_compress.h b/src/zabbix_server/housekeeper/history_compress.h index c7cd4ba14c9..16e6ab9f043 100644 --- a/src/zabbix_server/housekeeper/history_compress.h +++ b/src/zabbix_server/housekeeper/history_compress.h @@ -20,7 +20,7 @@ #ifndef ZABBIX_HISTORY_COMPRESSION_H #define ZABBIX_HISTORY_COMPRESSION_H -#include "dbcache.h" +#include "zbxcacheconfig.h" void hk_history_compression_init(void); void hk_history_compression_update(zbx_config_db_t *cfg); diff --git a/src/zabbix_server/ipmi/checks_ipmi.h b/src/zabbix_server/ipmi/checks_ipmi.h index 54b537b753f..900dbba4a5e 100644 --- a/src/zabbix_server/ipmi/checks_ipmi.h +++ b/src/zabbix_server/ipmi/checks_ipmi.h @@ -24,7 +24,7 @@ #ifdef HAVE_OPENIPMI -#include "dbcache.h" +#include "zbxcacheconfig.h" #include "zbxsysinfo.h" int zbx_init_ipmi_handler(void); diff --git a/src/zabbix_server/ipmi/ipmi.h b/src/zabbix_server/ipmi/ipmi.h index fb476417363..cea3f615000 100644 --- a/src/zabbix_server/ipmi/ipmi.h +++ b/src/zabbix_server/ipmi/ipmi.h @@ -20,7 +20,7 @@ #ifndef ZABBIX_IPMI_H #define ZABBIX_IPMI_H -#include "dbcache.h" +#include "zbxcacheconfig.h" #include "zbxtypes.h" #include "config.h" diff --git a/src/zabbix_server/operations.h b/src/zabbix_server/operations.h index 4476e3609ac..7dfa6eea3f6 100644 --- a/src/zabbix_server/operations.h +++ b/src/zabbix_server/operations.h @@ -20,7 +20,7 @@ #ifndef ZABBIX_OPERATIONS_H #define ZABBIX_OPERATIONS_H -#include "dbcache.h" +#include "zbxcacheconfig.h" extern int CONFIG_TIMEOUT; diff --git a/src/zabbix_server/poller/Makefile.am b/src/zabbix_server/poller/Makefile.am index e8186ee61f6..923c97a735f 100644 --- a/src/zabbix_server/poller/Makefile.am +++ b/src/zabbix_server/poller/Makefile.am @@ -46,10 +46,15 @@ libzbxpoller_proxy_a_SOURCES = \ libzbxpoller_a_CFLAGS = \ -I$(top_srcdir)/src/libs/zbxsysinfo/simple \ - -I$(top_srcdir)/src/libs/zbxdbcache \ + -I$(top_srcdir)/src/libs/zbxcacheconfig \ + -I$(top_srcdir)/src/libs/zbxcachehistory \ + -I$(top_srcdir)/src/libs/zbxcachevalue \ $(SNMP_CFLAGS) \ $(SSH2_CFLAGS) \ $(SSH_CFLAGS) \ $(LIBXML2_CFLAGS) -libzbxpoller_server_a_CFLAGS = -I$(top_srcdir)/src/libs/zbxdbcache +libzbxpoller_server_a_CFLAGS = \ + -I$(top_srcdir)/src/libs/zbxcacheconfig \ + -I$(top_srcdir)/src/libs/zbxcachehistory \ + -I$(top_srcdir)/src/libs/zbxcachevalue diff --git a/src/zabbix_server/poller/checks_agent.h b/src/zabbix_server/poller/checks_agent.h index 66e33925a6b..94ed2e3a625 100644 --- a/src/zabbix_server/poller/checks_agent.h +++ b/src/zabbix_server/poller/checks_agent.h @@ -20,7 +20,7 @@ #ifndef ZABBIX_CHECKS_AGENT_H #define ZABBIX_CHECKS_AGENT_H -#include "dbcache.h" +#include "zbxcacheconfig.h" #include "module.h" extern char *CONFIG_SOURCE_IP; diff --git a/src/zabbix_server/poller/checks_calculated.h b/src/zabbix_server/poller/checks_calculated.h index 328e0d45994..75fc58d4ca7 100644 --- a/src/zabbix_server/poller/checks_calculated.h +++ b/src/zabbix_server/poller/checks_calculated.h @@ -20,7 +20,7 @@ #ifndef ZABBIX_CHECKS_CALCULATED_H #define ZABBIX_CHECKS_CALCULATED_H -#include "dbcache.h" +#include "zbxcachehistory.h" #include "module.h" int get_value_calculated(DC_ITEM *dc_item, AGENT_RESULT *result); diff --git a/src/zabbix_server/poller/checks_db.h b/src/zabbix_server/poller/checks_db.h index e37716a3383..72d73600016 100644 --- a/src/zabbix_server/poller/checks_db.h +++ b/src/zabbix_server/poller/checks_db.h @@ -20,7 +20,7 @@ #ifndef ZABBIX_CHECKS_DB_H #define ZABBIX_CHECKS_DB_H -#include "dbcache.h" +#include "zbxcacheconfig.h" #ifdef HAVE_UNIXODBC int get_value_db(const DC_ITEM *item, AGENT_RESULT *result); diff --git a/src/zabbix_server/poller/checks_external.h b/src/zabbix_server/poller/checks_external.h index 7e6f2327ba1..e6b775b7fe4 100644 --- a/src/zabbix_server/poller/checks_external.h +++ b/src/zabbix_server/poller/checks_external.h @@ -20,7 +20,7 @@ #ifndef ZABBIX_CHECKS_EXTERNAL_H #define ZABBIX_CHECKS_EXTERNAL_H -#include "dbcache.h" +#include "zbxcacheconfig.h" #include "module.h" int get_value_external(const DC_ITEM *item, AGENT_RESULT *result); diff --git a/src/zabbix_server/poller/checks_http.c b/src/zabbix_server/poller/checks_http.c index 6aabf6410f7..32a886c0fdd 100644 --- a/src/zabbix_server/poller/checks_http.c +++ b/src/zabbix_server/poller/checks_http.c @@ -21,7 +21,7 @@ #include "zbxhttp.h" #include "zbxjson.h" #include "log.h" -#include "dbcache.h" +#include "zbxcacheconfig.h" #ifdef HAVE_LIBCURL diff --git a/src/zabbix_server/poller/checks_http.h b/src/zabbix_server/poller/checks_http.h index 3e5d392cd23..1cdf3e7a10a 100644 --- a/src/zabbix_server/poller/checks_http.h +++ b/src/zabbix_server/poller/checks_http.h @@ -24,7 +24,7 @@ #include "module.h" #ifdef HAVE_LIBCURL -#include "dbcache.h" +#include "zbxcacheconfig.h" int get_value_http(const DC_ITEM *item, AGENT_RESULT *result); #endif diff --git a/src/zabbix_server/poller/checks_internal.h b/src/zabbix_server/poller/checks_internal.h index b381f8c4ee3..b1172bdf494 100644 --- a/src/zabbix_server/poller/checks_internal.h +++ b/src/zabbix_server/poller/checks_internal.h @@ -20,7 +20,7 @@ #ifndef ZABBIX_CHECKS_INTERNAL_H #define ZABBIX_CHECKS_INTERNAL_H -#include "dbcache.h" +#include "zbxcachehistory.h" #include "zbxcomms.h" extern int CONFIG_SERVER_STARTUP_TIME; diff --git a/src/zabbix_server/poller/checks_internal_proxy.c b/src/zabbix_server/poller/checks_internal_proxy.c index 6915d35d68d..8bb45b829f0 100644 --- a/src/zabbix_server/poller/checks_internal_proxy.c +++ b/src/zabbix_server/poller/checks_internal_proxy.c @@ -18,7 +18,7 @@ **/ #include "zbxcommon.h" -#include "dbcache.h" +#include "zbxcachehistory.h" #include "checks_internal.h" /****************************************************************************** diff --git a/src/zabbix_server/poller/checks_internal_server.c b/src/zabbix_server/poller/checks_internal_server.c index 7dd548db690..f20e45fce08 100644 --- a/src/zabbix_server/poller/checks_internal_server.c +++ b/src/zabbix_server/poller/checks_internal_server.c @@ -18,9 +18,9 @@ **/ #include "zbxcommon.h" -#include "valuecache.h" +#include "zbxcachevalue.h" #include "zbxlld.h" -#include "dbcache.h" +#include "zbxcacheconfig.h" #include "zbxha.h" #include "zbxjson.h" #include "zbxtime.h" diff --git a/src/zabbix_server/poller/checks_java.h b/src/zabbix_server/poller/checks_java.h index 2365e82d129..43f61cd0cfe 100644 --- a/src/zabbix_server/poller/checks_java.h +++ b/src/zabbix_server/poller/checks_java.h @@ -20,7 +20,7 @@ #ifndef ZABBIX_CHECKS_JAVA_H #define ZABBIX_CHECKS_JAVA_H -#include "dbcache.h" +#include "zbxcacheconfig.h" #define ZBX_JAVA_GATEWAY_REQUEST_INTERNAL 0 #define ZBX_JAVA_GATEWAY_REQUEST_JMX 1 diff --git a/src/zabbix_server/poller/checks_script.h b/src/zabbix_server/poller/checks_script.h index 988fdeaa447..4d23e46fac3 100644 --- a/src/zabbix_server/poller/checks_script.h +++ b/src/zabbix_server/poller/checks_script.h @@ -21,7 +21,7 @@ #define ZABBIX_CHECKS_SCRIPT_H #include "module.h" -#include "dbcache.h" +#include "zbxcacheconfig.h" void scriptitem_es_engine_init(void); void scriptitem_es_engine_destroy(void); diff --git a/src/zabbix_server/poller/checks_simple.h b/src/zabbix_server/poller/checks_simple.h index d2d56eb3756..0eae4ac1a01 100644 --- a/src/zabbix_server/poller/checks_simple.h +++ b/src/zabbix_server/poller/checks_simple.h @@ -20,7 +20,7 @@ #ifndef ZABBIX_CHECKS_SIMPLE_H #define ZABBIX_CHECKS_SIMPLE_H -#include "dbcache.h" +#include "zbxcacheconfig.h" #include "module.h" #include "zbxalgo.h" diff --git a/src/zabbix_server/poller/checks_simple_vmware.h b/src/zabbix_server/poller/checks_simple_vmware.h index 4923196f3b5..ce78bd45e2a 100644 --- a/src/zabbix_server/poller/checks_simple_vmware.h +++ b/src/zabbix_server/poller/checks_simple_vmware.h @@ -25,7 +25,7 @@ #if defined(HAVE_LIBXML2) && defined(HAVE_LIBCURL) #include "module.h" #include "zbxalgo.h" -#include "dbcache.h" +#include "zbxcacheconfig.h" int check_vcenter_cluster_alarms_get(AGENT_REQUEST *request, const char *username, const char *password, AGENT_RESULT *result); diff --git a/src/zabbix_server/poller/checks_snmp.h b/src/zabbix_server/poller/checks_snmp.h index 5f8e4432f91..5e1c5ed5085 100644 --- a/src/zabbix_server/poller/checks_snmp.h +++ b/src/zabbix_server/poller/checks_snmp.h @@ -22,7 +22,7 @@ #include "config.h" #include "module.h" -#include "dbcache.h" +#include "zbxcacheconfig.h" extern char *CONFIG_SOURCE_IP; extern int CONFIG_TIMEOUT; diff --git a/src/zabbix_server/poller/checks_ssh.h b/src/zabbix_server/poller/checks_ssh.h index 529fa517e0a..5554b2ea330 100644 --- a/src/zabbix_server/poller/checks_ssh.h +++ b/src/zabbix_server/poller/checks_ssh.h @@ -24,7 +24,7 @@ #include "config.h" #if defined(HAVE_SSH2) || defined(HAVE_SSH) -#include "dbcache.h" +#include "zbxcacheconfig.h" int get_value_ssh(DC_ITEM *item, AGENT_RESULT *result); #endif /* defined(HAVE_SSH2) || defined(HAVE_SSH)*/ diff --git a/src/zabbix_server/poller/checks_telnet.h b/src/zabbix_server/poller/checks_telnet.h index 9c5b56a32da..265687bb391 100644 --- a/src/zabbix_server/poller/checks_telnet.h +++ b/src/zabbix_server/poller/checks_telnet.h @@ -21,7 +21,7 @@ #define ZABBIX_CHECKS_TELNET_H #include "module.h" -#include "dbcache.h" +#include "zbxcacheconfig.h" int get_value_telnet(DC_ITEM *item, AGENT_RESULT *result); diff --git a/src/zabbix_server/poller/poller.h b/src/zabbix_server/poller/poller.h index 3d71f519bc9..f971d22d027 100644 --- a/src/zabbix_server/poller/poller.h +++ b/src/zabbix_server/poller/poller.h @@ -21,7 +21,7 @@ #define ZABBIX_POLLER_H #include "zbxthreads.h" -#include "dbcache.h" +#include "zbxcacheconfig.h" #include "zbxcomms.h" typedef struct diff --git a/src/zabbix_server/poller/ssh_run.h b/src/zabbix_server/poller/ssh_run.h index 2fa4b5f9fe9..7013f0845ce 100644 --- a/src/zabbix_server/poller/ssh_run.h +++ b/src/zabbix_server/poller/ssh_run.h @@ -24,7 +24,7 @@ #include "module.h" #if defined(HAVE_SSH2) || defined(HAVE_SSH) -#include "dbcache.h" +#include "zbxcacheconfig.h" int ssh_run(DC_ITEM *item, AGENT_RESULT *result, const char *encoding); #endif /* defined(HAVE_SSH2) || defined(HAVE_SSH)*/ diff --git a/src/zabbix_server/poller/telnet_run.h b/src/zabbix_server/poller/telnet_run.h index 149e16f325c..5cb4601402a 100644 --- a/src/zabbix_server/poller/telnet_run.h +++ b/src/zabbix_server/poller/telnet_run.h @@ -20,7 +20,7 @@ #ifndef ZABBIX_TELNET_RUN_H #define ZABBIX_TELNET_RUN_H -#include "dbcache.h" +#include "zbxcacheconfig.h" int telnet_run(DC_ITEM *item, AGENT_RESULT *result, const char *encoding); diff --git a/src/zabbix_server/postinit.c b/src/zabbix_server/postinit.c index 09a0ef0012d..ed563a777d6 100644 --- a/src/zabbix_server/postinit.c +++ b/src/zabbix_server/postinit.c @@ -24,7 +24,8 @@ #include "zbxtasks.h" #include "log.h" #include "zbxnum.h" -#include "valuecache.h" +#include "zbxcachevalue.h" +#include "zbxdbwrap.h" #define ZBX_HIST_MACRO_NONE (-1) #define ZBX_HIST_MACRO_ITEM_VALUE 0 diff --git a/src/zabbix_server/preprocessor/item_preproc.h b/src/zabbix_server/preprocessor/item_preproc.h index 31dfbd7d138..5db45d64dde 100644 --- a/src/zabbix_server/preprocessor/item_preproc.h +++ b/src/zabbix_server/preprocessor/item_preproc.h @@ -20,7 +20,7 @@ #ifndef ZABBIX_ITEM_PREPROC_H #define ZABBIX_ITEM_PREPROC_H -#include "dbcache.h" +#include "zbxcacheconfig.h" #include "preproc.h" #define ZBX_PREPROC_MAX_PACKET_SIZE (ZBX_MEBIBYTE * 128) diff --git a/src/zabbix_server/proxyconfigread/proxyconfig_read.h b/src/zabbix_server/proxyconfigread/proxyconfig_read.h index e77b7de6980..a76aa8b61cd 100644 --- a/src/zabbix_server/proxyconfigread/proxyconfig_read.h +++ b/src/zabbix_server/proxyconfigread/proxyconfig_read.h @@ -20,7 +20,7 @@ #ifndef ZABBIX_PROXYCONFIG_READ_H #define ZABBIX_PROXYCONFIG_READ_H -#include "dbcache.h" +#include "zbxcacheconfig.h" typedef enum { ZBX_PROXYCONFIG_STATUS_EMPTY, diff --git a/src/zabbix_server/scripts/scripts.h b/src/zabbix_server/scripts/scripts.h index 344fb37335d..f94c7d4ace5 100644 --- a/src/zabbix_server/scripts/scripts.h +++ b/src/zabbix_server/scripts/scripts.h @@ -20,7 +20,7 @@ #ifndef ZABBIX_SCRIPTS_H #define ZABBIX_SCRIPTS_H -#include "dbcache.h" +#include "zbxcacheconfig.h" void zbx_script_init(zbx_script_t *script); void zbx_script_clean(zbx_script_t *script); diff --git a/src/zabbix_server/server.c b/src/zabbix_server/server.c index 4f9227114ee..5cd62e96067 100644 --- a/src/zabbix_server/server.c +++ b/src/zabbix_server/server.c @@ -62,7 +62,7 @@ #include "reporter/report_manager.h" #include "reporter/report_writer.h" #include "events.h" -#include "../libs/zbxdbcache/valuecache.h" +#include "zbxcachevalue.h" #include "setproctitle.h" #include "zbxhistory.h" #include "postinit.h" diff --git a/src/zabbix_server/stats/Makefile.am b/src/zabbix_server/stats/Makefile.am index 3f7c866691b..e82bf28ea87 100644 --- a/src/zabbix_server/stats/Makefile.am +++ b/src/zabbix_server/stats/Makefile.am @@ -6,4 +6,7 @@ libzbxserver_server_a_SOURCES = \ zabbix_stats.h \ zabbix_stats_server.c -libzbxserver_server_a_CFLAGS = -I$(top_srcdir)/src/libs/zbxdbcache +libzbxserver_server_a_CFLAGS = \ + -I$(top_srcdir)/src/libs/zbxcacheconfig \ + -I$(top_srcdir)/src/libs/zbxcachehistory \ + -I$(top_srcdir)/src/libs/zbxcachevalue diff --git a/src/zabbix_server/stats/zabbix_stats_server.c b/src/zabbix_server/stats/zabbix_stats_server.c index 566c6405279..39c9a7b6a9b 100644 --- a/src/zabbix_server/stats/zabbix_stats_server.c +++ b/src/zabbix_server/stats/zabbix_stats_server.c @@ -20,8 +20,8 @@ #include "zabbix_stats.h" #include "zbxcommon.h" -#include "dbcache.h" -#include "valuecache.h" +#include "zbxcacheconfig.h" +#include "zbxcachevalue.h" #include "zbxlld.h" #include "log.h" #include "zbxtrends.h" diff --git a/src/zabbix_server/taskmanager/taskmanager.c b/src/zabbix_server/taskmanager/taskmanager.c index 2f3653afbb3..4ef312d24e8 100644 --- a/src/zabbix_server/taskmanager/taskmanager.c +++ b/src/zabbix_server/taskmanager/taskmanager.c @@ -23,7 +23,7 @@ #include "zbxnix.h" #include "zbxself.h" #include "log.h" -#include "dbcache.h" +#include "zbxcacheconfig.h" #include "zbxtasks.h" #include "../events.h" #include "../actions.h" @@ -34,7 +34,6 @@ #include "zbxrtc.h" #include "audit/zbxaudit.h" #include "audit/zbxaudit_proxy.h" -#include "dbcache.h" #include "zbxnum.h" #include "zbxtime.h" #include "zbxversion.h" diff --git a/src/zabbix_server/timer/timer.c b/src/zabbix_server/timer/timer.c index 56e8feee12b..2392a926785 100644 --- a/src/zabbix_server/timer/timer.c +++ b/src/zabbix_server/timer/timer.c @@ -20,7 +20,7 @@ #include "timer.h" #include "log.h" -#include "dbcache.h" +#include "zbxcacheconfig.h" #include "zbxnix.h" #include "zbxself.h" #include "zbxnum.h" diff --git a/src/zabbix_server/trapper/proxydata.c b/src/zabbix_server/trapper/proxydata.c index f1a02741668..2fe95123d93 100644 --- a/src/zabbix_server/trapper/proxydata.c +++ b/src/zabbix_server/trapper/proxydata.c @@ -18,9 +18,9 @@ **/ #include "proxydata.h" -#include "zbxdbwrap.h" -#include "zbxdbhigh.h" +#include "zbxdbwrap.h" +#include "zbxcachehistory.h" #include "log.h" #include "zbxtasks.h" #include "zbxmutexs.h" diff --git a/src/zabbix_server/trapper/proxydata.h b/src/zabbix_server/trapper/proxydata.h index b7ee7f6b3ad..460a2db25d4 100644 --- a/src/zabbix_server/trapper/proxydata.h +++ b/src/zabbix_server/trapper/proxydata.h @@ -21,7 +21,7 @@ #define ZABBIX_PROXYDATA_H #include "zbxjson.h" -#include "dbcache.h" +#include "zbxcachehistory.h" extern int CONFIG_TIMEOUT; extern int CONFIG_TRAPPER_TIMEOUT; diff --git a/src/zabbix_server/trapper/trapper.c b/src/zabbix_server/trapper/trapper.c index fe3eb584aaa..df1ee54ff09 100644 --- a/src/zabbix_server/trapper/trapper.c +++ b/src/zabbix_server/trapper/trapper.c @@ -75,6 +75,13 @@ typedef struct } zbx_entry_attribute_t; +typedef enum +{ + ZBX_COUNTER_TYPE_UI64, + ZBX_COUNTER_TYPE_DBL +} +zbx_counter_type_t; + typedef struct { zbx_entry_info_t *info; diff --git a/src/zabbix_server/trapper/trapper_expressions_evaluate.c b/src/zabbix_server/trapper/trapper_expressions_evaluate.c index 5c484e33389..54c5a0a82cb 100644 --- a/src/zabbix_server/trapper/trapper_expressions_evaluate.c +++ b/src/zabbix_server/trapper/trapper_expressions_evaluate.c @@ -21,7 +21,7 @@ #include "zbxalgo.h" #include "zbxnum.h" -#include "dbcache.h" +#include "zbxcacheconfig.h" #include "trapper_auth.h" #include "zbxcommshigh.h" diff --git a/tests/libs/zbxalgo/Makefile.am b/tests/libs/zbxalgo/Makefile.am index 36a097d3a29..9f0e344cb6c 100644 --- a/tests/libs/zbxalgo/Makefile.am +++ b/tests/libs/zbxalgo/Makefile.am @@ -36,7 +36,9 @@ COMMON_LIB_FILES = \ $(top_srcdir)/src/libs/zbxsysinfo/libzbxserversysinfo.a \ $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo.a \ $(top_srcdir)/src/libs/zbxsysinfo/simple/libsimplesysinfo.a \ - $(top_srcdir)/src/libs/zbxdbcache/libzbxdbcache.a \ + $(top_srcdir)/src/libs/zbxcacheconfig/libzbxcacheconfig.a \ + $(top_srcdir)/src/libs/zbxcachehistory/libzbxcachehistory.a \ + $(top_srcdir)/src/libs/zbxcachevalue/libzbxcachevalue.a \ $(top_srcdir)/src/libs/zbxshmem/libzbxshmem.a \ $(top_srcdir)/src/libs/zbxregexp/libzbxregexp.a \ $(top_srcdir)/src/libs/zbxself/libzbxself.a \ diff --git a/tests/libs/zbxcommon/Makefile.am b/tests/libs/zbxcommon/Makefile.am index f04f6402e18..eedff6448a9 100644 --- a/tests/libs/zbxcommon/Makefile.am +++ b/tests/libs/zbxcommon/Makefile.am @@ -65,7 +65,9 @@ COMMON_LIB_FILES = \ $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo_http.a \ $(top_srcdir)/src/libs/zbxsysinfo/simple/libsimplesysinfo.a \ $(top_srcdir)/src/libs/zbxsysinfo/alias/libalias.a \ - $(top_srcdir)/src/libs/zbxdbcache/libzbxdbcache.a \ + $(top_srcdir)/src/libs/zbxcacheconfig/libzbxcacheconfig.a \ + $(top_srcdir)/src/libs/zbxcachehistory/libzbxcachehistory.a \ + $(top_srcdir)/src/libs/zbxcachevalue/libzbxcachevalue.a \ $(top_srcdir)/src/libs/zbxshmem/libzbxshmem.a \ $(top_srcdir)/src/libs/zbxself/libzbxself.a \ $(top_srcdir)/src/libs/zbxmedia/libzbxmedia.a \ diff --git a/tests/libs/zbxconf/Makefile.am b/tests/libs/zbxconf/Makefile.am index 15ae5520e3e..b7fbab632a8 100644 --- a/tests/libs/zbxconf/Makefile.am +++ b/tests/libs/zbxconf/Makefile.am @@ -29,7 +29,9 @@ parse_cfg_file_LDADD = \ $(top_srcdir)/src/libs/zbxsysinfo/libzbxserversysinfo.a \ $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo.a \ $(top_srcdir)/src/libs/zbxsysinfo/simple/libsimplesysinfo.a \ - $(top_srcdir)/src/libs/zbxdbcache/libzbxdbcache.a \ + $(top_srcdir)/src/libs/zbxcacheconfig/libzbxcacheconfig.a \ + $(top_srcdir)/src/libs/zbxcachehistory/libzbxcachehistory.a \ + $(top_srcdir)/src/libs/zbxcachevalue/libzbxcachevalue.a \ $(top_srcdir)/src/libs/zbxhistory/libzbxhistory.a \ $(top_srcdir)/src/libs/zbxshmem/libzbxshmem.a \ $(top_srcdir)/src/libs/zbxregexp/libzbxregexp.a \ diff --git a/tests/libs/zbxdbcache/Makefile.am b/tests/libs/zbxdbcache/Makefile.am index 1a9dba5bf9f..2aab76024ec 100644 --- a/tests/libs/zbxdbcache/Makefile.am +++ b/tests/libs/zbxdbcache/Makefile.am @@ -49,7 +49,9 @@ VALUECACHE_LIBS = \ $(top_srcdir)/tests/libzbxmockdata.a CACHE_LIBS = \ - $(top_srcdir)/src/libs/zbxdbcache/libzbxdbcache.a \ + $(top_srcdir)/src/libs/zbxcacheconfig/libzbxcacheconfig.a \ + $(top_srcdir)/src/libs/zbxcachehistory/libzbxcachehistory.a \ + $(top_srcdir)/src/libs/zbxcachevalue/libzbxcachevalue.a \ $(top_srcdir)/src/libs/zbxavailability/libzbxavailability.a \ $(top_srcdir)/src/zabbix_server/availability/libavailability.a \ $(top_srcdir)/src/libs/zbxipcservice/libzbxipcservice.a \ @@ -105,7 +107,9 @@ CACHE_LIBS = \ $(top_srcdir)/src/libs/zbxnix/libzbxnix.a \ $(top_srcdir)/src/libs/zbxstr/libzbxstr.a \ $(top_srcdir)/src/libs/zbxnum/libzbxnum.a \ - $(top_srcdir)/src/libs/zbxdbcache/libzbxdbcache.a \ + $(top_srcdir)/src/libs/zbxcacheconfig/libzbxcacheconfig.a \ + $(top_srcdir)/src/libs/zbxcachehistory/libzbxcachehistory.a \ + $(top_srcdir)/src/libs/zbxcachevalue/libzbxcachevalue.a \ $(top_srcdir)/src/libs/zbxcommon/libzbxcommon.a \ $(top_srcdir)/tests/libzbxmocktest.a \ $(top_srcdir)/tests/libzbxmockdata.a @@ -130,7 +134,7 @@ COMMON_WRAP_FUNCS = \ zbx_vc_get_values_SOURCES = \ zbx_vc_common.c \ zbx_vc_get_values.c \ - @top_srcdir@/src/libs/zbxdbcache/valuecache.c \ + @top_srcdir@/src/libs/zbxcachevalue/valuecache.c \ @top_srcdir@/src/libs/zbxhistory/history.c \ ../../zbxmocktest.h @@ -139,14 +143,16 @@ zbx_vc_get_values_LDFLAGS = @SERVER_LDFLAGS@ $(COMMON_WRAP_FUNCS) zbx_vc_get_values_CFLAGS = \ -I@top_srcdir@/src/libs/zbxalgo \ - -I@top_srcdir@/src/libs/zbxdbcache \ + -I@top_srcdir@/src/libs/zbxcacheconfig \ + -I@top_srcdir@/src/libs/zbxcachehistory \ + -I@top_srcdir@/src/libs/zbxcachevalue \ -I@top_srcdir@/src/libs/zbxhistory \ -I@top_srcdir@/tests zbx_vc_add_values_SOURCES = \ zbx_vc_common.c \ zbx_vc_add_values.c \ - @top_srcdir@/src/libs/zbxdbcache/valuecache.c \ + @top_srcdir@/src/libs/zbxcachevalue/valuecache.c \ @top_srcdir@/src/libs/zbxhistory/history.c \ ../../zbxmocktest.h @@ -155,14 +161,16 @@ zbx_vc_add_values_LDFLAGS = @SERVER_LDFLAGS@ $(COMMON_WRAP_FUNCS) zbx_vc_add_values_CFLAGS = \ -I@top_srcdir@/src/libs/zbxalgo \ - -I@top_srcdir@/src/libs/zbxdbcache \ + -I@top_srcdir@/src/libs/zbxcacheconfig \ + -I@top_srcdir@/src/libs/zbxcachehistory \ + -I@top_srcdir@/src/libs/zbxcachevalue \ -I@top_srcdir@/src/libs/zbxhistory \ -I@top_srcdir@/tests zbx_vc_get_value_SOURCES = \ zbx_vc_common.c \ zbx_vc_get_value.c \ - @top_srcdir@/src/libs/zbxdbcache/valuecache.c \ + @top_srcdir@/src/libs/zbxcachevalue/valuecache.c \ @top_srcdir@/src/libs/zbxhistory/history.c \ ../../zbxmocktest.h @@ -171,16 +179,22 @@ zbx_vc_get_value_LDFLAGS = @SERVER_LDFLAGS@ $(COMMON_WRAP_FUNCS) zbx_vc_get_value_CFLAGS = \ -I@top_srcdir@/src/libs/zbxalgo \ - -I@top_srcdir@/src/libs/zbxdbcache \ + -I@top_srcdir@/src/libs/zbxcacheconfig \ + -I@top_srcdir@/src/libs/zbxcachehistory \ + -I@top_srcdir@/src/libs/zbxcachevalue \ -I@top_srcdir@/src/libs/zbxhistory \ -I@top_srcdir@/tests dc_maintenance_match_tags_CFLAGS = \ - -I@top_srcdir@/src/libs/zbxdbcache \ + -I@top_srcdir@/src/libs/zbxcacheconfig \ + -I@top_srcdir@/src/libs/zbxcachehistory \ + -I@top_srcdir@/src/libs/zbxcachevalue \ -I@top_srcdir@/tests dc_check_maintenance_period_CFLAGS = \ - -I@top_srcdir@/src/libs/zbxdbcache \ + -I@top_srcdir@/src/libs/zbxcacheconfig \ + -I@top_srcdir@/src/libs/zbxcachehistory \ + -I@top_srcdir@/src/libs/zbxcachevalue \ -I@top_srcdir@/tests dc_maintenance_match_tags_SOURCES = dc_maintenance_match_tags.c @@ -199,12 +213,16 @@ is_item_processed_by_server_CFLAGS = -I@top_srcdir@/tests dc_item_poller_type_update_SOURCES = dc_item_poller_type_update.c dc_item_poller_type_update_LDADD = $(CACHE_LIBS) @SERVER_LIBS@ dc_item_poller_type_update_LDFLAGS = @SERVER_LDFLAGS@ -dc_item_poller_type_update_CFLAGS = -I@top_srcdir@/tests -I@top_srcdir@/src/libs/zbxdbcache +dc_item_poller_type_update_CFLAGS = -I@top_srcdir@/tests -I@top_srcdir@/src/libs/zbxcacheconfig \ + -I@top_srcdir@/src/libs/zbxcachehistory -I@top_srcdir@/src/libs/zbxcachevalue dc_expand_user_macros_in_func_params_CFLAGS = \ -I@top_srcdir@/tests \ -I@top_srcdir@/tests/mocks/configcache \ - -I@top_srcdir@/src/libs/zbxdbcache + -I@top_srcdir@/src/libs/zbxcacheconfig \ + -I@top_srcdir@/src/libs/zbxcachehistory \ + -I@top_srcdir@/src/libs/zbxcachevalue + dc_expand_user_macros_in_func_params_SOURCES = \ dc_expand_user_macros_in_func_params.c dc_expand_user_macros_in_func_params_LDADD = \ diff --git a/tests/libs/zbxdbcache/dc_check_maintenance_period.c b/tests/libs/zbxdbcache/dc_check_maintenance_period.c index d4259968b70..deee63ddc97 100644 --- a/tests/libs/zbxdbcache/dc_check_maintenance_period.c +++ b/tests/libs/zbxdbcache/dc_check_maintenance_period.c @@ -25,7 +25,7 @@ #include "zbxcommon.h" #include "zbxmutexs.h" #include "zbxalgo.h" -#include "dbcache.h" +#include "zbxcacheconfig.h" #include "log.h" #include "dbconfig.h" diff --git a/tests/libs/zbxdbcache/dc_expand_user_macros_in_func_params.c b/tests/libs/zbxdbcache/dc_expand_user_macros_in_func_params.c index ae751ad0d46..82985689eb6 100644 --- a/tests/libs/zbxdbcache/dc_expand_user_macros_in_func_params.c +++ b/tests/libs/zbxdbcache/dc_expand_user_macros_in_func_params.c @@ -25,7 +25,7 @@ #include "zbxserver.h" #include "zbxcommon.h" #include "zbxalgo.h" -#include "dbcache.h" +#include "zbxcacheconfig.h" #include "zbxmutexs.h" #include "dbconfig.h" diff --git a/tests/libs/zbxdbcache/dc_function_calculate_nextcheck.c b/tests/libs/zbxdbcache/dc_function_calculate_nextcheck.c index fd59577f016..e8b6a1bb388 100644 --- a/tests/libs/zbxdbcache/dc_function_calculate_nextcheck.c +++ b/tests/libs/zbxdbcache/dc_function_calculate_nextcheck.c @@ -26,7 +26,7 @@ #include "zbxtrends.h" #include "log.h" #include "zbxdbhigh.h" -#include "dbcache.h" +#include "zbxcacheconfig.h" int zbx_dc_function_calculate_nextcheck(const zbx_trigger_timer_t *timer, time_t from, zbx_uint64_t seed); diff --git a/tests/libs/zbxdbcache/dc_item_poller_type_update.c b/tests/libs/zbxdbcache/dc_item_poller_type_update.c index b6bc9869c70..0f9bec82c95 100644 --- a/tests/libs/zbxdbcache/dc_item_poller_type_update.c +++ b/tests/libs/zbxdbcache/dc_item_poller_type_update.c @@ -32,7 +32,7 @@ #include "zbxcommon.h" #include "zbxmutexs.h" -#include "dbcache.h" +#include "zbxcacheconfig.h" #include "dbconfig.h" #include "dc_item_poller_type_update_test.h" diff --git a/tests/libs/zbxdbcache/dc_maintenance_match_tags.c b/tests/libs/zbxdbcache/dc_maintenance_match_tags.c index 12815c5e6ca..9bdf9c17b19 100644 --- a/tests/libs/zbxdbcache/dc_maintenance_match_tags.c +++ b/tests/libs/zbxdbcache/dc_maintenance_match_tags.c @@ -25,7 +25,7 @@ #include "zbxcommon.h" #include "zbxmutexs.h" #include "zbxalgo.h" -#include "dbcache.h" +#include "zbxcacheconfig.h" #include "dbconfig.h" #include "dbconfig_maintenance_test.h" diff --git a/tests/libs/zbxdbcache/is_item_processed_by_server.c b/tests/libs/zbxdbcache/is_item_processed_by_server.c index 63d912aa57b..e3da647a454 100644 --- a/tests/libs/zbxdbcache/is_item_processed_by_server.c +++ b/tests/libs/zbxdbcache/is_item_processed_by_server.c @@ -23,7 +23,7 @@ #include "zbxmockutil.h" #include "zbxcommon.h" -#include "dbcache.h" +#include "zbxcacheconfig.h" void zbx_mock_test_entry(void **state) { diff --git a/tests/libs/zbxdbcache/um_cache_mock.c b/tests/libs/zbxdbcache/um_cache_mock.c index 6a06a30c852..a1337a3dbeb 100644 --- a/tests/libs/zbxdbcache/um_cache_mock.c +++ b/tests/libs/zbxdbcache/um_cache_mock.c @@ -24,8 +24,9 @@ #include "zbxnum.h" #include "zbxalgo.h" -#include "zbxdbcache/user_macro.h" +#include "zbxcacheconfig/user_macro.h" #include "um_cache_mock.h" +#include "zbxshmem.h" ZBX_PTR_VECTOR_IMPL(um_mock_macro, zbx_um_mock_macro_t *) diff --git a/tests/libs/zbxdbcache/um_cache_mock.h b/tests/libs/zbxdbcache/um_cache_mock.h index 588a84361aa..8ce1c585804 100644 --- a/tests/libs/zbxdbcache/um_cache_mock.h +++ b/tests/libs/zbxdbcache/um_cache_mock.h @@ -20,8 +20,8 @@ #ifndef ZABBIX_UM_CACHE_MOCK_H #define ZABBIX_UM_CACHE_MOCK_H -#include "zbxdbcache/dbconfig.h" -#include "zbxdbcache/dbsync.h" +#include "zbxcacheconfig/dbconfig.h" +#include "zbxcacheconfig/dbsync.h" typedef struct { diff --git a/tests/libs/zbxdbcache/um_cache_resolve.c b/tests/libs/zbxdbcache/um_cache_resolve.c index 5119f718c81..17b5697c2ba 100644 --- a/tests/libs/zbxdbcache/um_cache_resolve.c +++ b/tests/libs/zbxdbcache/um_cache_resolve.c @@ -23,7 +23,7 @@ #include "zbxmockutil.h" #include "zbxnum.h" -#include "zbxdbcache/user_macro.h" +#include "zbxcacheconfig/user_macro.h" #include "um_cache_mock.h" static void mock_get_hostids(zbx_vector_uint64_t *hostids, zbx_mock_handle_t handle) diff --git a/tests/libs/zbxdbcache/um_cache_resolve_cont.c b/tests/libs/zbxdbcache/um_cache_resolve_cont.c index fbf9c8152dc..bccc3ad6421 100644 --- a/tests/libs/zbxdbcache/um_cache_resolve_cont.c +++ b/tests/libs/zbxdbcache/um_cache_resolve_cont.c @@ -24,7 +24,7 @@ #include "zbxcommon.h" #include "zbxjson.h" -#include "zbxdbcache/user_macro.h" +#include "zbxcacheconfig/user_macro.h" #include "zbxalgo.h" #include "um_cache_mock.h" diff --git a/tests/libs/zbxdbcache/um_cache_sync.c b/tests/libs/zbxdbcache/um_cache_sync.c index 54bdec14753..9e6120e4eb8 100644 --- a/tests/libs/zbxdbcache/um_cache_sync.c +++ b/tests/libs/zbxdbcache/um_cache_sync.c @@ -23,7 +23,7 @@ #include "zbxmockutil.h" #include "zbxcommon.h" -#include "zbxdbcache/user_macro.h" +#include "zbxcacheconfig/user_macro.h" #include "zbxalgo.h" #include "um_cache_mock.h" diff --git a/tests/libs/zbxdbcache/zbx_vc_add_values.c b/tests/libs/zbxdbcache/zbx_vc_add_values.c index 574efdf2b7f..c4b489e97fe 100644 --- a/tests/libs/zbxdbcache/zbx_vc_add_values.c +++ b/tests/libs/zbxdbcache/zbx_vc_add_values.c @@ -23,7 +23,7 @@ #include "zbxmockutil.h" #include "zbxcommon.h" -#include "valuecache.h" +#include "zbxcachevalue.h" #include "valuecache_test.h" #include "mocks/valuecache/valuecache_mock.h" diff --git a/tests/libs/zbxdbcache/zbx_vc_common.c b/tests/libs/zbxdbcache/zbx_vc_common.c index 1dcdc946f48..807f90f243f 100644 --- a/tests/libs/zbxdbcache/zbx_vc_common.c +++ b/tests/libs/zbxdbcache/zbx_vc_common.c @@ -25,7 +25,7 @@ #include "zbxnum.h" #include "zbxmutexs.h" -#include "valuecache.h" +#include "zbxcachevalue.h" #include "valuecache_test.h" #include "mocks/valuecache/valuecache_mock.h" diff --git a/tests/libs/zbxdbcache/zbx_vc_get_value.c b/tests/libs/zbxdbcache/zbx_vc_get_value.c index fbdd784f588..2bc786c104f 100644 --- a/tests/libs/zbxdbcache/zbx_vc_get_value.c +++ b/tests/libs/zbxdbcache/zbx_vc_get_value.c @@ -23,7 +23,7 @@ #include "zbxmockutil.h" #include "zbxnum.h" -#include "valuecache.h" +#include "zbxcachevalue.h" #include "valuecache_test.h" #include "mocks/valuecache/valuecache_mock.h" diff --git a/tests/libs/zbxdbcache/zbx_vc_get_values.c b/tests/libs/zbxdbcache/zbx_vc_get_values.c index 039616df687..b4187f54ccf 100644 --- a/tests/libs/zbxdbcache/zbx_vc_get_values.c +++ b/tests/libs/zbxdbcache/zbx_vc_get_values.c @@ -23,7 +23,7 @@ #include "zbxmockutil.h" #include "zbxcommon.h" -#include "valuecache.h" +#include "zbxcachevalue.h" #include "valuecache_test.h" #include "mocks/valuecache/valuecache_mock.h" diff --git a/tests/libs/zbxdbhigh/Makefile.am b/tests/libs/zbxdbhigh/Makefile.am index 74118eb8698..31ea5ed6962 100644 --- a/tests/libs/zbxdbhigh/Makefile.am +++ b/tests/libs/zbxdbhigh/Makefile.am @@ -91,7 +91,9 @@ SERVER_COMMON_LIB = \ $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo_http.a \ $(top_srcdir)/src/libs/zbxsysinfo/simple/libsimplesysinfo.a \ $(top_srcdir)/src/libs/zbxsysinfo/alias/libalias.a \ - $(top_srcdir)/src/libs/zbxdbcache/libzbxdbcache.a \ + $(top_srcdir)/src/libs/zbxcacheconfig/libzbxcacheconfig.a \ + $(top_srcdir)/src/libs/zbxcachehistory/libzbxcachehistory.a \ + $(top_srcdir)/src/libs/zbxcachevalue/libzbxcachevalue.a \ $(top_srcdir)/src/libs/zbxeval/libzbxeval.a \ $(top_srcdir)/src/libs/zbxserialize/libzbxserialize.a \ $(top_srcdir)/src/zabbix_server/availability/libavailability.a \ @@ -135,7 +137,9 @@ if PROXY PROXY_COMMON_LIB = \ $(top_srcdir)/src/libs/zbxdbhigh/libzbxdbhigh.a \ - $(top_srcdir)/src/libs/zbxdbcache/libzbxdbcache.a \ + $(top_srcdir)/src/libs/zbxcacheconfig/libzbxcacheconfig.a \ + $(top_srcdir)/src/libs/zbxcachehistory/libzbxcachehistory.a \ + $(top_srcdir)/src/libs/zbxcachevalue/libzbxcachevalue.a \ $(top_srcdir)/src/libs/zbxeval/libzbxeval.a \ $(top_srcdir)/src/libs/zbxserialize/libzbxserialize.a \ $(top_srcdir)/src/libs/zbxdbwrap/libzbxdbwrap.a \ diff --git a/tests/libs/zbxeval/Makefile.am b/tests/libs/zbxeval/Makefile.am index 0cb02059978..022b60697c2 100755 --- a/tests/libs/zbxeval/Makefile.am +++ b/tests/libs/zbxeval/Makefile.am @@ -37,7 +37,9 @@ COMMON_LIB_FILES = \ $(top_srcdir)/src/zabbix_server/odbc/libzbxodbc.a \ $(top_srcdir)/src/zabbix_server/scripts/libzbxscripts.a \ $(top_srcdir)/src/zabbix_server/preprocessor/libpreprocessor.a \ - $(top_srcdir)/src/libs/zbxdbcache/libzbxdbcache.a \ + $(top_srcdir)/src/libs/zbxcacheconfig/libzbxcacheconfig.a \ + $(top_srcdir)/src/libs/zbxcachehistory/libzbxcachehistory.a \ + $(top_srcdir)/src/libs/zbxcachevalue/libzbxcachevalue.a \ $(top_srcdir)/src/libs/zbxeval/libzbxeval.a \ $(top_srcdir)/src/libs/zbxserialize/libzbxserialize.a \ $(top_srcdir)/src/libs/zbxtrends/libzbxtrends.a \ diff --git a/tests/libs/zbxserver/Makefile.am b/tests/libs/zbxserver/Makefile.am index 2092a19d445..d6f5c02a45c 100755 --- a/tests/libs/zbxserver/Makefile.am +++ b/tests/libs/zbxserver/Makefile.am @@ -35,7 +35,9 @@ COMMON_LIB_FILES = \ $(top_srcdir)/src/zabbix_server/scripts/libzbxscripts.a \ $(top_srcdir)/src/zabbix_server/preprocessor/libpreprocessor.a \ $(top_srcdir)/src/libs/zbxserver/libzbxserver.a \ - $(top_srcdir)/src/libs/zbxdbcache/libzbxdbcache.a \ + $(top_srcdir)/src/libs/zbxcacheconfig/libzbxcacheconfig.a \ + $(top_srcdir)/src/libs/zbxcachehistory/libzbxcachehistory.a \ + $(top_srcdir)/src/libs/zbxcachevalue/libzbxcachevalue.a \ $(top_srcdir)/src/libs/zbxtrends/libzbxtrends.a \ $(top_srcdir)/src/libs/zbxsysinfo/libzbxserversysinfo.a \ $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo.a \ @@ -47,7 +49,9 @@ COMMON_LIB_FILES = \ $(top_srcdir)/src/libs/zbxmedia/libzbxmedia.a \ $(top_srcdir)/src/libs/zbxdbwrap/libzbxdbwrap.a \ $(top_srcdir)/src/libs/zbxserver/libzbxserver.a \ - $(top_srcdir)/src/libs/zbxdbcache/libzbxdbcache.a \ + $(top_srcdir)/src/libs/zbxcacheconfig/libzbxcacheconfig.a \ + $(top_srcdir)/src/libs/zbxcachehistory/libzbxcachehistory.a \ + $(top_srcdir)/src/libs/zbxcachevalue/libzbxcachevalue.a \ $(top_srcdir)/src/libs/zbxtrends/libzbxtrends.a \ $(top_srcdir)/src/libs/zbxsysinfo/libzbxserversysinfo.a \ $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo.a \ @@ -144,7 +148,9 @@ macro_fmttime_LDADD += @SERVER_LIBS@ macro_fmttime_LDFLAGS = @SERVER_LDFLAGS@ $(VALUECACHE_WRAP_FUNCS) macro_fmttime_CFLAGS = $(COMMON_COMPILER_FLAGS) \ - -I@top_srcdir@/src/libs/zbxdbcache \ + -I@top_srcdir@/src/libs/zbxcacheconfig \ + -I@top_srcdir@/src/libs/zbxcachehistory \ + -I@top_srcdir@/src/libs/zbxcachevalue \ -I@top_srcdir@/src/libs/zbxserver evaluate_function_SOURCES = \ @@ -217,22 +223,30 @@ VALUECACHE_WRAP_FUNCS = \ evaluate_function_CFLAGS = $(COMMON_COMPILER_FLAGS) \ -I@top_srcdir@/src/libs/zbxalgo \ - -I@top_srcdir@/src/libs/zbxdbcache \ + -I@top_srcdir@/src/libs/zbxcacheconfig \ + -I@top_srcdir@/src/libs/zbxcachehistory \ + -I@top_srcdir@/src/libs/zbxcachevalue \ -I@top_srcdir@/src/libs/zbxhistory evaluate_stl_CFLAGS = $(COMMON_COMPILER_FLAGS) \ -I@top_srcdir@/src/libs/zbxalgo \ - -I@top_srcdir@/src/libs/zbxdbcache \ + -I@top_srcdir@/src/libs/zbxcacheconfig \ + -I@top_srcdir@/src/libs/zbxcachehistory \ + -I@top_srcdir@/src/libs/zbxcachevalue \ -I@top_srcdir@/src/libs/zbxhistory evaluate_percentage_deviations_in_remainder_CFLAGS = $(COMMON_COMPILER_FLAGS) \ -I@top_srcdir@/src/libs/zbxalgo \ - -I@top_srcdir@/src/libs/zbxdbcache \ + -I@top_srcdir@/src/libs/zbxcacheconfig \ + -I@top_srcdir@/src/libs/zbxcachehistory \ + -I@top_srcdir@/src/libs/zbxcachevalue \ -I@top_srcdir@/src/libs/zbxhistory valuemaps_CFLAGS = $(COMMON_COMPILER_FLAGS) \ -I@top_srcdir@/src/libs/zbxalgo \ - -I@top_srcdir@/src/libs/zbxdbcache \ + -I@top_srcdir@/src/libs/zbxcacheconfig \ + -I@top_srcdir@/src/libs/zbxcachehistory \ + -I@top_srcdir@/src/libs/zbxcachevalue \ -I@top_srcdir@/src/libs/zbxhistory endif diff --git a/tests/libs/zbxserver/evaluate_function.c b/tests/libs/zbxserver/evaluate_function.c index 21c0a655c8c..2a03937e3cb 100644 --- a/tests/libs/zbxserver/evaluate_function.c +++ b/tests/libs/zbxserver/evaluate_function.c @@ -22,7 +22,7 @@ #include "zbxmockassert.h" #include "zbxmockutil.h" -#include "valuecache.h" +#include "zbxcachevalue.h" #include "zbxserver.h" #include "../../src/libs/zbxserver/evalfunc.h" diff --git a/tests/libs/zbxserver/evaluate_percentage_deviations_in_remainder.c b/tests/libs/zbxserver/evaluate_percentage_deviations_in_remainder.c index 8c962bc1964..a2e80741332 100644 --- a/tests/libs/zbxserver/evaluate_percentage_deviations_in_remainder.c +++ b/tests/libs/zbxserver/evaluate_percentage_deviations_in_remainder.c @@ -22,7 +22,7 @@ #include "zbxmockassert.h" #include "zbxmockutil.h" -#include "valuecache.h" +#include "zbxcachevalue.h" #include "zbxserver.h" #include "zbxtrends.h" #include "zbxparam.h" diff --git a/tests/libs/zbxserver/evaluate_stl.c b/tests/libs/zbxserver/evaluate_stl.c index 8ed26dc5805..d90d97545e5 100644 --- a/tests/libs/zbxserver/evaluate_stl.c +++ b/tests/libs/zbxserver/evaluate_stl.c @@ -23,7 +23,7 @@ #include "zbxmockutil.h" #include "zbxserver.h" -#include "valuecache.h" +#include "zbxcachevalue.h" #include "mocks/valuecache/valuecache_mock.h" #include "../../../src/libs/zbxserver/anomalystl.h" diff --git a/tests/libs/zbxserver/macro_fmttime.c b/tests/libs/zbxserver/macro_fmttime.c index 651472c6b77..b92ca15064b 100644 --- a/tests/libs/zbxserver/macro_fmttime.c +++ b/tests/libs/zbxserver/macro_fmttime.c @@ -26,7 +26,7 @@ #include "macrofunc.h" #include "log.h" #include "zbxexpr.h" -#include "valuecache.h" +#include "zbxcachevalue.h" #include "mocks/valuecache/valuecache_mock.h" int __wrap_substitute_simple_macros(zbx_uint64_t *actionid, const ZBX_DB_EVENT *event, const ZBX_DB_EVENT *r_event, diff --git a/tests/libs/zbxsysinfo/Makefile.am b/tests/libs/zbxsysinfo/Makefile.am index 670be6d8d55..7532ec716cb 100644 --- a/tests/libs/zbxsysinfo/Makefile.am +++ b/tests/libs/zbxsysinfo/Makefile.am @@ -60,7 +60,9 @@ parse_item_key_LDADD = \ $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo_http.a \ $(top_srcdir)/src/libs/zbxsysinfo/simple/libsimplesysinfo.a \ $(top_srcdir)/src/libs/zbxsysinfo/alias/libalias.a \ - $(top_srcdir)/src/libs/zbxdbcache/libzbxdbcache.a \ + $(top_srcdir)/src/libs/zbxcacheconfig/libzbxcacheconfig.a \ + $(top_srcdir)/src/libs/zbxcachehistory/libzbxcachehistory.a \ + $(top_srcdir)/src/libs/zbxcachevalue/libzbxcachevalue.a \ $(top_srcdir)/src/libs/zbxhistory/libzbxhistory.a \ $(top_srcdir)/src/libs/zbxshmem/libzbxshmem.a \ $(top_srcdir)/src/libs/zbxregexp/libzbxregexp.a \ diff --git a/tests/mocks/configcache/Makefile.am b/tests/mocks/configcache/Makefile.am index 4bab279c50a..d4592463723 100644 --- a/tests/mocks/configcache/Makefile.am +++ b/tests/mocks/configcache/Makefile.am @@ -8,5 +8,7 @@ libconfigcachemock_a_SOURCES = \ libconfigcachemock_a_CFLAGS = \ -I@top_srcdir@/src/libs/zbxalgo \ - -I@top_srcdir@/src/libs/zbxdbcache \ + -I@top_srcdir@/src/libs/zbxcacheconfig \ + -I@top_srcdir@/src/libs/zbxcachehistory \ + -I@top_srcdir@/src/libs/zbxcachevalue \ -I@top_srcdir@/tests diff --git a/tests/mocks/configcache/hosts.c b/tests/mocks/configcache/hosts.c index f44ba9f9dcb..7ff4a59dc1c 100644 --- a/tests/mocks/configcache/hosts.c +++ b/tests/mocks/configcache/hosts.c @@ -25,7 +25,7 @@ #include "zbxserver.h" #include "zbxcommon.h" #include "zbxalgo.h" -#include "dbcache.h" +#include "zbxcacheconfig.h" #include "zbxmutexs.h" #include "dbconfig.h" #include "configcache.h" diff --git a/tests/mocks/valuecache/Makefile.am b/tests/mocks/valuecache/Makefile.am index ea19d055a20..9a25aca30d0 100644 --- a/tests/mocks/valuecache/Makefile.am +++ b/tests/mocks/valuecache/Makefile.am @@ -6,6 +6,8 @@ libvaluecachemock_a_SOURCES = \ libvaluecachemock_a_CFLAGS = \ -I@top_srcdir@/src/libs/zbxalgo \ - -I@top_srcdir@/src/libs/zbxdbcache \ + -I@top_srcdir@/src/libs/zbxcacheconfig \ + -I@top_srcdir@/src/libs/zbxcachehistory \ + -I@top_srcdir@/src/libs/zbxcachevalue \ -I@top_srcdir@/src/libs/zbxhistory \ -I@top_srcdir@/tests diff --git a/tests/mocks/valuecache/valuecache_mock.c b/tests/mocks/valuecache/valuecache_mock.c index c3b3ad4f5d7..cc0abaf11c1 100644 --- a/tests/mocks/valuecache/valuecache_mock.c +++ b/tests/mocks/valuecache/valuecache_mock.c @@ -22,7 +22,7 @@ #include "zbxmockutil.h" #include "valuecache_mock.h" -#include "valuecache.h" +#include "zbxcachevalue.h" #include "zbxnum.h" #include "log.h" #include "zbxmutexs.h" @@ -30,7 +30,7 @@ #include "zbxalgo.h" #include "zbxhistory.h" #include "history.h" -#include "dbcache.h" +#include "zbxcacheconfig.h" #include <setjmp.h> #include <cmocka.h> diff --git a/tests/zabbix_server/pinger/Makefile.am b/tests/zabbix_server/pinger/Makefile.am index 3f8f1945438..6e93b9aa8bd 100644 --- a/tests/zabbix_server/pinger/Makefile.am +++ b/tests/zabbix_server/pinger/Makefile.am @@ -9,7 +9,9 @@ COMMON_SRC_FILES = \ PINGER_LIBS = \ $(top_srcdir)/tests/libzbxmocktest.a \ $(top_srcdir)/tests/libzbxmockdata.a \ - $(top_srcdir)/src/libs/zbxdbcache/libzbxdbcache.a \ + $(top_srcdir)/src/libs/zbxcacheconfig/libzbxcacheconfig.a \ + $(top_srcdir)/src/libs/zbxcachehistory/libzbxcachehistory.a \ + $(top_srcdir)/src/libs/zbxcachevalue/libzbxcachevalue.a \ $(top_srcdir)/src/libs/zbxdbhigh/libzbxdbhigh.a \ $(top_srcdir)/src/libs/zbxdb/libzbxdb.a \ $(top_srcdir)/src/libs/zbxmodules/libzbxmodules.a \ @@ -53,7 +55,9 @@ PINGER_LIBS = \ $(top_srcdir)/src/libs/zbxhashicorp/libzbxhashicorp.a \ $(top_srcdir)/src/libs/zbxserialize/libzbxserialize.a \ $(top_srcdir)/src/libs/zbxdbwrap/libzbxdbwrap.a \ - $(top_srcdir)/src/libs/zbxdbcache/libzbxdbcache.a \ + $(top_srcdir)/src/libs/zbxcacheconfig/libzbxcacheconfig.a \ + $(top_srcdir)/src/libs/zbxcachehistory/libzbxcachehistory.a \ + $(top_srcdir)/src/libs/zbxcachevalue/libzbxcachevalue.a \ $(top_srcdir)/src/libs/zbxdbhigh/libzbxdbhigh.a \ $(top_srcdir)/src/libs/zbxservice/libzbxservice.a \ $(top_srcdir)/src/libs/zbxaudit/libzbxaudit.a \ diff --git a/tests/zabbix_server/poller/test_get_value_ssh.h b/tests/zabbix_server/poller/test_get_value_ssh.h index 45f1f9d2d25..a9f9f44a36a 100644 --- a/tests/zabbix_server/poller/test_get_value_ssh.h +++ b/tests/zabbix_server/poller/test_get_value_ssh.h @@ -20,7 +20,7 @@ #ifndef POLLER_GET_VALUE_SSH_TEST_H #define POLLER_GET_VALUE_SSH_TEST_H -#include "dbcache.h" +#include "zbxcacheconfig.h" #if defined(HAVE_SSH2) || defined(HAVE_SSH) int zbx_get_value_ssh_test_run(DC_ITEM *item, char **error); diff --git a/tests/zabbix_server/poller/test_get_value_telnet.h b/tests/zabbix_server/poller/test_get_value_telnet.h index adb776a2c88..cfc6b039a34 100644 --- a/tests/zabbix_server/poller/test_get_value_telnet.h +++ b/tests/zabbix_server/poller/test_get_value_telnet.h @@ -20,7 +20,7 @@ #ifndef POLLER_GET_VALUE_TELNET_TEST_H #define POLLER_GET_VALUE_TELNET_TEST_H -#include "dbcache.h" +#include "zbxcacheconfig.h" int zbx_get_value_telnet_test_run(DC_ITEM *item, char **error); diff --git a/tests/zabbix_server/preprocessor/zbx_item_preproc.c b/tests/zabbix_server/preprocessor/zbx_item_preproc.c index d4936fae54b..7885c7d1a8d 100644 --- a/tests/zabbix_server/preprocessor/zbx_item_preproc.c +++ b/tests/zabbix_server/preprocessor/zbx_item_preproc.c @@ -24,7 +24,7 @@ #include "zbxcommon.h" #include "zbxjson.h" -#include "dbcache.h" +#include "zbxcacheconfig.h" #include "zbxembed.h" #include "log.h" diff --git a/tests/zabbix_server/service/Makefile.am b/tests/zabbix_server/service/Makefile.am index 5847747c6d9..ee6d58ece9c 100644 --- a/tests/zabbix_server/service/Makefile.am +++ b/tests/zabbix_server/service/Makefile.am @@ -14,7 +14,9 @@ COMMON_SRC_FILES = \ COMMON_LIBS = \ $(top_srcdir)/tests/libzbxmocktest.a \ $(top_srcdir)/src/zabbix_server/service/libservice.a \ - $(top_srcdir)/src/libs/zbxdbcache/libzbxdbcache.a \ + $(top_srcdir)/src/libs/zbxcacheconfig/libzbxcacheconfig.a \ + $(top_srcdir)/src/libs/zbxcachehistory/libzbxcachehistory.a \ + $(top_srcdir)/src/libs/zbxcachevalue/libzbxcachevalue.a \ $(top_srcdir)/src/libs/zbxavailability/libzbxavailability.a \ $(top_srcdir)/src/zabbix_server/availability/libavailability.a \ $(top_srcdir)/src/libs/zbxipcservice/libzbxipcservice.a \ |