Source
xxxxxxxxxx
void zbx_history_value2variant(const zbx_history_value_t *value, unsigned char value_type, zbx_variant_t *var)
/*
** 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_VECTOR_IMPL(history_record, zbx_history_record_t)
ZBX_PTR_VECTOR_IMPL(dc_history_ptr, zbx_dc_history_t *)
void zbx_dc_history_shallow_free(zbx_dc_history_t *dc_history)
{
zbx_free(dc_history);
}
zbx_history_iface_t history_ifaces[ITEM_VALUE_TYPE_BIN + 1];
/************************************************************************************
* *
* Purpose: initializes history storage *
* *
* Comments: History interfaces are created for all values types based on *
* configuration. Every value type can have different history storage *
* backend. (Binary value type is not supported for ElasticSearch) *
* *
************************************************************************************/
int zbx_history_init(const char *config_history_storage_url, const char *config_history_storage_opts,
int config_log_slow_queries, char **error)
{
/* TODO: support per value type specific configuration */
const char *opts[] = {"dbl", "str", "log", "uint", "text", "bin"};
for (int i = ITEM_VALUE_TYPE_FLOAT; i <= ITEM_VALUE_TYPE_BIN; i++)
{
if (NULL == config_history_storage_url || NULL == strstr(config_history_storage_opts, opts[i]))
{
zbx_history_sql_init(&history_ifaces[i], i);
}
else
{
if (ITEM_VALUE_TYPE_BIN == i)
{
*error = zbx_strdup(*error, "Binary value type is not supported for ElasticSearch"
" history storage");
return FAIL;
}
if (FAIL == zbx_history_elastic_init(&history_ifaces[i], i, config_history_storage_url,
config_log_slow_queries, error))
{
return FAIL;
}
}
}
return SUCCEED;
}
/************************************************************************************
* *
* Purpose: destroys history storage *
* *
* Comments: All interfaces created by zbx_history_init() function are destroyed *
* here. *
* *
************************************************************************************/
void zbx_history_destroy(void)
{
int i;
for (i = 0; i <= ITEM_VALUE_TYPE_BIN; i++)
{
zbx_history_iface_t *writer = &history_ifaces[i];