Source
xxxxxxxxxx
zbx_strlog_alloc(LOG_LEVEL_INFORMATION, out, out_alloc, out_offset, "== history cache diagnostic information ==");
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** 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 Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
ZBX_PTR_VECTOR_IMPL(diag_map_ptr, zbx_diag_map_t *)
static zbx_diag_add_section_info_func_t add_diag_cb;
void zbx_diag_map_free(zbx_diag_map_t *map)
{
zbx_free(map->name);
zbx_free(map);
}
/******************************************************************************
* *
* Purpose: parse diagnostic section request having json format *
* {"stats":[<field1>,<field2>,...], "top":{<field1>:<limit1>,...}} *
* *
* Parameters: jp - [IN] the request *
* field_map - [IN] a map of supported statistic field names to *
* bitmasks *
* field_mask - [OUT] the bitmask of the requested fields *
* top_views - [OUT] the requested top views *
* error - [OUT] error message *
* *
* Return value: SUCCEED - the request was parsed successfully *
* FAIL - otherwise *
* *
******************************************************************************/
int zbx_diag_parse_request(const struct zbx_json_parse *jp, const zbx_diag_map_t *field_map,
zbx_uint64_t *field_mask, zbx_vector_diag_map_ptr_t *top_views, char **error)
{
struct zbx_json_parse jp_stats;
int ret = FAIL;
const char *pnext = NULL;
char name[ZBX_DIAG_FIELD_MAX + 1], value[MAX_ID_LEN + 1];
zbx_uint64_t value_ui64;
*field_mask = 0;
/* parse requested statistics fields */
if (SUCCEED == zbx_json_brackets_by_name(jp, "stats", &jp_stats))
{
while (NULL != (pnext = zbx_json_next(&jp_stats, pnext)))
{
if (NULL != zbx_json_decodevalue(pnext, name, sizeof(name), NULL))
{
const zbx_diag_map_t *stat;
for (stat = field_map;; stat++)
{