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_MAX];
/************************************************************************************
* *
* 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. *
* *
************************************************************************************/
int zbx_history_init(char **error)
{
int i, ret;
/* TODO: support per value type specific configuration */
const char *opts[] = {"dbl", "str", "log", "uint", "text"};
for (i = 0; i < ITEM_VALUE_TYPE_MAX; i++)
{
if (NULL == CONFIG_HISTORY_STORAGE_URL || NULL == strstr(CONFIG_HISTORY_STORAGE_OPTS, opts[i]))
ret = zbx_history_sql_init(&history_ifaces[i], i, error);
else
ret = zbx_history_elastic_init(&history_ifaces[i], i, error);
if (FAIL == ret)
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_MAX; i++)
{
zbx_history_iface_t *writer = &history_ifaces[i];
writer->destroy(writer);
}
}
/************************************************************************************
* *
* Purpose: Sends values to the history storage *
* *
* Parameters: history - [IN] the values to store *
* *
* Comments: add history values to the configured storage backends *