Source
ret = zbx_db_item_value(trigger, lastvalue, N_functionid, (int)time(NULL), 999999999, raw, tz, value_property);
/*
** 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: retrieve item value by trigger expression and number of function, *
* retrieved value depends from value property. *
* *
* Return value: upon successful completion return SUCCEED *
* otherwise FAIL *
* *
******************************************************************************/
int zbx_db_item_value(const zbx_db_trigger *trigger, char **value, int N_functionid, int clock, int ns, int raw,
const char *tz, zbx_expr_db_item_value_property_t value_property)
{
zbx_uint64_t itemid;
zbx_timespec_t ts = {clock, ns};
int ret;
time_t timestamp;
zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __func__);
if (SUCCEED == (ret = zbx_db_trigger_get_itemid(trigger, N_functionid, &itemid)) &&
SUCCEED == (ret = zbx_db_item_get_value(itemid, value, raw, &ts, ×tamp)))
{
switch (value_property)
{
case ZBX_VALUE_PROPERTY_TIME:
*value = zbx_strdup(*value, zbx_time2str(timestamp, tz));
break;
case ZBX_VALUE_PROPERTY_TIMESTAMP:
*value = zbx_dsprintf(*value, ZBX_FS_UI64, (uint64_t)timestamp);
break;
case ZBX_VALUE_PROPERTY_DATE:
*value = zbx_strdup(*value, zbx_date2str(timestamp, tz));
break;
case ZBX_VALUE_PROPERTY_AGE:
*value = zbx_strdup(*value, zbx_age2str(time(NULL) - timestamp));
break;
default:
break;
}