Source
xxxxxxxxxx
static void zbx_register_history_write_cbs(zbx_module_t *module, ZBX_HISTORY_WRITE_CBS history_write_cbs)
/*
** 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/>.
**/
static zbx_vector_ptr_t modules;
zbx_history_float_cb_t *history_float_cbs = NULL;
zbx_history_integer_cb_t *history_integer_cbs = NULL;
zbx_history_string_cb_t *history_string_cbs = NULL;
zbx_history_text_cb_t *history_text_cbs = NULL;
zbx_history_log_cb_t *history_log_cbs = NULL;
/******************************************************************************
* *
* Purpose: add items supported by module *
* *
* Parameters: metrics - list of items supported by module *
* error - error buffer *
* max_error_len - error buffer size *
* *
* Return value: SUCCEED - all module items were added or there were none *
* FAIL - otherwise *
* *
******************************************************************************/
static int zbx_register_module_items(zbx_metric_t *metrics, char *error, size_t max_error_len)
{
int i;
for (i = 0; NULL != metrics[i].key; i++)
{
/* accept only CF_HAVEPARAMS flag from module items */
metrics[i].flags &= CF_HAVEPARAMS;
/* the flag means that the items comes from a loadable module */
metrics[i].flags |= CF_MODULE;
if (SUCCEED != zbx_add_metric(&metrics[i], error, max_error_len))
return FAIL;
}
return SUCCEED;
}
/******************************************************************************
* *
* Purpose: add module to the list of successfully loaded modules *
* *
******************************************************************************/
static zbx_module_t *zbx_register_module(void *lib, char *name)
{
zbx_module_t *module;
module = (zbx_module_t *)zbx_malloc(NULL, sizeof(zbx_module_t));
module->lib = lib;
module->name = zbx_strdup(NULL, name);
zbx_vector_ptr_append(&modules, module);
return module;
}
/******************************************************************************
* *
* Purpose: registers callback functions for history export *
* *
* Parameters: module - module pointer for later reference *
* history_write_cbs - callbacks *
* *