Source
xxxxxxxxxx
if (SUCCEED == item_preproc_delta(value_type, value, &ts, type, history_value_in, history_value_out, history_ts,
/*
** 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/>.
**/
/******************************************************************************
* *
* Purpose: execute 'multiply by' step *
* *
* Parameters: value_type - [IN] item value type *
* value - [IN/OUT] input/output value *
* params - [IN] preprocessing parameters *
* *
* Result value: SUCCEED - the preprocessing step was executed successfully. *
* FAIL - otherwise. The error message is stored in value. *
* *
******************************************************************************/
static int pp_execute_multiply(unsigned char value_type, zbx_variant_t *value, const char *params)
{
char buffer[MAX_STRING_LEN], *error = NULL, *errmsg = NULL;
zbx_strlcpy(buffer, params, sizeof(buffer));
zbx_trim_float(buffer);
if (FAIL == zbx_is_double(buffer, NULL))
{
error = zbx_dsprintf(NULL, "a numerical value is expected or the value is out of range");
}
else if (SUCCEED == item_preproc_multiplier_variant(value_type, value, buffer, &errmsg))
{
return SUCCEED;
}
else
{
error = zbx_dsprintf(NULL, "cannot apply multiplier \"%s\" to value of type \"%s\": %s",
params, zbx_variant_type_desc(value), errmsg);
zbx_free(errmsg);
}
zbx_variant_clear(value);
zbx_variant_set_error(value, error);
return FAIL;
}
/******************************************************************************
* *
* Purpose: return preprocessing 'trim' step descriptions for error messages *
* *
******************************************************************************/
static const char *pp_trim_desc(int type)
{
switch (type)
{
case ZBX_PREPROC_RTRIM:
return "right ";
case ZBX_PREPROC_LTRIM:
return "left ";
default:
return "";