diff options
author | Sergey Simonenko <sergey.simonenko@zabbix.com> | 2022-07-11 03:46:07 +0300 |
---|---|---|
committer | Sergey Simonenko <sergey.simonenko@zabbix.com> | 2022-07-11 03:46:07 +0300 |
commit | d6dd0bd5e9300e10bf59a990ee41ed8f2b5d4812 (patch) | |
tree | f41ef305a11cbc90133d0cf0ba91fb86863683fb | |
parent | 8d461cf2cc2c07e88893ead48087c4f310429399 (diff) |
........S. [ZBX-21266] fixed {ITEM.KEY} macro support for expression macros
-rw-r--r-- | ChangeLog.d/bugfix/ZBX-21266 | 1 | ||||
-rw-r--r-- | src/libs/zbxeval/parse.c | 18 | ||||
-rw-r--r-- | src/libs/zbxserver/expression_eval.c | 1 |
3 files changed, 20 insertions, 0 deletions
diff --git a/ChangeLog.d/bugfix/ZBX-21266 b/ChangeLog.d/bugfix/ZBX-21266 new file mode 100644 index 00000000000..4e68df23bf3 --- /dev/null +++ b/ChangeLog.d/bugfix/ZBX-21266 @@ -0,0 +1 @@ +........S. [ZBX-21266] fixed {ITEM.KEY} macro support for expression macros (ssimonenko) diff --git a/src/libs/zbxeval/parse.c b/src/libs/zbxeval/parse.c index dbc97ab7635..54c63890906 100644 --- a/src/libs/zbxeval/parse.c +++ b/src/libs/zbxeval/parse.c @@ -610,6 +610,7 @@ static int eval_parse_query_filter(const char **ptr) size_t eval_parse_query(const char *str, const char **phost, const char **pkey, const char **pfilter) { #define MVAR_HOST_HOST "{HOST.HOST" +#define MVAR_ITEM_KEY "{ITEM.KEY" const char *host = str + 1, *key, *filter, *end; @@ -652,6 +653,23 @@ size_t eval_parse_query(const char *str, const char **phost, const char **pkey, if ('*' == *key) end++; + else if (0 == strncmp(key, MVAR_ITEM_KEY, ZBX_CONST_STRLEN(MVAR_ITEM_KEY))) + { + int offset = 0; + + if ('}' == key[ZBX_CONST_STRLEN(MVAR_ITEM_KEY)]) + { + offset = 1; + } + else if (0 != isdigit((unsigned char)key[ZBX_CONST_STRLEN(MVAR_ITEM_KEY)]) && + '}' == key[ZBX_CONST_STRLEN(MVAR_ITEM_KEY) + 1]) + { + offset = 2; + } + + if (0 != offset) + end += ZBX_CONST_STRLEN(MVAR_ITEM_KEY) + offset; + } else if (SUCCEED != parse_key(&end)) return 0; diff --git a/src/libs/zbxserver/expression_eval.c b/src/libs/zbxserver/expression_eval.c index 6298890354a..1a52db73a33 100644 --- a/src/libs/zbxserver/expression_eval.c +++ b/src/libs/zbxserver/expression_eval.c @@ -1987,6 +1987,7 @@ void zbx_expression_eval_resolve_trigger_hosts(zbx_expression_eval_t *eval, cons if (NULL != hi->host) { query->ref.host = zbx_strdup(query->ref.host, hi->host); + DBget_trigger_value(trigger, &query->ref.key, func_num, ZBX_REQUEST_ITEM_KEY); } else { |