这是原厂英文文档的翻译页面. 欢迎帮助我们 完善文档.
2022 Zabbix中国峰会
2022 Zabbix中国峰会

5 Java gateway

概述

从 Zabbix 2.0 开始,以 Zabbix 守护进程方式原生支持监控 JMX 应用程序就存在了,称之为“Zabbix Java gateway”。Zabbix Java gateway 的守护进程是用 Java 编写。为了在特定主机上找到 JMX 计数器的值,Zabbix server 向 Zabbix Java gateway 发送请求,后者使用 JMX 管理 API 来远程查询相关的应用。该应用不需要安装额外的软件。只需要在启动时,命令行添加-Dcom.sun.management.jmxremote选项即可。

Java gateway 接受来自 Zabbix server 或 Zabbix proxy 的传入连接,并且只能用作“被动 proxy”。与 Zabbix proxy 相反,它也可以从 Zabbix proxy (Zabbix proxy 不能被链接)调用。在 Zabbix server 或 Zabbix proxy 配置文件中,可以直接配置每个 Java gateway 的访问,因此每个 Zabbix server 或 Zabbix proxy 只能配置一个 Java gateway。如果主机将有 JMX agent 或其他类型的监控项,则只将 JMX agent 监控项传递给 Java gateway 进行检索。

当必须通过 Java gateway 更新监控项时,Zabbix server 或 proxy 将连接到 Java gateway 并请求该值,Java gateway 将检索该值并将其传递回 Zabbix server 或 Zabbix proxy。 因此,Java gateway 不会缓存任何值。

Zabbix server 或 Zabbix proxy 具有连接到 Java gateway 的特定类型的进程,由 StartJavaPollers 选项控制。在内部,Java gateway 启动多个线程,由 START_POLLERS 选项控制。 在服务器端,如果连接超过 Timeout 选项配置的秒数,它将被终止,但 Java gateway 可能仍在忙于从 JMX 计数器检索值。 为了解决这个问题,从 Zabbix 2.0.15、Zabbix 2.2.10 和 Zabbix 2.4.5 开始,Java gateway 中有 TIMEOUT 选项,允许为 JMX 网络操作设置超时。

Zabbix server 或 proxy 尝试尽可能地将请求汇集到单个 JMX 目标(受监控项取值间隔影响),并在单个连接中将它们发送到 Java Gateway 以获得更好的性能。

此外,建议让 StartJavaPollers 选项的值小于或等于 START_POLLERS,否则可能会出现 Java gateway 中没有可用线程来为传入请求提供服务的情况。

以下部分描述了如何获取和运行Zabbix Java gateway,如何配置 Zabbix server(或 Zabbix proxy)来使用 Zabbix Java gateway 进行 JMX 监控,以及如何在 Zabbix GUI 中配置与特定 JMX 计数器对应的 Zabbix 监控项。

When an item has to be updated over Java gateway, Zabbix server or proxy will connect to the Java gateway and request the value, which Java gateway in turn retrieves and passes back to the server or proxy. As such, Java gateway does not cache any values.

Zabbix server or proxy has a specific type of processes that connect to Java gateway, controlled by the option StartJavaPollers. Internally, Java gateway starts multiple threads, controlled by the START_POLLERS option. On the server side, if a connection takes more than Timeout seconds, it will be terminated, but Java gateway might still be busy retrieving value from the JMX counter. To solve this, there is the TIMEOUT option in Java gateway that allows to set timeout for JMX network operations.

Zabbix server or proxy will try to pool requests to a single JMX target together as much as possible (affected by item intervals) and send them to the Java gateway in a single connection for better performance.

It is suggested to have StartJavaPollers less than or equal to START_POLLERS, otherwise there might be situations when no threads are available in the Java gateway to service incoming requests; in such a case Java gateway uses ThreadPoolExecutor.CallerRunsPolicy, meaning that the main thread will service the incoming request and temporarilylabel will not accept any new requests.

If you are trying to monitor Wildfly-based Java applications with Zabbix Java gateway, please install the latest jboss-client.jar available on the Wildfly download page.

获取java网关

您可以从源代码或从下载的包中安装Java网关 Zabbix website.

使用下面的链接,您可以访问以下信息:如何获取和运行Zabbix java网关,如何配置Zabbix server(或Zabbix proxy)以使用Zabbix Java 网关进行JMX监控,以及如何在Zabbix前端配置对应于特定JMX计数器的Zabbix监控项。

安装途径 安装说明 配置步骤说明
Sources 安装 配置
RHEL packages 安装 配置
Debian/Ubuntu packages 安装 配置