en	# 21 Extensions
zh-cn	# 20. 扩展

en	#### Overview Although Zabbix offers a multiplicity of features, there is always room for additional functionality. Extensions are a convenient way of modifying and enhancing the monitoring capabilities of Zabbix without changing its source code. You can extend Zabbix functionality either by using built-in extension options (trapper items, user parameters, etc.) or by using or creating custom extensions (loadable modules, plugins, etc.). This section provides an overview with references to all the options for extending Zabbix.
zh-cn	#### 概述 尽管 Zabbix 提供了多种功能，但总可以扩展添加更多功能。扩展是一种方便的方式，可以在不更改其源代码的情况下修改和增强 Zabbix 的监控功能。 您可以通过使用内置扩展选项（捕获器监控项、用户参数等）或使用或创建自定义扩展（可加载模块、插件等）来扩展 Zabbix 功能。 本节概述了用于扩展 Zabbix 的所有选项。

en	#### Data collection with custom commands
zh-cn	#### 使用自定义命令进行数据收集

en	##### Trapper items [Trapper items](/manual/config/items/itemtypes/trapper) are items that accept incoming data instead of querying for it. Trapper items are useful for sending specific data to Zabbix server or proxy, for example, periodic availability and performance data in the case of long-running user scripts. Sending data to Zabbix server or proxy is possible using the [Zabbix sender](/manual/concepts/sender) utility or Zabbix sender [protocol](/manual/appendix/protocols/zabbix_sender). Sending data to Zabbix server is also possible using the [`history.push`](/manual/api/reference/history/push) API method.
zh-cn	##### 捕获器监控项 [Trapper items捕获器监控项](/manual/config/items/itemtypes/trapper) 是接受传入数据而不是查询数据的监控项。捕获器监控项可用于将特定数据发送到 Zabbix server/proxy，例如，在长时间运行的用户脚本的情况下，定期发送可用性和性能数据。您可以使用[Zabbix sender](/manual/concepts/sender)命令行实用程序或自己实现基于 JSON 的[通信协议](/manual/appendix/protocols/zabbix_sender).（类似于 Zabbix 发送器中使用的协议）来执行此[`history.push`](/manual/api/reference/history/push)操作。

en	##### External checks An [external check](/manual/config/items/itemtypes/external) is an item for executing checks by running an executable, for example, a [shell script](/manual/appendix/command_execution) or a binary. External checks are executed by Zabbix server or proxy (when host is monitored by proxy), and do not require an agent running on the host being monitored.
zh-cn	##### 外部检查 [外部检查](/manual/config/items/itemtypes/external) 是通过运行可执行文件（例如shell 脚本或二进制文件）来执行检查的监控项。 外部检查由 Zabbix server或proxy（当主机通过proxy监控时）执行，不需要在被监控的主机上运行agent。

en	##### User parameters A [user parameter](/manual/config/items/userparameters) is a user-defined command (associated with a user-defined key) that, when executed, can retrieve the data you need from the host where Zabbix agent is running. User parameters are useful for configuring agent or agent 2 items that are not predefined in Zabbix.
zh-cn	##### 用户参数 [用户参数](/manual/config/items/userparameters) 是用户定义的命令（与用户定义的键相关联），执行后可以从运行 Zabbix agent的主机检索所需的数据。用户参数对于配置 Zabbix 中未预定义的agent或agent2 监控项很有用。

en	##### `system.run[]` Zabbix agent items `system.run[]` Zabbix [agent item](/manual/config/items/itemtypes/zabbix_agent#system.run) is an item for a user-defined command (associated with a predefined key `system.run[]`, for example, `system.run[myscript.sh]`) that can be executed on the host where Zabbix agent is running. Note: `system.run[]` items are disabled by default and, if used, must be enabled ([allowed](/manual/config/items/restrict_checks)) and defined in the Zabbix agent or agent 2 configuration file (`AllowKey` configuration parameter).
zh-cn	##### `system.run[]` Zabbix agent 监控项 `system.run[]` Zabbix [agent item](/manual/config/items/itemtypes/zabbix_agent#system-data)是用户定义命令的监控项（与预定义键相关联`system.run[]`，例如`system.run[myscript.sh]`），可以在运行 Zabbix 代理的主机上执行。 注意：`system.run[]`默认情况下，监控项是禁用的，如果使用，则必须启用([允许](/manual/config/items/restrict_checks))并在 Zabbix agent或agent2 配置文件中定义(AllowKey`配置参数)

en	::: noteimportant User-defined commands in items such as external checks, user parameters and `system.run[]` Zabbix agent items are executed from the OS user that is used to run Zabbix components. To execute these commands, this user must have the necessary permissions. :::
zh-cn	::: noteimportant 外部检查、用户参数和 Zabbix agent 监控项等监控项中的用户定义命令`system.run[]` 均由用于运行 Zabbix 组件的 OS 用户执行。要执行这些命令，此用户必须具有必要的权限。 :::

en	##### HTTP agent items [HTTP agent](/manual/config/items/itemtypes/http) item is an item for executing data requests over HTTP/HTTPS. HTTP agent items are useful for sending requests to HTTP endpoints to retrieve data from services such as *Elasticsearch* and *OpenWeatherMap*, for checking the status of Zabbix API or the status of Apache or Nginx web server, etc. HTTP agent items (with trapping enabled) can also function as [trapper items](#trapper-items).
zh-cn	##### HTTP agent 监控项 [HTTP agent](/manual/config/items/itemtypes/http)是通过 HTTP/HTTPS 执行数据请求的项。HTTP agent 监控项可用于向 HTTP 端点发送请求以从*Elasticsearch* 和 *OpenWeatherMap*等服务检索数据，用于检查 Zabbix API 的状态或 Apache 或 Nginx Web 服务器的状态等。HTTP 代理项（启用了捕获器功能）也可以用作[trapper items捕获器监控项](#trapper-items)。

en	##### Script items A [script item](/manual/config/items/itemtypes/script) is an item for executing user-defined JavaScript code that retrieves data over HTTP/HTTPS. Script items are useful when the functionality provided by HTTP agent items is not enough. For example, in demanding data collection scenarios that require multiple steps or complex logic, a script item can be configured to make an HTTP call, then process the data received, and then pass the transformed value to a second HTTP call.
zh-cn	##### 脚本监控项 [脚本监控项](/manual/config/items/itemtypes/script)是用于执行用户定义的 JavaScript 代码的项，该代码通过 HTTP/HTTPS 检索数据。当 HTTP 代理项提供的功能不够时，脚本项非常有用。例如，在需要多个步骤或复杂逻辑的苛刻数据收集场景中，可以配置脚本项以进行 HTTP 调用，然后处理收到的数据，然后将转换后的值传递给第二个 HTTP 调

en	::: notetip HTTP agent items and script items are supported by Zabbix server and proxy, and do not require an agent running on the host being monitored. :::
zh-cn	::: notetip Zabbix server和proxy支持 HTTP agent和脚本监控项，并且不需要在被监控的主机上运行agent。 :::

en	#### Advanced extensions
zh-cn	#### 高级扩展

en	##### Loadable modules [Loadable modules](/manual/extensions/loadablemodules), written in C, are a versatile and performance-minded option for extending the functionality of Zabbix components (server, proxy, agent) on UNIX platforms. A loadable module is basically a shared library used by Zabbix daemon and loaded on startup. The library should contain certain functions, so that a Zabbix process may detect that the file is indeed a module it can load and work with. Loadable modules have a number of benefits, including the ability to add new metrics or implement any other logic (for example, Zabbix [history data export](/manual/extensions/loadablemodules#providing-history-export-callbacks)), great performance, and the option to develop, use and share the functionality they provide. It contributes to trouble-free maintenance and helps to deliver new functionality easier and independently of the Zabbix core code base. Loadable modules are especially useful in a complex monitoring setup. When monitoring embedded systems, having a large number of monitored parameters or heavy scripts with complex logic or long startup time, extensions such as user parameters, `system.run[]` Zabbix agent items, and external checks will have an impact on performance. Loadable modules offer a way of extending Zabbix functionality without sacrificing performance.
zh-cn	##### 可加载模块 [可加载模块](/manual/extensions/loadablemodules), 用C语言编写, 是一种多功能且注重性能的选项，用于扩展 UNIX 平台上 Zabbix 组件 (server, proxy, agent)的功能。加载模块基本上是 Zabbix 守护程序使用的共享库，并在启动时加载。该库应包含某些函数，以便 Zabbix 进程可以检测到该文件确实是它可以加载和使用的模块。 可加载模块具有许多优点，包括能够添加新指标或实现任何其他逻辑 (例如，Zabbix [历史数据导出](/manual/extensions/loadablemodules#providing-history-export-callbacks)),出色的性能以及开发、使用和共享其提供的功能的选项。它有助于无故障维护，并有助于更轻松地独立于 Zabbix 核心代码库提供新功能。 可加载模块在复杂的监控设置中特别有用。当监控嵌入式系统时，如果有大量监控参数或逻辑复杂或启动时间较长的繁重脚本，用户参数、 `system.run[]` Zabbix 代理项和外部检查等扩展将对性能产生影响。可加载模块提供了一种在不牺牲性能的情况下扩展 Zabbix 功能的方法。

en	##### Plugins Plugins extend the monitoring capabilities of Zabbix agent 2. Written in the Go programming language, they provide an alternative to loadable modules (written in C). A plugin is a Go package that defines the structure and implements one or several plugin interfaces (*Exporter*, *Collector*, *Configurator*, *Runner*, *Watcher*). Two types of Zabbix agent 2 plugins are supported: - [Built-in plugins](https://www.zabbix.com/documentation/guidelines/en/plugins/built_in_plugins) (supported since Zabbix 4.4.0) - [Loadable plugins](https://www.zabbix.com/documentation/guidelines/en/plugins/loadable_plugins) (supported since Zabbix 6.0.0) See the list of [plugins](/manual/extensions/plugins#built-in-plugins) provided by Zabbix. For instructions and tutorials on creating your own plugins, see [Developer center](/devel/plugins).
zh-cn	##### 插件 [插件](/manual/extensions/plugins)提供了可加载模块（用 C 编写）的替代方案。但是，插件仅是一种扩展 Zabbix agent 2 的方法。 插件是一个*Go*包，它定义结构并实现一个或多个插件接口(*Exporter*, *Collector*, *Configurator*, *Runner*, *Watcher*)。支持两种类型的 Zabbix agent 2 插件： - [内置插件](https://www.zabbix.com/documentation/guidelines/en/plugins/built_in_plugins) (自 Zabbix 4.4.0 起支持) - [可加载插件](https://www.zabbix.com/documentation/guidelines/en/plugins/loadable_plugins) (自 Zabbix 6.0.0 起支持) 查看[内置插件](/manual/extensions/plugins#built-in)列表。 有关编写自己的插件的说明和教程，请参阅[开发者中心](/devel/plugins)。

en	#### Alert customization
zh-cn	#### 自定义警报

en	##### Webhooks A [webhook](/manual/config/notifications/media/webhook) is a Zabbix [media type](/manual/config/notifications/media) that provides an option to extend Zabbix alerting capabilities to external software such as helpdesk systems, chats, or messengers. Similarly to script items, webhooks are useful for making HTTP calls using custom JavaScript code, for example, to push notifications to different platforms such as Microsoft Teams, Discord, and Jira. It is also possible to return some data (for example, about created helpdesk tickets) that is then displayed in Zabbix. Existing webhooks are available in the Zabbix [Git repository](https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/media?at=refs%2Fheads%2Frelease%2F7.4). For custom webhook development, see [Webhook development guidelines](https://www.zabbix.com/documentation/guidelines/en/webhooks).
zh-cn	##### Webhooks [Webhook](/manual/config/notifications/media/webhook)是一种 Zabbix[媒体类型](/manual/config/notifications/media)，它提供了一种将 Zabbix 警报功能扩展到外部软件（例如帮助台系统、聊天或 Messenger ）的选项。与脚本项类似，Webhook 可用于使用自定义 JavaScript 代码进行 HTTP 调用，例如，将通知推送到不同的平台（例如 Microsoft Teams、Discord 和 Jira）。它还可以返回一些数据（例如，有关创建的帮助台工单的数据），然后这些数据会显示在 Zabbix 中 现有 webhook 可在 Zabbix [Git 代码库](https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/media)中找到。有关自定义 webhook 开发，请参阅[Webhook 开发指南](https://www.zabbix.com/documentation/guidelines/en/webhooks).。

en	##### Alert scripts An [alert script](/manual/config/notifications/media/script) is a Zabbix [media type](/manual/config/notifications/media) that provides an option to create an alternative way (script) to handle Zabbix alerts. Alert scripts are useful if you are not satisfied with the existing media types for sending alerts in Zabbix.
zh-cn	##### 警报脚本 [警报脚本](/manual/config/notifications/media/script)是一种 Zabbix[媒体类型](/manual/config/notifications/media)，它提供了创建替代方法（脚本）来处理 Zabbix 警报的选项。如果您对 Zabbix 中现有的发送警报的媒体类型不满意，警报脚本会很有用

en	#### Frontend customization
zh-cn	#### 前端自定义

en	##### Custom themes It is possible to change Zabbix frontend visual appearance by using custom themes. See the [instructions](/manual/web_interface/theming) on creating and applying your own themes.
zh-cn	##### 自定义主题 可以使用自定义主题来更改 Zabbix 前端的外观。请参阅有关创建和应用您自己的主题的[说明](/manual/web_interface/theming)。

en	##### Frontend modules [Frontend modules](/manual/extensions/frontendmodules) provide an option to extend Zabbix frontend functionality by adding third-party modules or by developing your own. With frontend modules you can add new menu items, their respective views, actions, etc.
zh-cn	##### 前端模块 [前端模块](/manual/extensions/frontendmodules)提供了通过添加第三方模块或开发您自己的模块来扩展 Zabbix 前端功能的选项。使用前端模块，您可以添加新的菜单项、它们各自的视图、操作等。

en	#### Global scripts A [global script](/manual/web_interface/frontend_sections/alerts/scripts) is a user-defined set of commands that can be executed on a monitoring target (by shell (/bin/sh) interpreter), depending on the configured scope and user permissions. Global scripts can be configured for the following actions: - Action [operation](/manual/config/notifications/action/operation) - [Manual host action](/manual/web_interface/menu/host_menu#overview) - [Manual event action](/manual/web_interface/menu/event_menu#content) Global scripts are useful in many cases. For example, if configured for action operations or manual host actions, you can use global scripts to automatically or manually execute [remote commands](/manual/config/notifications/action/operation/remote_command) such as restarting an application (web server, middleware, CRM, etc.) or freeing disk space (removing older files, cleaning `/tmp`, etc). Or, another example, if configured for manual event actions, you can use global scripts to manage problem tickets in external systems. Global scripts can be executed by Zabbix server, proxy or agent.
zh-cn	#### 全局脚本 [全局脚本](/manual/web_interface/frontend_sections/alerts/scripts)是用户定义的一组命令，可根据配置的范围和用户权限在监控目标上执行（通过 shell (/bin/sh) 解释器）。可以配置全局脚本以执行以下操作： - 动作 [操作](/manual/config/notifications/action/operation) - [手动主机动作](/manual/web_interface/menu/host_menu#overview) - [手动事件动作](/manual/web_interface/menu/event_menu#content) 全局脚本在许多情况下都很有用。例如，如果配置为操作或手动主机操作，则可以使用全局脚本自动或手动执行远程命令，例如重新启动应用程序（Web 服务器、中间件、CRM 等）或释放磁盘空间（删除旧文件、清理/tmp目录等）。或者，另一个示例，如果配置为手动事件操作，则可以使用全局脚本来管理外部系统中的问题单。 全局脚本可以由 Zabbix server、proxy或agent程序执行。

en	::: noteimportant User-defined commands are executed from the OS user that is used to run Zabbix components. To execute these commands, this user must have the necessary permissions. :::
zh-cn	::: noteimportant 用户定义的命令由运行 Zabbix 组件的 OS 用户执行。要执行这些命令，该用户必须具有必要的权限。 :::

en	#### Zabbix API [Zabbix API](/manual/api) is an HTTP-based API that is part of Zabbix frontend. With Zabbix API, you can do any of the following operations: - Programmatically retrieve and modify the configuration of Zabbix. - Import and export Zabbix configuration. - Access Zabbix historical and trend data. - Configure applications to work with Zabbix. - Integrate Zabbix with third-party software. - Automate routine tasks. Zabbix API consists of a multiplicity of methods that are nominally grouped into separate APIs. Each method performs a specific task. For the available methods, as well as an overview of the functions provided by Zabbix API, see Zabbix API [Method reference](/manual/api/reference).
zh-cn	#### Zabbix API [Zabbix API](/manual/api)是基于 HTTP 的 API，是 Zabbix 前端的一部分。使用 Zabbix API，您可以执行以下任何操作： - Automate routine tasks. - 以编程方式检索和修改 Zabbix 的配置。 - 导入和导出 Zabbix 配置。 - 访问 Zabbix 历史和趋势数据。 - 配置应用程序以与 Zabbix 配合使用。 - 将 Zabbix 与第三方软件集成。 - 自动执行日常任务。 see Zabbix API [Method reference](/manual/api/reference). Zabbix API 包含多种方法，这些方法名义上被分组到单独的 API 中。每种方法执行特定任务。有关可用方法以及 Zabbix API 提供的功能的概述，请参阅 Zabbix API[方法参考](/manual/api/reference)。