Source
/*
** 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/>.
**/
/******************************************************************************
* *
* Purpose: add requested proxy buffer diagnostic information to json data *
* *
* Parameters: jp - [IN] the request *
* json - [IN/OUT] the json to update *
* error - [OUT] error message *
* *
* Return value: SUCCEED - the information was added successfully *
* FAIL - otherwise *
* *
******************************************************************************/
static int diag_add_proxybuffer_info(const struct zbx_json_parse *jp, struct zbx_json *json, char **error)
{
zbx_vector_diag_map_ptr_t tops;
int ret;
double time1, time2, time_total = 0;
zbx_uint64_t fields;
zbx_diag_map_t field_map[] = {
{"memory", ZBX_DIAG_PROXYBUFFER_MEMORY},
{NULL, 0}
};
zbx_vector_diag_map_ptr_create(&tops);
if (SUCCEED == (ret = zbx_diag_parse_request(jp, field_map, &fields, &tops, error)))
{
zbx_json_addobject(json, ZBX_DIAG_PROXYBUFFER);
if (0 != (fields & ZBX_DIAG_PROXYBUFFER_MEMORY))
{
zbx_shmem_stats_t stats;
time1 = zbx_time();
zbx_pb_get_mem_stats(&stats);
time2 = zbx_time();
time_total += time2 - time1;
zbx_diag_add_mem_stats(json, "memory", &stats);