项目值预处理允许 define ,并对接收的项值执行转换规则。
预处理由预处理管理器进程管理,该进程已在Zabbix 3.4中添加,以及执行预处理步骤的预处理工作程序。 在添加到历史缓存之前,来自不同数据收集器的所有值(有或没有预处理)都会通过预处理管理器。 基于套接字的IPC通信用于数据收集器(轮询器,捕获器等)和预处理过程之间。 只有Zabbix服务器正在执行预处理步骤。
为了可视化从数据源到Zabbix数据库的数据流,我们可以使用以下简化图:
上图仅以简化形式显示与项目值处理相关的流程,对象和操作。 该图未显示条件方向更改,错误处理或循环。 未显示预处理管理器的本地数据高速缓存,因为它不会直接影响数据流。 此图的目的是显示项目值处理中涉及的过程及其交互方式。
如果任何预处理步骤失败,则在执行预处理时,项目可以将其状态更改为NOT SUPPORTED。
如果数据规范化失败(例如,当文本值无法转换为数字时),项可以将其状态更改为NOT SUPPORTED。
为了可视化数据预处理过程,我们可以使用以下简化图:
上图仅以简化形式显示了与项值预处理相关的流程,对象和主要操作。 该图未显示条件方向更改,错误处理或循环。 此图中只显示了一个预处理工作程序(多个预处理工作程序可以在实际场景中使用),只处理一个项目值,我们假设此项目需要执行至少一个预处理步骤。 该图的目的是展示项目值预处理管道背后的想法。
项可以放在预处理队列的末尾或开头。 Zabbix内部项总是放在预处理队列的开头,而其他项类型最后排队。
通过多个处理以多个步骤(或阶段)执行项目值处理。 这可能导致:
* 主项具有值类型''UINT'',(可以使用捕获项),依赖项具有值类型''TEXT''。
* 主项和从属项都不需要预处理步骤。
* 应将文本值(例如“abc”)传递给主项目。
* 由于没有要执行的预处理步骤,预处理管理器检查主项目是否处于NOT SUPPORTED状态并且是否设置了值(两者都为真)并且将依赖项目排入与主项目具有相同值(因为没有预处理步骤)。
* 当主项和从属项都达到历史同步阶段时,由于值converSion错误(文本数据无法转换为无符号整数),主项变为NOT SUPPORTED。
因此,依赖项接收值,而主项将其状态更改为NOT SUPPORTED。
CHAR
类型用于主项目,则主项目值将在历史同步阶段被截断,而依赖项目将从主项目的初始(未截断)值接收它们的值。预处理队列是一种FIFO数据结构,它存储保留预处理管理器恢复值的顺序的值。 FIFO逻辑有多个例外:
为了可视化数据预处理过程,我们可以使用以下简化图:
预处理队列中的值从队列的开头刷新到第一个未处理的值。 因此,例如,预处理管理器将刷新值1,2和3,但不会刷新值5,因为值4尚未处理:
刷新后,队列(4和5)中只剩下两个值,将值添加到预处理管理器的本地数据高速缓存中,然后将值从本地高速缓存传输到历史记录高速缓存中。 预处理管理器可以在单项模式或批量模式下从本地数据高速缓存刷新值(用于依赖项和批量接收的值)。
Zabbix服务器配置文件允许用户设置预处理工作进程的计数。 应使用StartPreprocessors配置参数来设置预处理工作程序的预分叉实例数。 预处理工作者的最佳数量可以由许多因素决定,包括“可预处理”项目的计数(需要执行任何预处理步骤的项目),数据收集过程的计数,项目预处理的平均步数等。
但是假设没有像解析大型XML / JSON块那样繁重的预处理操作,预处理工作者的数量可以匹配数据收集器的总数。 这样,大多数(除了来自收集器的数据大量出现的情况除外)至少是一个未占用的预处理工作者用于收集数据。
<note warning>太多的数据收集进程(轮询器,无法访问的轮询器,HTTP轮询器,Java轮询器,pinper,捕获器,代理程序控制器)以及IPMI管理器,SNMP捕获器和预处理工作程序可能会耗尽预处理管理器的每进程文件描述符限制。 这将导致Zabbix服务器停止(通常在启动后不久,但有时可能需要更多时间)。 应修改配置文件或应提高限制以避免这种情况。 :::
Item value preprocessing allows to define and execute transformation rules for the received item values.
Preprocessing is managed by a preprocessing manager process, which has been added in Zabbix 3.4, along with preprocessing workers that perform the preprocessing steps. All values (with or without preprocessing) from different data gatherers pass through the preprocessing manager before being added to the history cache. Socket-based IPC communication is used between data gatherers (pollers, trappers, etc) and the preprocessing process. Only Zabbix server is performing preprocessing steps.
To visualize the data flow from data source to the Zabbix database, we can use the following simplified diagram:
The diagram above shows only processes, objects and actions related to item value processing in a simplified form. The diagram does not show conditional direction changes, error handling or loops. Local data cache of preprocessing manager is not shown either because it doesn't affect data flow directly. The aim of this diagram is to show processes involved in item value processing and the way they interact.
Item can change its state to NOT SUPPORTED while preprocessing is performed if any of preprocessing steps fail.
Item can change it's state to NOT SUPPORTED if data normalization fails (for example, when textual value cannot be converted to number).
To visualize the data preprocessing process, we can use the following simplified diagram:
The diagram above shows only processes, objects and main actions related to item value preprocessing in a simplified form. The diagram does not show conditional direction changes, error handling or loops. Only one preprocessing worker is shown on this diagram (multiple preprocessing workers can be used in real-life scenarios), only one item value is being processed and we assume that this item requires to execute at least one preprocessing step. The aim of this diagram is to show the idea behind item value preprocessing pipeline.
Item can be placed at the end or at the beginning of the preprocessing queue. Zabbix internal items are always placed at the beginning of preprocessing queue, while other item types are enqueued at the end.
Item value processing is executed in multiple steps (or phases) by multiple processes. This can cause:
* Master item has value type ''UINT'', (trapper item can be used), dependent item has value type ''TEXT''.
* No preprocessing steps are required for both master and dependent items.
* Textual value (like, "abc") should be passed to master item.
* As there are no preprocessing steps to execute, preprocessing manager checks if master item is not in NOT SUPPORTED state and if value is set (both are true) and enqueues dependent item with the same value as master item (as there are no preprocessing steps).
* When both master and dependent items reach history synchronization phase, master item becomes NOT SUPPORTED, because of the value converSion error (textual data cannot be converted to unsigned integer).
As a result, dependent item receIves a value, while master item changes itS state to NOT SUPPORTED.
CHAR
type is used for master item, then master item value will be truncated at the history synchronization phase, while dependent items will receive their value from the initial (not truncated) value of master item.Preprocessing queue is a FIFO data structure that stores values preserving the order in which values are revieved by preprocessing manager. There are multiple exceptions to FIFO logic:
To visualize the logic of preprocessing queue, we can use the following diagram:
Values from the preprocessing queue are flushed from the beginning of the queue to the first unprocessed value. So, for example, preprocessing manager will flush values 1, 2 and 3, but will not flush value 5 as value 4 is not processed yet:
Only two values will be left in queue (4 and 5) after flushing, values are added into local data cache of preprocessing manager and then values are transferred from local cache into history cache. Preprocessing manager can flush values from local data cache in single item mode or in bulk mode (used for dependent items and values received in bulk).
Zabbix server configuration file allows users to set count of preprocessing worker processes. StartPreprocessors configuration parameter should be used to set number of pre-forked instances of preprocessing workers. Optimal number of preprocessing workers can be determined by many factors, including the count of "preprocessable" items (items that require to execute any preprocessing steps), count of data gathering processes, average step count for item preprocessing, etc.
But assuming that there is no heavy preprocessing operations like parsing of large XML / JSON chunks, number of preprocessing workers can match total number of data gatherers. This way, there will mostly (except for the cases when data from gatherer comes in bulk) be at least one unoccupied preprocessing worker for collected data.
Too many data gathering processes (pollers, unreachable pollers, HTTP pollers, Java pollers, pingers, trappers, proxypollers) together with IPMI manager, SNMP trapper and preprocessing workers can exhaust the per-process file descriptor limit for the preprocessing manager. This will cause Zabbix server to stop (usually shortly after the start, but sometimes it can take more time). The configuration file should be revised or the limit should be raised to avoid this situation.