"Zabbix"- Items (Items) @20210222

brief introduction

In many cases, we need more complex monitoring methods and monitoring indicators. At this time, we need to customize monitoring items.

This document briefly introduces the content of adding items and managing items in Zabbix.

What is a monitoring item?

The monitoring item is the indicator to be obtained. It consists of the data to be acquired, the frequency of acquisition, the storage time of the data type, and so on. The detection cycle affects data acquisition and can affect the frequency of Zabbix Server.

How to add monitoring items?

Monitoring items can be added in "Host" or in "Template". Monitoring items added in "Template" can be reused.

# The first step, add monitoring items

The demo here is added in the Template. After finding "Configuration-Templates-Items-Create Item" in turn, enter the creation page of monitoring items:

		**# Name**-The name of the monitoring item. 
		**# Key **- The value of the monitoring item. (1) You can choose by yourself, but "Custom KEY" (described later) needs to be filled in manually. (2) Then, modify the value in ``[<xxx>]'' to a specific parameter (refer to "[[https://www.zabbix.com/documentation/4.2/manual/config/items/itemtypes|4.2 /Item types]]" manual). For example, if you want to count the total memory size, after selecting ``vm.memory.size[<mode>]'', you can modify it to ``vm.memory.size[total]'' (of course, in addition to ``total'', but also There are other parameters to choose from).

The other input boxes on the page have the same literal meaning. For details, please refer to the " 4.2/2 Items " document. Here are just a few of them:

   
Name Item name
Type Types of monitoring items
Key KEY name corresponding to the monitoring item
Type of information Type of information obtained
Update interval Frequency of data acquisition
Custom intervals Custom frequency, you can redefine the rules of Update interval

Regarding the "KEY" format
(1) In the KEY field on the page, its value can have two formats, KEY or KEY[PARAM] , namely "with parameters" and "without parameters".
(2) The legal naming of KEY is expressed as: [a-zA-z0-9-_.]
(3) PARAM is a parameter, and the format can be "quoted string", "non-quoted string", " Arrays of these three types. The "quoted string" has the form: vm.memory.size["total"] ; the "non-quoted string" has the form: vm.memory.size[total] . If there are quotation marks, use a backslash to escape. Use commas and square brackets; the "array" has the form: icmping[,,200,,500] , multiple parameters are separated by commas, and if there is no option, leave it blank , which means the default value is used.

# The second step, check the monitoring items

After the configuration is over, you can use the zabbix_get command to verify. This verification is to check whether the KEY configuration is correct.

Execute zabbix_get --host'agent_ip_addr' -k vm.memory.size[total] command, if the return value is normal, it means that the configuration of KEY is normal, and it also means that Zabbix Server can access Zabbix Agent to or value.

Note that the command zabbix_get can only be used to verify monitoring items whose Type is Zabbix agent , and cannot be used for monitoring items of these types such as Simple Check, JMX, etc.

Custom items

The monitoring items that come with Zabbix may not meet our needs, we need to customize the monitoring items.

# How to customize monitoring items?

Custom "monitoring items" currently only support the Zabbix agent type, which means that you need to modify the /etc/zabbix/zabbix_agentd.conf configuration file of the Zabbix Agent service (or customize the configuration in /etc/zabbix/zabbix_agentd.d/ , Then introduce the configuration in zabbix_agentd.conf ).

The configuration file format is as follows:

# Do not pass parameters 
UserParameter=key,command 

# Pass parameters 
UserParameter=key[*],command $1 $2 $3... 

# For example, the following custom monitoring items 
UserParameter=redis.standalone.info[*],redis-cli -h $1 -p $2 -a $3 INFO 

# When using the KEY 
redis.standalone.info[127.0.0.1,6379,123456]

# Precautions for monitoring items

(1) The KEY in the custom parameter must be unique, otherwise an error will occur when Zabbix Agent is started, and an error message will be displayed in the log.
(2) The parameters passed to KEY will be passed to the command in turn. The first parameter corresponds to $1 in the command , the second parameter corresponds to $2 in the command , and so on.
(3) If you need to use some special characters in the parameters (such as *, &, ", etc., these symbols will cause command injection), you need to turn on the UnsafeUserParameters=1 setting.
(4) If you want to use the $ symbol in the command, you should do "Double write" escape. For example: awk'{print $$1} '
(5) The return value type can be characters, text, etc. If the returned value is an invalid value, the message ZBX_NOTSUPPORTED will be displayed .

# Check new monitoring items

You can still use the zabbix_get command to check whether the configured KEY is correct, or use the zabbix_agentd -p command to check all supported monitoring items.

Item type

# Different types

In Zabbix, it supports multiple types of monitoring items, such as Zabbix agent, Simple check, etc., and can also monitor logs and databases.

The different types of monitoring items represent: different data collection methods and different data processing methods.

In the real scene, the specific type used depends on the situation. I won't list them here, and refer to the manual " 4.2/2 Item types " for details .

# Common types

The types and functions of some monitoring items are listed below:

Types of effect
Zabbix internal Detect and monitor oneself.
Zabbix agent The most commonly used mode is to obtain data passively.
Zabbix agent (active) Active mode. Log monitoring needs to use this mode.
Simple check Simple check, check the remote host when Zabbix Agent is not running.
Zabbix aggregate Aggregation operation is to aggregate data within a certain period of time (average, maximum, minimum, etc.).
Calculated It can be calculated based on multiple monitoring items and performed by Zabbix Server. And you can customize the KEY name, and then be referenced by other monitoring items.
Dependent items This type of monitoring item depends on a monitoring item and can obtain values ​​from the results of other monitoring items.

I will not list them one by one here. For details, please refer to the manual " 4.2/2 Item types ".

About the "Dependent items" type

-" Zabbix UserParameter return 2 or more values "
This type is worth mentioning. You can create a monitoring item that requests many values ​​at a time (for example, REDIS INFO to obtain information). Then, multiple other monitoring items are dependent on the monitoring item, and the values ​​are filtered from the results of the previous monitoring items. In this way, the network pressure can be reduced when the amount of data remains unchanged, and the complexity of the zabbix_agentd.conf configuration file can be reduced , but the template or host configuration may be increased.

Maintenance time

You can set the maintenance time (Configuration-Maintance). Also configure Action (Configuration-Actions-Action) so that there is no alarm during the maintenance time.

Event confirmation

After the event occurs, you can manually confirm it.

Data import and configuration export

The configuration file can be exported from Zabbix or imported into Zabbix. Import is at the upper right corner of the page, and export is at the bottom of the page.

related articles

"Zabbix"-Chinese font "garbled" (no Chinese font)
"Zabbix"-set active mode and passive mode

Guess you like

Origin blog.csdn.net/u013670453/article/details/113941657