Source
void zbx_history_value2variant(const zbx_history_value_t *value, unsigned char value_type, zbx_variant_t *var)
/*
** Zabbix
** Copyright (C) 2001-2023 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.
**/
ZBX_VECTOR_IMPL(history_record, zbx_history_record_t)
extern char *CONFIG_HISTORY_STORAGE_URL;
extern char *CONFIG_HISTORY_STORAGE_OPTS;
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(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, 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];
writer->destroy(writer);
}
}