Zabbix Documentation 3.4

3.04.04.4 (current)| In development:5.0 (devel)| Unsupported:1.82.02.22.43.23.44.2Guidelines

User Tools

Site Tools


zh:manual:discovery:low_level_discovery

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
zh:manual:discovery:low_level_discovery [2017/04/04 09:13]
bluetom520 [3.1 文件系统的发现]
zh:manual:discovery:low_level_discovery [2017/04/04 10:19]
bluetom520 [3.9 Using LLD macros in user macro contexts]
Line 220: Line 220:
  
 Discovery of network interfaces is done in exactly the same way as discovery of file systems, except that you use the discovery rule key "​net.if.discovery"​ instead of "​vfs.fs.discovery"​ and use macro {#IFNAME} instead of {#FSNAME} in filter and item/​trigger/​graph prototypes. Discovery of network interfaces is done in exactly the same way as discovery of file systems, except that you use the discovery rule key "​net.if.discovery"​ instead of "​vfs.fs.discovery"​ and use macro {#IFNAME} instead of {#FSNAME} in filter and item/​trigger/​graph prototypes.
 +
 +网络接口的发现与文件系统的发现完全相同,只是你使用发现规则的键值是“net.if.discovery”而不是“vfs.fs.discovery”,并使用宏{#​IFNAME}而不是{#​FSNAME}。
  
 Examples of item prototypes that you might wish to create based on "​net.if.discovery":​ "​net.if.in[{#​IFNAME},​bytes]",​ "​net.if.out[{#​IFNAME},​bytes]"​. Examples of item prototypes that you might wish to create based on "​net.if.discovery":​ "​net.if.in[{#​IFNAME},​bytes]",​ "​net.if.out[{#​IFNAME},​bytes]"​.
 +
 +你可能希望基于“net.if.discovery”创建的监控项原型示例:“net.if.in[{#​IFNAME},​bytes]”,“net.if.out[{#​IFNAME},​bytes]“。
  
 [[#​discovery_of_file_systems|See above]] for more information about the filter. [[#​discovery_of_file_systems|See above]] for more information about the filter.
  
-=== - Discovery of CPUs and CPU cores ===+有关过滤器的更多信息,请参阅[[#​discovery_of_file_systems|上文]]。 
 + 
 +=== - CPU和CPU内核的发现 ​===
  
 Discovery of CPUs and CPU cores is done in a similar fashion as network interface discovery with the exception being that the discovery rule key is "​system.cpu.discovery"​. This discovery key returns two macros - {#​CPU.NUMBER} and {#​CPU.STATUS} identifying the CPU order number and status respectively. To note, a clear distinction cannot be made between actual, physical processors, cores and hyperthreads. {#​CPU.STATUS} on Linux, UNIX and BSD systems returns the status of the processor, which can be either "​online"​ or "​offline"​. On Windows systems, this same macro may represent a third value - "​unknown"​ - which indicates that a processor has been detected, but no information has been collected for it yet. Discovery of CPUs and CPU cores is done in a similar fashion as network interface discovery with the exception being that the discovery rule key is "​system.cpu.discovery"​. This discovery key returns two macros - {#​CPU.NUMBER} and {#​CPU.STATUS} identifying the CPU order number and status respectively. To note, a clear distinction cannot be made between actual, physical processors, cores and hyperthreads. {#​CPU.STATUS} on Linux, UNIX and BSD systems returns the status of the processor, which can be either "​online"​ or "​offline"​. On Windows systems, this same macro may represent a third value - "​unknown"​ - which indicates that a processor has been detected, but no information has been collected for it yet.
 +
 +CPU和CPU内核的发现以与网络接口发现类似的方式完成相同,除了发现规则的键值是“system.cpu.discovery”之外。此发现键返回两个宏 - {#CPU.NUMBER}和{#CPU.STATUS}分别标识CPU序号和状态。要注意,实际物理处理器,内核和超线程之间不能做出明确的区分。在Linux,UNIX和BSD系统上的{#CPU.STATUS}返回处理器的状态,可以是“online”还是“offline”。在Windows系统上,同一个宏可能表示第三个值 - “unknown” - 这表示处理器已被检测到,但尚未收集到任何信息
  
 CPU discovery relies on the agent'​s collector process to remain consistent with the data provided by the collector and save resources on obtaining the data. This has the effect of this item key not working with the test (-t) command line flag of the agent binary, which will return a NOT_SUPPORTED status and an accompanying message indicating that the collector process has not been started. CPU discovery relies on the agent'​s collector process to remain consistent with the data provided by the collector and save resources on obtaining the data. This has the effect of this item key not working with the test (-t) command line flag of the agent binary, which will return a NOT_SUPPORTED status and an accompanying message indicating that the collector process has not been started.
 +
 +CPU发现依赖于agent的收集器进程去收集和获取数据。如果agent的测试(-t)命令行不起作用,这将返回一个NOT_SUPPORTED状态以及附带的消息,表明收集器进程尚未启动。
  
 Item prototypes that can be created based on CPU discovery include, for example, "​system.cpu.util[{#​CPU.NUMBER},​ <​type>,​ <​mode>​]"​ or "​system.hw.cpu[{#​CPU.NUMBER},​ <​info>​]"​. Item prototypes that can be created based on CPU discovery include, for example, "​system.cpu.util[{#​CPU.NUMBER},​ <​type>,​ <​mode>​]"​ or "​system.hw.cpu[{#​CPU.NUMBER},​ <​info>​]"​.
  
-=== - Discovery of SNMP OIDs ===+可以基于CPU发现规则创建的监控项原型包括例如: "​system.cpu.util[{#​CPU.NUMBER},​ <​type>,​ <​mode>​]"​ 或 "​system.hw.cpu[{#​CPU.NUMBER},​ <​info>​]"​。 
 + 
 +=== - SNMP OID的发现 ​===
  
 In this example, we will perform SNMP discovery on a switch. First, go to "​Configuration"​ -> "​Templates"​. In this example, we will perform SNMP discovery on a switch. First, go to "​Configuration"​ -> "​Templates"​.
 +
 +例如,我们将在交换机上执行SNMP发现。首先,进入“配置”→“模板”。
  
 {{manual:​discovery:​low_level_discovery:​templates_snmp.png|}} {{manual:​discovery:​low_level_discovery:​templates_snmp.png|}}
  
 To edit discovery rules for a template, click on the link in the "​Discovery"​ column. To edit discovery rules for a template, click on the link in the "​Discovery"​ column.
 +
 +要编辑模板的发现规则,请单击“自动发现”列中的链接。
  
 Then, press "​Create rule" and fill the form with the details in the screenshot below. Then, press "​Create rule" and fill the form with the details in the screenshot below.
 +
 +然后,按“创建发现规则”,并在下面的屏幕截图中填写表单与详细信息。
  
 Unlike file system and network interface discovery, the item does not necessarily have to have "​snmp.discovery"​ key - item type of SNMP agent is sufficient. Unlike file system and network interface discovery, the item does not necessarily have to have "​snmp.discovery"​ key - item type of SNMP agent is sufficient.
 +
 +与文件系统和网络接口发现不同,项目不一定必须具有“snmp.discovery”键值 - SNMP agent的项目类型就足够了。
  
 The OIDs to discover are defined in SNMP OID field in the following format: ''​discovery[{#​MACRO1},​ oid1, {#MACRO2}, oid2, …,​]''​ The OIDs to discover are defined in SNMP OID field in the following format: ''​discovery[{#​MACRO1},​ oid1, {#MACRO2}, oid2, …,​]''​
 +
 +要发现的OID在SNMP OID字段中以下列格式定义: ''​discovery[{#​MACRO1},​ oid1, {#MACRO2}, oid2, …,​]''​
  
 where //​{#​MACRO1}//,​ //​{#​MACRO2}//​ …  are valid lld macro names and //oid1//, //oid2//... are OIDs capable of generating meaningful values for these macros. A built-in macro //​{#​SNMPINDEX}//​ containing index of the discovered OID is applied to discovered entities. The discovered entities are grouped by //​{#​SNMPINDEX}//​ macro value. where //​{#​MACRO1}//,​ //​{#​MACRO2}//​ …  are valid lld macro names and //oid1//, //oid2//... are OIDs capable of generating meaningful values for these macros. A built-in macro //​{#​SNMPINDEX}//​ containing index of the discovered OID is applied to discovered entities. The discovered entities are grouped by //​{#​SNMPINDEX}//​ macro value.
 +
 +其中//​{#​MACRO1}//,​ //​{#​MACRO2}//​ ...是有效的lld宏名称和//​oid1//,​ //oid2//... 是能够为这些宏生成有意义的值的OID。已发现OID索引的内置宏{#​SNMPINDEX}将应用于发现的实体。发现的实体按{#​SNMPINDEX}宏值分组。
  
 To understand what we mean, let us perform few snmpwalks on our switch: ​ To understand what we mean, let us perform few snmpwalks on our switch: ​
 +
 +为了理解清楚,在我们的交换机上执行几个snmpwalk:
   $ snmpwalk -v 2c -c public 192.168.1.1 IF-MIB::​ifDescr   $ snmpwalk -v 2c -c public 192.168.1.1 IF-MIB::​ifDescr
   IF-MIB::​ifDescr.1 = STRING: WAN   IF-MIB::​ifDescr.1 = STRING: WAN
Line 261: Line 287:
  
 And set SNMP OID to: ''​discovery[{#​IFDESCR},​ ifDescr, {#​IFPHYSADDRESS},​ ifPhysAddress]''​ And set SNMP OID to: ''​discovery[{#​IFDESCR},​ ifDescr, {#​IFPHYSADDRESS},​ ifPhysAddress]''​
 +
 +并将SNMP OID设置为: ''​discovery[{#​IFDESCR},​ ifDescr, {#​IFPHYSADDRESS},​ ifPhysAddress]''​
  
 Now this rule will discover entities with {#IFDESCR} macros set to **WAN**, **LAN1** and **LAN2**, {#​IFPHYSADDRESS} macros set to **8:​0:​27:​90:​7a:​75**,​ **8:​0:​27:​90:​7a:​76**,​ and **8:​0:​27:​2b:​af:​9e**,​ {#​SNMPINDEX} macros set to the discovered OIDs indexes **1**, **2** and **3**: Now this rule will discover entities with {#IFDESCR} macros set to **WAN**, **LAN1** and **LAN2**, {#​IFPHYSADDRESS} macros set to **8:​0:​27:​90:​7a:​75**,​ **8:​0:​27:​90:​7a:​76**,​ and **8:​0:​27:​2b:​af:​9e**,​ {#​SNMPINDEX} macros set to the discovered OIDs indexes **1**, **2** and **3**:
 +
 +现在,这个规则会发现设置为{#​IFDESCR}宏实体WAN,LAN1和LAN2,{#​IFPHYSADDRESS}宏设置为8:0:27:90:7A:75,8:0:27:90:7A:76和8:0:27:2B:AF:9E,{#​SNMPINDEX}宏设定为所发现的OID索引1,2和3:
   {   {
       "​data":​ [       "​data":​ [
Line 284: Line 314:
  
 If an entity does not have the specified OID, then the corresponding macro will be omitted for this entity. For example if we have the following data: If an entity does not have the specified OID, then the corresponding macro will be omitted for this entity. For example if we have the following data:
 +
 +如果一个实体没有指定的OID,则该实体将忽略相应的宏。例如,如果我们有以下数据:
   ifDescr.1 "​Interface #1"   ifDescr.1 "​Interface #1"
   ifDescr.2 "​Interface #2"   ifDescr.2 "​Interface #2"
Line 294: Line 326:
    
 Then in this case SNMP discovery ''​discovery[{#​IFDESCR},​ ifDescr, {#IFALIAS}, ifAlias]''​ will return the following structure: ​ Then in this case SNMP discovery ''​discovery[{#​IFDESCR},​ ifDescr, {#IFALIAS}, ifAlias]''​ will return the following structure: ​
 +
 +那么在这种情况下,SNMP发现''​discovery[{#​IFDESCR},​ ifDescr, {#IFALIAS}, ifAlias]''​ 将返回以下结构:
   {   {
       "​data":​ [       "​data":​ [
Line 324: Line 358:
  
 The following screenshot illustrates how we can use these macros in item prototypes: The following screenshot illustrates how we can use these macros in item prototypes:
 +
 +以下屏幕截图显示了我们如何在监控项原型中使用这些宏:
  
 {{manual:​discovery:​low_level_discovery:​item_prototype_snmp.png|}} {{manual:​discovery:​low_level_discovery:​item_prototype_snmp.png|}}
  
 Again, creating as many item prototypes as needed: Again, creating as many item prototypes as needed:
 +
 +再次,根据需要创建尽可能多的监控项原型:
  
 {{manual:​discovery:​low_level_discovery:​item_prototypes_snmp.png|}} {{manual:​discovery:​low_level_discovery:​item_prototypes_snmp.png|}}
  
 As well as trigger prototypes: As well as trigger prototypes:
 +
 +以及触发原型:
  
 {{manual:​discovery:​low_level_discovery:​trigger_prototype_snmp.png|}} {{manual:​discovery:​low_level_discovery:​trigger_prototype_snmp.png|}}
Line 338: Line 378:
  
 And graph prototypes: And graph prototypes:
 +
 +和图形原型:
  
 {{manual:​discovery:​low_level_discovery:​graph_prototype_snmp.png|}} {{manual:​discovery:​low_level_discovery:​graph_prototype_snmp.png|}}
Line 344: Line 386:
  
 A summary of our discovery rule: A summary of our discovery rule:
 +
 +我们的发现规则摘要:
  
 {{manual:​discovery:​low_level_discovery:​lld_rules_snmp.png|}} {{manual:​discovery:​low_level_discovery:​lld_rules_snmp.png|}}
  
 When server runs, it will create real items, triggers and graphs based on the values the SNMP discovery rule returns. In the host configuration they are prefixed with an orange link to a discovery rule they come from. When server runs, it will create real items, triggers and graphs based on the values the SNMP discovery rule returns. In the host configuration they are prefixed with an orange link to a discovery rule they come from.
 +
 +当服务器运行时,它将根据SNMP发现规则返回的值创建实际监控项,触发器和图形。在主机配置中,它们的前缀是橙色链接到它们来自的发现规则。
  
 {{manual:​discovery:​low_level_discovery:​discovered_items_snmp.png|}} {{manual:​discovery:​low_level_discovery:​discovered_items_snmp.png|}}
Line 355: Line 401:
 {{manual:​discovery:​low_level_discovery:​discovered_graphs_snmp.png|}} {{manual:​discovery:​low_level_discovery:​discovered_graphs_snmp.png|}}
  
-=== - Discovery using ODBC SQL queries ​===+=== - ODBC SQL查询的发现 ​===
  
 This type of discovery is done using SQL queries, whose results get automatically transformed into a JSON object suitable for low-level discovery. SQL queries are performed using items of type "​Database monitor"​. Therefore, most of the instructions on [[:​manual/​config/​items/​itemtypes/​odbc_checks|ODBC monitoring]] page apply in order to get a working "​Database monitor"​ discovery rule, the only difference being that "​db.odbc.discovery[<​description>,<​dsn>​]"​ key should be used instead of "​db.odbc.select[<​description>,<​dsn>​]"​. This type of discovery is done using SQL queries, whose results get automatically transformed into a JSON object suitable for low-level discovery. SQL queries are performed using items of type "​Database monitor"​. Therefore, most of the instructions on [[:​manual/​config/​items/​itemtypes/​odbc_checks|ODBC monitoring]] page apply in order to get a working "​Database monitor"​ discovery rule, the only difference being that "​db.odbc.discovery[<​description>,<​dsn>​]"​ key should be used instead of "​db.odbc.select[<​description>,<​dsn>​]"​.
 +
 +这种类型的发现使用SQL查询完成,其结果自动转换为适合于自动发现(LLD)的JSON对象。使用“数据库监控”类型的项目执行SQL查询。因此,[[:​manual/​config/​items/​itemtypes/​odbc_checks|ODBC监控]]页面上的说明都适用于“数据库监控”发现规则,唯一的区别是应该使用"​db.odbc.discovery[<​description>,<​dsn>​]"​键代替"​db.odbc.select[<​description>,<​dsn>​]”。
  
 As a practical example to illustrate how the SQL query is transformed into JSON, let us consider low-level discovery of Zabbix proxies by performing an ODBC query on Zabbix database. This is useful for automatic creation of "​zabbix[proxy,<​name>,​lastaccess]"​ [[:​manual/​config/​items/​itemtypes/​internal|internal items]] to monitor which proxies are alive. As a practical example to illustrate how the SQL query is transformed into JSON, let us consider low-level discovery of Zabbix proxies by performing an ODBC query on Zabbix database. This is useful for automatic creation of "​zabbix[proxy,<​name>,​lastaccess]"​ [[:​manual/​config/​items/​itemtypes/​internal|internal items]] to monitor which proxies are alive.
 +
 +举例来说明SQL查询如何转换为JSON,我们可以通过在Zabbix数据库上执行ODBC查询来执行Zabbix proxies 自动发现(LLD)。这对于自动创建"​zabbix[proxy,<​name>,​lastaccess]" ​ [[:​manual/​config/​items/​itemtypes/​internal|内部项目]]来监视哪些proxies是存活的很有用。
  
 Let us start with discovery rule configuration:​ Let us start with discovery rule configuration:​
 +
 +让我们从发现规则配置开始:
  
 {{manual:​discovery:​low_level_discovery:​discovery_rule_odbc.png}} {{manual:​discovery:​low_level_discovery:​discovery_rule_odbc.png}}
  
 Here, the following direct query on Zabbix database is used to select all Zabbix proxies, together with the number of hosts they are monitoring. The number of hosts can be used, for instance, to filter out empty proxies: Here, the following direct query on Zabbix database is used to select all Zabbix proxies, together with the number of hosts they are monitoring. The number of hosts can be used, for instance, to filter out empty proxies:
 +
 +这里,对Zabbix数据库的执行查询用于选择所有Zabbix proxies以及它们正在监视的主机数量。例如,可以使用主机数量来过滤掉空 proxies:
  
 <​code>​ <​code>​
Line 380: Line 434:
  
 By the internal workings of "​db.odbc.discovery[]"​ item, the result of this query gets automatically transformed into the following JSON: By the internal workings of "​db.odbc.discovery[]"​ item, the result of this query gets automatically transformed into the following JSON:
 +
 +通过“db.odbc.discovery []”项目的内部工作,此查询的结果将自动转换为以下JSON:
  
 <code js> <code js>
Line 401: Line 457:
  
 It can be seen that column names become macro names and selected rows become the values of these macros. It can be seen that column names become macro names and selected rows become the values of these macros.
 +
 +可以看出,列名称成为宏名称,选定的行将成为这些宏的值。
  
 <​note>​ <​note>​
 If it is not obvious how a column name would be transformed into a macro name, it is suggested to use column aliases like "​COUNT(h2.host) AS count" in the example above. If it is not obvious how a column name would be transformed into a macro name, it is suggested to use column aliases like "​COUNT(h2.host) AS count" in the example above.
 +
 +如果将列名称变换为宏名称不明显,建议在上述示例中使用像"​COUNT(h2.host) AS count"​这样的列别名。
  
 In case a column name cannot be converted into a valid macro name, the discovery rule becomes not supported, with the error message detailing the offending column number. If additional help is desired, the obtained column names are provided under DebugLevel=4 in Zabbix server log file: In case a column name cannot be converted into a valid macro name, the discovery rule becomes not supported, with the error message detailing the offending column number. If additional help is desired, the obtained column names are provided under DebugLevel=4 in Zabbix server log file:
 +
 +如果列名称无法转换为有效的宏名称,则不支持发现规则,错误消息将详细列出违规列号。如果需要其他帮助,获取的列名称在Zabbix服务器日志文件中的DebugLevel = 4下提供:
  
 <​code>​ <​code>​
Line 419: Line 481:
  
 Now that we understand how a SQL query is transformed into a JSON object, we can use {#HOST} macro in item prototypes: Now that we understand how a SQL query is transformed into a JSON object, we can use {#HOST} macro in item prototypes:
 +
 +现在我们了解SQL查询如何转换为JSON对象,我们可以在项目原型中使用{#​HOST}宏:
  
 {{manual:​discovery:​low_level_discovery:​item_prototype_odbc.png}} {{manual:​discovery:​low_level_discovery:​item_prototype_odbc.png}}
  
 Once discovery is performed, an item will be created for each proxy: Once discovery is performed, an item will be created for each proxy:
 +执行发现后,将为每个proxy创建一个监控项:
  
 {{manual:​discovery:​low_level_discovery:​discovered_items_odbc.png}} {{manual:​discovery:​low_level_discovery:​discovered_items_odbc.png}}
  
-=== - Discovery of Windows ​services ​===+=== - Windows服务的发现 ​===
  
 Windows service discovery is done in the same way as discovery of file systems. The key to use in the  discovery rule is "​service.discovery"​ and the following macros are supported for use in the [[#​discovery_of_file_systems|filter]] and item/​trigger/​graph prototypes: Windows service discovery is done in the same way as discovery of file systems. The key to use in the  discovery rule is "​service.discovery"​ and the following macros are supported for use in the [[#​discovery_of_file_systems|filter]] and item/​trigger/​graph prototypes:
 +
 +Windows服务发现的方式与文件系统的发现相同。在发现规则中使用的关键是“service.discovery”,并且支持以下宏用于过滤器和监控项/​触发器/​图形原型:
  
 <​code>​ <​code>​
Line 443: Line 510:
  
 Based on Windows service discovery you may create an item prototype like "​service.info[{#​SERVICE.NAME},<​param>​]",​ where //param// accepts the following values: //state//, //​displayname//,​ //path//, //user//, //startup// or //​description//​. For example, to acquire the display name of a service you should use a "​service.info[{#​SERVICE.NAME},​displayname]"​ item. If //param// value is not specified ("​service.info[{#​SERVICE.NAME}]"​),​ the default parameter //state// is used. Based on Windows service discovery you may create an item prototype like "​service.info[{#​SERVICE.NAME},<​param>​]",​ where //param// accepts the following values: //state//, //​displayname//,​ //path//, //user//, //startup// or //​description//​. For example, to acquire the display name of a service you should use a "​service.info[{#​SERVICE.NAME},​displayname]"​ item. If //param// value is not specified ("​service.info[{#​SERVICE.NAME}]"​),​ the default parameter //state// is used.
 +
 +基于Windows服务发现,你可以创建一个监控项原型,如"​service.info[{#​SERVICE.NAME},<​param>​]"​),其中//​param//​接受以下值://​state//,​ //​displayname//,​ //path//, //user//, //startup// 或 //​description//​。例如,要获取服务的显示名称,您应该使用"​service.info[{#​SERVICE.NAME},​displayname]"​项目。如果没有指定//​param//​值("​service.info[{#​SERVICE.NAME}]"​),则使用默认参//​param//​态。
  
 {#​SERVICE.STATE} and {#​SERVICE.STATENAME} macros return the same content, however, {#​SERVICE.STATE} returns a numerical value (0-7), while {#​SERVICE.STATENAME} returns text (//​running//,​ //paused//, //start pending//, //pause pending//, //continue pending//, //stop pending//, //stopped// or //​unknown//​). The same applies to {#​SERVICE.STARTUP} and {#​SERVICE.STARTUPNAME},​ where one returns a numerical value (0-4) while the other - text (//​automatic//,​ //automatic delayed//, //manual//, //​disabled//,​ //​unknown//​). {#​SERVICE.STATE} and {#​SERVICE.STATENAME} macros return the same content, however, {#​SERVICE.STATE} returns a numerical value (0-7), while {#​SERVICE.STATENAME} returns text (//​running//,​ //paused//, //start pending//, //pause pending//, //continue pending//, //stop pending//, //stopped// or //​unknown//​). The same applies to {#​SERVICE.STARTUP} and {#​SERVICE.STARTUPNAME},​ where one returns a numerical value (0-4) while the other - text (//​automatic//,​ //automatic delayed//, //manual//, //​disabled//,​ //​unknown//​).
  
-=== - Setting up multiple ​LLD rules for the same item ===+{#SERVICE.STATE}和{#SERVICE.STATENAME}宏返回相同的内容,但{#SERVICE.STATE}返回数值(0-7),而{#SERVICE.STATENAME}返回文字(//​running//,​ //paused//, //start pending//, //pause pending//, //continue pending//, //stop pending//, //stopped// or //​unknown//​)。{#SERVICE.STARTUP}和{#SERVICE.STARTUPNAME}也是如此,其中一个返回数字值(0-4),而另一个文本(//​automatic//,​ //automatic delayed//, //manual//, //​disabled//,​ //​unknown//​)。 
 + 
 +=== - 为同一项目设置多个LLD规则 ​===
  
 Since Zabbix agent version 3.2 it is possible to alter low-level discovery item keys using "​Alias"​ parameter in [[manual/​appendix/​config/​zabbix_agentd|zabbix_agentd.conf]] file to enable configuration of several LLD rules for the same item. Since Zabbix agent version 3.2 it is possible to alter low-level discovery item keys using "​Alias"​ parameter in [[manual/​appendix/​config/​zabbix_agentd|zabbix_agentd.conf]] file to enable configuration of several LLD rules for the same item.
  
-=== - Creating custom ​LLD rules ===+从Zabbix agent版本3.2,可以使用[[manual/​appendix/​config/​zabbix_agentd|zabbix_agentd.conf]]文件中的“Alias”参数来更改自动发现项目键值,以便为同一项目配置多个LLD规则。 
 + 
 +=== - 创建自定义LLD规则===
  
 It is also possible to create a completely custom LLD rule, discovering any type of entities - for example, databases on a database server. It is also possible to create a completely custom LLD rule, discovering any type of entities - for example, databases on a database server.
 +
 +也可以创建完全自定义的LLD规则,发现任何类型的实体 - 例如数据库服务器上的数据库。
  
 To do so, a custom item should be created that returns JSON, specifying found objects and optionally - some properties of them. The amount of macros per entity is not limited - while the built-in discovery rules return either one or two macros (for example, two for filesystem discovery), it is possible to return more. To do so, a custom item should be created that returns JSON, specifying found objects and optionally - some properties of them. The amount of macros per entity is not limited - while the built-in discovery rules return either one or two macros (for example, two for filesystem discovery), it is possible to return more.
 +
 +为此,应该创建一个返回JSON的自定义项目,指定找到的对象以及可选的一些属性。每个实体的宏数量不受限制 - 而内置的发现规则返回一个或两个宏(例如,两个用于文件系统发现)。
  
 The required JSON format is best illustrated with an example. Suppose we are running an old Zabbix 1.8 agent (one that does not support "​vfs.fs.discovery"​),​ but we still need to discover file systems. Here is a simple Perl script for Linux that discovers mounted file systems and outputs JSON, which includes both file system name and type. One way to use it would be as a UserParameter with key "​vfs.fs.discovery_perl":​ The required JSON format is best illustrated with an example. Suppose we are running an old Zabbix 1.8 agent (one that does not support "​vfs.fs.discovery"​),​ but we still need to discover file systems. Here is a simple Perl script for Linux that discovers mounted file systems and outputs JSON, which includes both file system name and type. One way to use it would be as a UserParameter with key "​vfs.fs.discovery_perl":​
 +
 +下面举例说明JSON格式。假设我们运行一个旧的Zabbix 1.8 agent(不支持"​vfs.fs.discovery"​),但是我们仍然需要发现文件系统。这是一个用于Linux的简单Perl脚本,用于发现挂载的文件系统并输出JSON,其中包含文件系统名称和类型。使用它的一种方式是具有键值"​vfs.fs.discovery_perl"​的参数:
  
 <code perl> <code perl>
Line 484: Line 563:
  
 <note important>​Allowed symbols for LLD macro names are **0-9** , **A-Z** , **_** , **.** \\ \\  Lowercase letters are not supported in the names.</​note>​ <note important>​Allowed symbols for LLD macro names are **0-9** , **A-Z** , **_** , **.** \\ \\  Lowercase letters are not supported in the names.</​note>​
 +
 +<note important>​对于LLD宏名允许的符号为 **0-9** , **A-Z** , **_** , **.** \\ \\ 名称中不支持小写字母。</​note>​
  
 An example of its output (reformatted for clarity) is shown below. JSON for custom discovery checks has to follow the same format. An example of its output (reformatted for clarity) is shown below. JSON for custom discovery checks has to follow the same format.
 +
 +其输出的示例(为了清楚起见重新格式化)如下所示。用于自定义发现检查的JSON必须遵循相同的格式。
  
   {   {
Line 507: Line 590:
  
 Then, in the discovery rule's "​Filter"​ field, we could specify "​{#​FSTYPE}"​ as a macro and "​rootfs|ext3"​ as a regular expression. Then, in the discovery rule's "​Filter"​ field, we could specify "​{#​FSTYPE}"​ as a macro and "​rootfs|ext3"​ as a regular expression.
 +
 +然后,在发现规则的“过滤器”字段中,我们可以将“{#​FSTYPE}”指定为宏,将 "​rootfs|ext3"​指定为正则表达式。
  
 <​note>​You don't have to use macro names FSNAME/​FSTYPE with custom LLD rules, you are free to use whatever names you like.</​note>​ <​note>​You don't have to use macro names FSNAME/​FSTYPE with custom LLD rules, you are free to use whatever names you like.</​note>​
  
-=== - Using LLD macros in user macro contexts ​===+<​note>​你不一定使用具有自定义LLD规则的宏名称FSNAME/​FSTYPE,你可以随意使用任何名称。</​note>​ 
 + 
 +=== - 在用户宏上下文中使用LLD宏 ===
  
 User macros [[:​manual/​config/​macros/​usermacros#​user_macro_context|with context]] can be used to accomplish more flexible thresholds in trigger expressions. Different thresholds may be defined on user macro level and then used in trigger constants depending on the discovered context. Discovered context appears when the [[:​manual/​config/​macros/​lld_macros|low-level discovery macros]] used in the macros are resolved to real values. User macros [[:​manual/​config/​macros/​usermacros#​user_macro_context|with context]] can be used to accomplish more flexible thresholds in trigger expressions. Different thresholds may be defined on user macro level and then used in trigger constants depending on the discovered context. Discovered context appears when the [[:​manual/​config/​macros/​lld_macros|low-level discovery macros]] used in the macros are resolved to real values.
 +
 +[[:​manual/​config/​macros/​usermacros#​user_macro_context|具有上下文]]的用户宏可用于在触发器表达式中实现更灵活的阈值。可以在用户宏级别上定义不同的阈值,然后根据发现的上下文使用触发器常量。当宏中使用的自动发现(LLD)宏被解析为真实值时,会出现在发现的上下文。
  
 To illustrate we can use data from the example above and assume that the following file systems will be discovered: ''/'',​ ''/​home'',​ ''/​tmp'',​ ''/​usr'', ​ ''/​var''​. To illustrate we can use data from the example above and assume that the following file systems will be discovered: ''/'',​ ''/​home'',​ ''/​tmp'',​ ''/​usr'', ​ ''/​var''​.
 +
 +为了说明我们可以从例子中使用上述数据和假设下面的文件系统将被发现:''/'',​ ''/​home'',​ ''/​tmp'',​ ''/​usr'', ​ ''/​var''​。
  
 We may define a free-disk-space trigger prototype for a host, where the threshold is expressed by a user macro with context: We may define a free-disk-space trigger prototype for a host, where the threshold is expressed by a user macro with context:
 +
 +我们可以为主机定义一个可用磁盘空间触发器原型,其中阈值由具有上下文的用户宏表示:
  
 ''​{host:​vfs.fs.size[{#​FSNAME},​pfree].last()}<​**{$LOW_SPACE_LIMIT:<​nowiki>"</​nowiki>​{#​FSNAME}<​nowiki>"</​nowiki>​}**''​ ''​{host:​vfs.fs.size[{#​FSNAME},​pfree].last()}<​**{$LOW_SPACE_LIMIT:<​nowiki>"</​nowiki>​{#​FSNAME}<​nowiki>"</​nowiki>​}**''​
  
 Then add user macros: Then add user macros:
 +
 +然后添加用户宏:
   * ''​{$LOW_SPACE_LIMIT}''​ **10**   * ''​{$LOW_SPACE_LIMIT}''​ **10**
   * ''​{$LOW_SPACE_LIMIT:/​home}''​ **20**   * ''​{$LOW_SPACE_LIMIT:/​home}''​ **20**
Line 526: Line 621:
  
 Now, once the file systems are discovered, events will be generated if ''/'',​ ''/​usr''​ and ''/​var''​ filesystems have less than **10**% of free disk space, the ''/​home''​ filesystem - less than **20**% of free disk space or the ''/​tmp''​ filesystem - less than **50**% of free disk space. Now, once the file systems are discovered, events will be generated if ''/'',​ ''/​usr''​ and ''/​var''​ filesystems have less than **10**% of free disk space, the ''/​home''​ filesystem - less than **20**% of free disk space or the ''/​tmp''​ filesystem - less than **50**% of free disk space.
 +
 +现在,一旦文件系统被发现,事件将被告知是否产生/​,/​usr以及/​var文件系统具有小于**10**% 的可用磁盘空间,该/​home文件系统-小于 **20**% 的可用磁盘空间或,/​tmp的文件系统-小于**50**%的可用磁盘空间 。
  
 <note important>​LLD macros are not supported inside of user macro contexts in [[manual:​config:​triggers:​expression#​function_parameters|trigger function parameters]].</​note>​ <note important>​LLD macros are not supported inside of user macro contexts in [[manual:​config:​triggers:​expression#​function_parameters|trigger function parameters]].</​note>​
 +
 +<note important>​[[manual:​config:​triggers:​expression#​function_parameters|触发功能参数]]中的用户宏上下文内不支持LLD宏。</​note>​