Source
int zbx_get_remote_zabbix_stats_queue(const char *ip, unsigned short port, const char *from, const char *to,
/*
** Zabbix
** Copyright (C) 2001-2022 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
/******************************************************************************
* *
* Purpose: Check whether JSON response is "success" or "failed" *
* *
* Parameters: response - [IN] the request *
* result - [OUT] check result *
* *
* Return value: SUCCEED - processed successfully *
* FAIL - an error occurred *
* *
******************************************************************************/
static int check_response(const char *response, AGENT_RESULT *result)
{
struct zbx_json_parse jp;
char buffer[MAX_STRING_LEN];
if (SUCCEED != zbx_json_open(response, &jp))
{
SET_MSG_RESULT(result, zbx_strdup(NULL, "Value should be a JSON object."));
return FAIL;
}
if (SUCCEED != zbx_json_value_by_name(&jp, ZBX_PROTO_TAG_RESPONSE, buffer, sizeof(buffer), NULL))
{
SET_MSG_RESULT(result, zbx_dsprintf(NULL, "Cannot find tag: %s.", ZBX_PROTO_TAG_RESPONSE));
return FAIL;
}
if (0 != strcmp(buffer, ZBX_PROTO_VALUE_SUCCESS))
{
if (SUCCEED != zbx_json_value_by_name(&jp, ZBX_PROTO_TAG_INFO, buffer, sizeof(buffer), NULL))
SET_MSG_RESULT(result, zbx_dsprintf(NULL, "Cannot find tag: %s.", ZBX_PROTO_TAG_INFO));
else
SET_MSG_RESULT(result, zbx_dsprintf(NULL, "Cannot obtain internal statistics: %s", buffer));
return FAIL;
}