Source
static int evaluate_statistical_func(zbx_variant_t *value, const zbx_dc_evaluate_item_t *item, const char *parameters,
/*
** 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.
**/
typedef struct
{
char value[ZBX_VALUEMAP_STRING_LEN];
char newvalue[ZBX_VALUEMAP_STRING_LEN];
int type;
}
zbx_valuemaps_t;
ZBX_PTR_VECTOR_DECL(valuemaps_ptr, zbx_valuemaps_t *)
ZBX_PTR_VECTOR_IMPL(valuemaps_ptr, zbx_valuemaps_t *)
/******************************************************************************
* *
* Purpose: Process suffix 'uptime' *
* *
* Parameters: value - value for adjusting *
* max_len - max len of the value *
* *
******************************************************************************/
static void add_value_suffix_uptime(char *value, size_t max_len)
{
double secs, days;
size_t offset = 0;
int hours, mins;
zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __func__);
if (0 > (secs = round(atof(value))))
{
offset += zbx_snprintf(value, max_len, "-");
secs = -secs;
}
days = floor(secs / SEC_PER_DAY);
secs -= days * SEC_PER_DAY;
hours = (int)(secs / SEC_PER_HOUR);
secs -= (double)hours * SEC_PER_HOUR;
mins = (int)(secs / SEC_PER_MIN);
secs -= (double)mins * SEC_PER_MIN;
if (0 != days)
{
if (1 == days)
offset += zbx_snprintf(value + offset, max_len - offset, ZBX_FS_DBL_EXT(0) " day, ", days);
else
offset += zbx_snprintf(value + offset, max_len - offset, ZBX_FS_DBL_EXT(0) " days, ", days);
}