Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/zabbix/zabbix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndris Zeila <andris.zeila@zabbix.com>2021-01-27 01:50:34 +0300
committerAndris Zeila <andris.zeila@zabbix.com>2021-01-27 01:55:43 +0300
commitffc0868ad96ffef7cbe1156c25f65d36388a6bfe (patch)
treeb03857921b67494a119b65a60b95e6a7ea66a0bc /include
parent477f6cf0ec943b422d571b256d4fb45160bb7744 (diff)
........S. [ZBXNEXT-6451] updated trigger expression processing to use new expression syntax
(trigger recalculation, macro resolving, etc - all places that parsed trigger expression to extract functionids).
Diffstat (limited to 'include')
-rw-r--r--include/common.h2
-rw-r--r--include/db.h16
-rw-r--r--include/dbcache.h10
-rw-r--r--include/zbxeval.h18
-rw-r--r--include/zbxserver.h1
5 files changed, 38 insertions, 9 deletions
diff --git a/include/common.h b/include/common.h
index a501e46711d..13beaf1acd8 100644
--- a/include/common.h
+++ b/include/common.h
@@ -1684,6 +1684,6 @@ int zbx_open_xml(char *data, int options, int maxerrlen, void **xml_doc, void **
int zbx_check_xml_memory(char *mem, int maxerrlen, char **errmsg);
#endif
-char *zbx_strloc_unquote_dyn(const char *src, const zbx_strloc_t *loc);
+char *zbx_strloc_get(const char *src, const zbx_strloc_t *loc);
#endif
diff --git a/include/db.h b/include/db.h
index fbdd8006e84..f9d469b3826 100644
--- a/include/db.h
+++ b/include/db.h
@@ -24,6 +24,7 @@
#include "zbxalgo.h"
#include "zbxdb.h"
#include "dbschema.h"
+#include "zbxeval.h"
extern char *CONFIG_DBHOST;
extern char *CONFIG_DBNAME;
@@ -307,6 +308,11 @@ typedef struct
}
DB_DSERVICE;
+#define ZBX_DB_TRIGGER_EVAL_NONE 0x0000
+#define ZBX_DB_TRIGGER_EVAL_EXPRESSION 0x0001
+#define ZBX_DB_TRIGGER_EVAL_EXPRESSION_USERMACRO 0x0002
+#define ZBX_DB_TRIGGER_EVAL_RECOVERY_EXPRESSION 0x0004
+
typedef struct
{
zbx_uint64_t triggerid;
@@ -323,6 +329,9 @@ typedef struct
unsigned char type;
unsigned char recovery_mode;
unsigned char correlation_mode;
+
+ /* temporary trigger cache for related data */
+ void *cache;
}
DB_TRIGGER;
@@ -871,6 +880,11 @@ void zbx_lld_override_operation_free(zbx_lld_override_operation_t *override_oper
void zbx_load_lld_override_operations(const zbx_vector_uint64_t *overrideids, char **sql, size_t *sql_alloc,
zbx_vector_ptr_t *ops);
-
+void zbx_db_trigger_get_all_functionids(const DB_TRIGGER *trigger, zbx_vector_uint64_t *functionids);
+void zbx_db_trigger_get_functionids(const DB_TRIGGER *trigger, zbx_vector_uint64_t *functionids);
+int zbx_db_trigger_get_all_hostids(const DB_TRIGGER *trigger, const zbx_vector_uint64_t **hostids);
+int zbx_db_trigger_get_constant(const DB_TRIGGER *trigger, int index, char **out);
+int zbx_db_trigger_get_itemid(const DB_TRIGGER *trigger, int index, zbx_uint64_t *itemid);
+void zbx_db_trigger_get_itemids(const DB_TRIGGER *trigger, zbx_vector_uint64_t *itemids);
#endif
diff --git a/include/dbcache.h b/include/dbcache.h
index e9c07adf576..b67930b2487 100644
--- a/include/dbcache.h
+++ b/include/dbcache.h
@@ -230,9 +230,6 @@ typedef struct _DC_TRIGGER
{
zbx_uint64_t triggerid;
char *description;
- char *expression_orig;
- char *recovery_expression_orig;
- /* temporary values, allocated during processing and freed right after */
char *expression;
char *recovery_expression;
@@ -750,7 +747,6 @@ void DCget_autoregistration_psk(char *psk_identity_buf, size_t psk_identity_buf_
#define ZBX_MACRO_SECRET_MASK "******"
void DCget_user_macro(const zbx_uint64_t *hostids, int hostids_num, const char *macro, char **replace_to);
-char *DCexpression_expand_user_macros(const char *expression);
char *zbx_dc_expand_func_params_user_macros(zbx_uint64_t hostid, const char *params);
int DCinterface_activate(zbx_uint64_t interfaceid, const zbx_timespec_t *ts, zbx_agent_availability_t *in,
@@ -990,10 +986,10 @@ typedef struct
{
zbx_uint64_t objectid;
zbx_uint64_t triggerid;
- zbx_function_type_t type;
+ zbx_uint32_t type;
zbx_time_unit_t trend_base;
unsigned char lock; /* 1 if the timer has locked trigger, 0 otherwise */
- int revision; /* function revision */
+ int revision; /* revision */
zbx_timespec_t eval_ts; /* the history time for which trigger must be recalculated */
zbx_timespec_t exec_ts; /* real time when the timer must be executed */
const char *parameter; /* function parameters (for trend functions) */
@@ -1012,4 +1008,6 @@ void zbx_db_trigger_queue_unlock(void);
void zbx_get_host_interfaces_availability(zbx_uint64_t hostid, zbx_agent_availability_t *agents);
+void zbx_dc_eval_expand_user_macros(zbx_eval_context_t *ctx);
+
#endif
diff --git a/include/zbxeval.h b/include/zbxeval.h
index c9482108acd..1ff895c8cc9 100644
--- a/include/zbxeval.h
+++ b/include/zbxeval.h
@@ -107,6 +107,7 @@
#define ZBX_EVAL_TRIGGER_EXPRESSION (ZBX_EVAL_PARSE_TRIGGER_EXPRESSSION | \
ZBX_EVAL_COMPOSE_TRIGGER_EXPRESSION | \
+ ZBX_EVAL_PARSE_CONST_INDEX | \
ZBX_EVAL_PROCESS_ERROR)
typedef zbx_uint32_t zbx_token_type_t;
@@ -160,6 +161,7 @@ typedef char *(*zbx_macro_resolve_func_t)(const char *str, size_t length, zbx_ui
int hostids_num);
int zbx_eval_parse_expression(zbx_eval_context_t *ctx, const char *expression, zbx_uint64_t rules, char **error);
+zbx_eval_context_t *zbx_eval_parse_expression_dyn(const char *expression, zbx_uint64_t rules, char **error);
void zbx_eval_clear(zbx_eval_context_t *ctx);
size_t zbx_eval_serialize(const zbx_eval_context_t *ctx, zbx_mem_malloc_func_t malloc_func, unsigned char **data);
void zbx_eval_deserialize(zbx_eval_context_t *ctx, const char *expression, zbx_uint64_t rules,
@@ -168,9 +170,23 @@ void zbx_eval_compose_expression(const zbx_eval_context_t *ctx, char **expressio
int zbx_eval_execute(zbx_eval_context_t *ctx, const zbx_timespec_t *ts, zbx_variant_t *value, char **error);
int zbx_eval_execute_ext(zbx_eval_context_t *ctx, const zbx_timespec_t *ts, zbx_eval_function_cb_t function_cb,
zbx_variant_t *value, char **error);
-void zbx_eval_get_functionids(const zbx_eval_context_t *ctx, zbx_vector_uint64_t *functionids);
+void zbx_eval_get_functionids(zbx_eval_context_t *ctx, zbx_vector_uint64_t *functionids);
+void zbx_eval_get_functionids_ordered(zbx_eval_context_t *ctx, zbx_vector_uint64_t *functionids);
void zbx_eval_expand_user_macros(const zbx_eval_context_t *ctx, zbx_uint64_t *hostids, int hostids_num,
zbx_macro_resolve_func_t resolver_cb);
void zbx_eval_set_exception(zbx_eval_context_t *ctx, char *message);
+#define ZBX_EVAL_EXTRACT_FUNCTIONID 0x0001
+#define ZBX_EVAL_EXTRACT_VAR_STR 0x0002
+#define ZBX_EVAL_EXTRACT_VAR_MACRO 0x0004
+
+#define ZBX_EVAL_EXCTRACT_ALL (ZBX_EVAL_EXTRACT_FUNCTIONID | ZBX_EVAL_EXTRACT_VAR_STR | ZBX_EVAL_EXTRACT_VAR_MACRO)
+
+zbx_eval_context_t *zbx_eval_deserialize_dyn(const unsigned char *data, const char *expression,
+ zbx_uint64_t mask);
+int zbx_eval_check_timer_functions(const zbx_eval_context_t *ctx);
+void zbx_get_serialized_expression_functionids(const char *expression, const unsigned char *data,
+ zbx_vector_uint64_t *functionids);
+void zbx_eval_get_constant(const zbx_eval_context_t *ctx, int index, char **value);
+
#endif
diff --git a/include/zbxserver.h b/include/zbxserver.h
index 29999ee4490..da0778313cf 100644
--- a/include/zbxserver.h
+++ b/include/zbxserver.h
@@ -74,6 +74,7 @@ int substitute_simple_macros_unmasked(zbx_uint64_t *actionid, const DB_EVENT *ev
int maxerrlen);
void evaluate_expressions(zbx_vector_ptr_t *triggers);
+void prepare_triggers(DC_TRIGGER **triggers, int triggers_num);
void zbx_format_value(char *value, size_t max_len, zbx_uint64_t valuemapid,
const char *units, unsigned char value_type);