Source
******************************************************************************************************************/
/*
** 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/>.
**/
/*
* The cache (zbx_vc_cache_t) is organized as a hashset of item records (zbx_vc_item_t).
*
* Each record holds item data (itemid, value_type), statistics (hits, last access time,...)
* and the historical data (timestamp,value pairs in ascending order).
*
* The historical data are stored from largest request (+timeshift) range to the
* current time. The data is automatically fetched from DB whenever a request
* exceeds cached value range.
*
* In addition to active range value cache tracks item range for last 24 hours. Once
* per day the active range is updated with daily range and the daily range is reset.
*
* If an item is already being cached the new values are automatically added to the cache
* after being written into database.
*
* When cache runs out of memory to store new items it enters in low memory mode.
* In low memory mode cache continues to function as before with few restrictions:
* 1) items that weren't accessed during the last day are removed from cache.
* 2) items with worst hits/values ratio might be removed from cache to free the space.
* 3) no new items are added to the cache.
*
* The low memory mode can't be turned off - it will persist until server is rebooted.
* In low memory mode a warning message is written into log every 5 minutes.
*/
ZBX_PTR_VECTOR_IMPL(vc_item_stats_ptr, zbx_vc_item_stats_t *)
void zbx_vc_item_stats_free(zbx_vc_item_stats_t * vc_item_stats)
{
zbx_free(vc_item_stats);
}
/* the period of low memory warning messages */
/* time period after which value cache will switch back to normal mode */
static zbx_shmem_info_t *vc_mem = NULL;