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
path: root/src/libs
diff options
context:
space:
mode:
authorAleksejs Sestakovs <aleksejs.sestakovs@zabbix.com>2022-01-28 13:03:48 +0300
committerAleksejs Sestakovs <aleksejs.sestakovs@zabbix.com>2022-01-28 13:03:48 +0300
commit0b3551a3c4e8fd693b538e396f0a4d6a0a9e975e (patch)
treefc152aa486643e5673de47da06e0327ec0729676 /src/libs
parent7da56661eefa1f73e9df2c3629134630e1ec52ce (diff)
........S. [ZBX-20334] fixed macro support in aggregate functions
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/zbxserver/expression.c16
-rw-r--r--src/libs/zbxserver/expression_eval.c24
2 files changed, 36 insertions, 4 deletions
diff --git a/src/libs/zbxserver/expression.c b/src/libs/zbxserver/expression.c
index 8910211213f..8d6783566ad 100644
--- a/src/libs/zbxserver/expression.c
+++ b/src/libs/zbxserver/expression.c
@@ -4134,17 +4134,27 @@ static int substitute_simple_macros_impl(const zbx_uint64_t *actionid, const DB_
else if (0 == indexed_macro &&
0 != (macro_type & (MACRO_TYPE_ITEM_KEY | MACRO_TYPE_PARAMS_FIELD |
MACRO_TYPE_LLD_FILTER | MACRO_TYPE_ALLOWED_HOSTS |
- MACRO_TYPE_SCRIPT_PARAMS_FIELD)))
+ MACRO_TYPE_SCRIPT_PARAMS_FIELD | MACRO_TYPE_QUERY_FILTER)))
{
- if (ZBX_TOKEN_USER_MACRO == token.type)
+ if (ZBX_TOKEN_USER_MACRO == token.type && 0 == (MACRO_TYPE_QUERY_FILTER & macro_type))
{
DCget_user_macro(&dc_item->host.hostid, 1, m, &replace_to);
pos = token.loc.r;
}
else if (0 == strcmp(m, MVAR_HOST_HOST) || 0 == strcmp(m, MVAR_HOSTNAME))
+ {
replace_to = zbx_strdup(replace_to, dc_item->host.host);
+ }
else if (0 == strcmp(m, MVAR_HOST_NAME))
- replace_to = zbx_strdup(replace_to, dc_item->host.name);
+ {
+ if (0 != (MACRO_TYPE_QUERY_FILTER & macro_type))
+ {
+ zbx_free(replace_to);
+ replace_to = zbx_dyn_escape_string(dc_item->host.name, "\\");
+ }
+ else
+ replace_to = zbx_strdup(replace_to, dc_item->host.name);
+ }
else if (0 == strcmp(m, MVAR_HOST_IP) || 0 == strcmp(m, MVAR_IPADDRESS))
{
if (INTERFACE_TYPE_UNKNOWN != dc_item->interface.type)
diff --git a/src/libs/zbxserver/expression_eval.c b/src/libs/zbxserver/expression_eval.c
index 8d42aaf7fc4..bd840788fb2 100644
--- a/src/libs/zbxserver/expression_eval.c
+++ b/src/libs/zbxserver/expression_eval.c
@@ -1705,6 +1705,29 @@ void zbx_expression_eval_resolve_item_hosts(zbx_expression_eval_t *eval, const D
}
}
+/******************************************************************************
+ * *
+ * Function: zbx_expression_eval_resolve_filter_macros *
+ * *
+ * Purpose: resolve calculated item formula macros in filter *
+ * *
+ * Parameters: eval - [IN] the evaluation data *
+ * item - [IN] the calculated item *
+ * *
+ ******************************************************************************/
+void zbx_expression_eval_resolve_filter_macros(zbx_expression_eval_t *eval, const DC_ITEM *item)
+{
+ int i;
+
+ for (i = 0; i < eval->queries.values_num; i++)
+ {
+ zbx_expression_query_t *query = (zbx_expression_query_t *)eval->queries.values[i];
+
+ substitute_simple_macros(NULL, NULL, NULL, NULL, NULL, NULL, item, NULL, NULL, NULL, &query->ref.filter,
+ MACRO_TYPE_QUERY_FILTER, NULL, 0);
+ }
+}
+
typedef struct
{
int num;
@@ -1712,7 +1735,6 @@ typedef struct
}
zbx_host_index_t;
-
static int host_index_compare(const void *d1, const void *d2)
{
const int *i1 = *(const int **)d1;