Source
if (NULL != (data_source = zbx_odbc_connect(dsn, connection, item->username, item->password, item->timeout,
/*
** Copyright (C) 2001-2024 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 database *
* *
* Parameters: item - [IN] item we are interested in *
* result - [OUT] check result *
* *
* Return value: SUCCEED - data successfully retrieved and stored in result *
* NOTSUPPORTED - requested item is not supported *
* *
******************************************************************************/
int get_value_db(const zbx_dc_item_t *item, AGENT_RESULT *result)
{
AGENT_REQUEST request;
const char *dsn, *connection = NULL;
zbx_odbc_data_source_t *data_source;
zbx_odbc_query_result_t *query_result;
char *error = NULL;
int (*query_result_to_text)(zbx_odbc_query_result_t *query_result, char **text, char **error),
ret = NOTSUPPORTED;
zabbix_log(LOG_LEVEL_DEBUG, "In %s() key_orig:'%s' query:'%s'", __func__, item->key_orig, item->params);
zbx_init_agent_request(&request);
if (SUCCEED != zbx_parse_item_key(item->key, &request))
{
SET_MSG_RESULT(result, zbx_strdup(NULL, "Invalid item key format."));
goto out;
}
if (0 == strcmp(request.key, "db.odbc.select"))
{
query_result_to_text = zbx_odbc_query_result_to_string;
}
else if (0 == strcmp(request.key, "db.odbc.discovery"))
{
query_result_to_text = zbx_odbc_query_result_to_lld_json;
}
else if (0 == strcmp(request.key, "db.odbc.get"))