diff options
Diffstat (limited to 'src/libs/zbxdbhigh/lld_macro.c')
-rw-r--r-- | src/libs/zbxdbhigh/lld_macro.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/libs/zbxdbhigh/lld_macro.c b/src/libs/zbxdbhigh/lld_macro.c index 4c7445346e2..3ee2e7644ba 100644 --- a/src/libs/zbxdbhigh/lld_macro.c +++ b/src/libs/zbxdbhigh/lld_macro.c @@ -54,7 +54,6 @@ int zbx_lld_macro_paths_get(zbx_uint64_t lld_ruleid, zbx_vector_ptr_t *lld_macro DB_ROW row; zbx_lld_macro_path_t *lld_macro_path; int ret = SUCCEED; - char err[MAX_STRING_LEN]; zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __func__); @@ -67,14 +66,18 @@ int zbx_lld_macro_paths_get(zbx_uint64_t lld_ruleid, zbx_vector_ptr_t *lld_macro while (NULL != (row = DBfetch(result))) { - if (SUCCEED != (ret = zbx_json_path_check(row[1], err, sizeof(err)))) + zbx_jsonpath_t path; + + if (SUCCEED != (ret = zbx_jsonpath_compile(row[1], &path))) { - *error = zbx_dsprintf(*error, "Cannot process LLD macro \"%s\": %s.\n", row[0], err); + *error = zbx_dsprintf(*error, "Cannot process LLD macro \"%s\": %s.\n", row[0], + zbx_json_strerror()); break; } - lld_macro_path = (zbx_lld_macro_path_t *)zbx_malloc(NULL, sizeof(zbx_lld_macro_path_t)); + zbx_jsonpath_clear(&path); + lld_macro_path = (zbx_lld_macro_path_t *)zbx_malloc(NULL, sizeof(zbx_lld_macro_path_t)); lld_macro_path->lld_macro = zbx_strdup(NULL, row[0]); lld_macro_path->path = zbx_strdup(NULL, row[1]); @@ -114,16 +117,14 @@ void zbx_lld_macro_path_free(zbx_lld_macro_path_t *lld_macro_path) * lld_macro_paths - [IN] use json path to extract from jp_row * * macro - [IN] LLD macro * * value - [OUT] value extracted from jp_row * - * value_alloc - [OUT] allocated memory size for value * * * ******************************************************************************/ int zbx_lld_macro_value_by_name(const struct zbx_json_parse *jp_row, const zbx_vector_ptr_t *lld_macro_paths, - const char *macro, char **value, size_t *value_alloc) + const char *macro, char **value) { zbx_lld_macro_path_t lld_macro_path_local, *lld_macro_path; int index; - struct zbx_json_parse jp_out; - int ret; + size_t value_alloc = 0; lld_macro_path_local.lld_macro = (char *)macro; @@ -132,12 +133,12 @@ int zbx_lld_macro_value_by_name(const struct zbx_json_parse *jp_row, const zbx_v { lld_macro_path = (zbx_lld_macro_path_t *)lld_macro_paths->values[index]; - if (FAIL != (ret = zbx_json_path_open(jp_row, lld_macro_path->path, &jp_out))) - zbx_json_value_dyn(&jp_out, value, value_alloc); + if (SUCCEED == zbx_jsonpath_query(jp_row, lld_macro_path->path, value) && NULL != *value) + return SUCCEED; + + return FAIL; } else - ret = zbx_json_value_by_name_dyn(jp_row, macro, value, value_alloc); - - return ret; + return zbx_json_value_by_name_dyn(jp_row, macro, value, &value_alloc); } |