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: retrieves data from Zabbix agent *
* *
* Parameters: item - [IN] item we are interested in *
* config_source_ip - [IN] *
* program_type - [IN] *
* result - [OUT] *
* version - [IN/OUT] if 7.0.0 or higher, connect using, *
* JSON protocol, fallback and retry *
* with plaintext protocol *
* Return value: SUCCEED - data successfully retrieved and stored in result *
* and result_str (as string) *
* NETWORK_ERROR - network related error occurred *
* NOTSUPPORTED - item not supported by the agent *
* AGENT_ERROR - uncritical error on agent side occurred *
* FAIL - otherwise *
* *
* Comments: error will contain error message *
* *
******************************************************************************/
int zbx_agent_get_value(const zbx_dc_item_t *item, const char *config_source_ip, unsigned char program_type,
AGENT_RESULT *result, int *version)
{
zbx_socket_t s;
const char *tls_arg1, *tls_arg2;
int ret = SUCCEED, retry = 0;
ssize_t received_len;
zabbix_log(LOG_LEVEL_DEBUG, "In %s() host:'%s' addr:'%s' key:'%s' conn:'%s'", __func__, item->host.host,
item->interface.addr, item->key, zbx_tcp_connection_type_name(item->host.tls_connect));
switch (item->host.tls_connect)
{
case ZBX_TCP_SEC_UNENCRYPTED:
tls_arg1 = NULL;
tls_arg2 = NULL;
break;