trends are two main tables in Zabbix database for storing data. There are also tables inherits
history which are used to store different types of data. For example, table
history_uint is to store uint data. Others are
history_text. Please pay attention that there is only one table inherits table
trends and its name is
The start of the whole process is in function
dbcache is a feature which enables Zabbix to keep data in memory first and flush to database in batch.
To make it more clearly, I wrote comments inline.
static void DCsync_all()
Since we are talking about Zabbix Server, so we will only take a look at
DCsync_history(). In this paragraph, I have simplified the code in
DCsync_history() to help readers understand the core process of flushing data to database.
Let’s take a look into
It will calculate the numbers for each type of items.
And then, call function to write data to database.
/* history */
Finally, we can touch the sql in
static void dc_add_history_dbl(ZBX_DC_HISTORY *history, int history_num)
Let’s see the code first.
static void DCmass_update_trends(ZBX_DC_HISTORY *history, int history_num)
We get that the main process is in the function
DCadd_trend(). Let’s move on to it.
static void DCadd_trend(ZBX_DC_HISTORY *history, ZBX_DC_TREND **trends, int *trends_alloc, int *trends_num)
Above all, I think we are clear on the fact how Zabbix update history and trends.
Below is the process: