Server端配置Zabbix_Java_Gateway
Zabbix Server 需要java环境这里不再详述

sudo apt-get install zabbix-java-gateway
* 测试gateway是否安装成功
sudo service zabbix-java-gateway status
* 修改zabbix-java-gateway配置
sudo vim /etc/zabbix/zabbix_java_gateway.conf

监听地址
LISTEN_IP="0.0.0.0"
监听端口
LISTEN_PORT=10052
PID_FILE文件
PID_FILE="/var/run/zabbix/zabbix_java_gateway.pid"
开启的工作线程 默认5
START_POLLERS=5
启动zabbix-java-gateway
service zabbix-java-gateway start

* 修改zabbix-server的配置
sudo vim /etc/zabbix/zabbix_server.conf

JavaGateway的服务器IP地址
JavaGateway=10.0.0.254
JavaGateway的服务端口
JavaGatewayPort=10052
从javagateway采集数据的进程数
StartJavaPollers=5

客户端Tomcat配置

* 编辑catalina.sh 加入如下配置
sudo vim /usr/local/tomcat/bin/catalina.sh
CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote  # 开启远程监控
-Dcom.sun.management.jmxremote.port=12345 # 监控端口
-Dcom.sun.management.jmxremote.ssl=false #远程ssl验证fales
-Dcom.sun.management.jmxremote.authenticate=false #关闭权限验证
-Djava.rmi.server.hostname=1.1.1.1" # tomcat #主机地址
CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=12345
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
-Djava.rmi.server.hostname=1.1.1.1"

重新启动tomcat

* 验证jmx是否监听成功
lsof -i :12345
COMMAND   PID USER   FD   TYPE    DEVICE SIZE/OFF NODE NAME
java    31363 root   20u  IPv6 868552675      0t0  TCP *:12345 (LISTEN
* Server端测试能否采集信息

下载cmdline-jmxclient-0.10.3.jar包采集数据
http://crawler.archive.org/cmdline-jmxclient/downloads.html

本地执行 查看非堆内存使用

java -jar cmdline-jmxclient-0.10.3.jar - 1.1.1.1:12345 java.lang:type=Memory NonHeapMemoryUsage 
04/12/2018 09:57:03 +0000 org.archive.jmx.Client NonHeapMemoryUsage:
committed: 71761920
init: 2555904
max: -1
used: 68962976
* 监控数据采集

1)堆内存

查看堆内存信息

java -jar cmdline-jmxclient-0.10.3.jar controlRole:tomcat 1.1.1.1:12345 java.lang:type=Memory HeapMemoryUsage

04/12/2018 10:17:46 +0000 org.archive.jmx.Client HeapMemoryUsage:
committed: 1785200640
init: 1073741824
max: 3042443264
used: 639319848

zabbix监控堆内存键值

堆内最大值存: jmx["java.lang:type=Memory","HeapMemoryUsage.max"]
已用堆内存: jmx["java.lang:type=Memory","HeapMemoryUsage.used"]
已提交堆内存: jmx["java.lang:type=Memory","HeapMemoryUsage.committed"]

2)内存池eden space

查看eden space

java -jar cmdline-jmxclient-0.10.3.jar - 1.1.1.1:12345 java.lang:type=MemoryPool,name=PS\ Eden\ Space Usage

04/12/2018 10:24:29 +0000 org.archive.jmx.Client Usage:
committed: 530055168
init: 402653184
max: 530055168
used: 185557424

zabbix 监控eden区域键值

最大空间: jmx["java.lang:type=MemoryPool,name=PS Eden Space",Usage.max]
已用空间: jmx["java.lang:type=MemoryPool,name=PS Eden Space",Usage.used]
提交空间: jmx["java.lang:type=MemoryPool,name=PS Eden Space",Usage.committed]

3)内存池survivorspace

查看Survivor space区域

java -jar cmdline-jmxclient-0.10.3.jar - 1.1.1.1:12345 java.lang:type=MemoryPool,name=PS\ Survivor\ Space Usage

zabbix监控Survivor键值

jmx["java.lang:type=MemoryPool,name=PS Survivor Space",Usage.committed]
jmx["java.lang:type=MemoryPool,name=PS Survivor Space",Usage.max]
jmx["java.lang:type=MemoryPool,name=PS Survivor Space",Usage.used]

4)内存池old gen

查看 old gen 区域使用

java -jar cmdline-jmxclient-0.10.3.jar - 1.1.1.1:12345 java.lang:name=PS\ Old\ Gen,type=MemoryPool Usage

zabbix监控old gen键值

jmx["java.lang:type=MemoryPool,name=PS Old Gen",Usage.committed]
jmx["java.lang:type=MemoryPool,name=PS Old Gen",Usage.max]
jmx["java.lang:type=MemoryPool,name=PS Old Gen",Usage.used]

5)非堆内存

查看非堆内存

java -jar cmdline-jmxclient-0.10.3.jar - 1.1.1.1:12345 java.lang:type=Memory NonHeapMemoryUsage

zabbix监控非堆内存键值

jmx["java.lang:type=Memory","NonHeapMemoryUsag.committed"]
jmx["java.lang:type=Memory","NonHeapMemoryUsag.used"]

6)内存池meta space

查看meta space 区域使用

java -jar cmdline-jmxclient-0.10.3.jar - 1.1.1.1:12345  java.lang:type=MemoryPool,name=Metaspace Usage

zabbix监控meta space区域键值

jmx["java.lang:type=MemoryPool,name=Metaspace",Usage.committed]
jmx["java.lang:type=MemoryPool,name=Metaspace",Usage.used]

7)内存池code cache

查看codec achce 区域

java -jar cmdline-jmxclient-0.10.3.jar - 1.1.1.1:12345  java.lang:type=MemoryPool,name=Code\ Cache Usage

zabbix监控code cache键值

jmx["java.lang:type=MemoryPool,name=Code Cache",Usage.committed]
jmx["java.lang:type=MemoryPool,name=Code Cache",Usage.max]
jmx["java.lang:type=MemoryPool,name=Code Cache",Usage.used]

8)内存池ccompressed class space

查看compressed class space 区域

java -jar cmdline-jmxclient-0.10.3.jar - 1.1.1.1:12345  java.lang:type=MemoryPool,name=Compressed\ Class\ Space Usage

zabbix 监控compressed class sapce 键值

jmx["java.lang:type=MemoryPool,name=Compressed Class Space",Usage.committed]
jmx["java.lang:type=MemoryPool,name=Compressed Class Space",Usage.max]
jmx["java.lang:type=MemoryPool,name=Compressed Class Space",Usage.used]

9)类加载

查看类加载信息

加载总数:

java -jar cmdline-jmxclient-0.10.3.jar - 1.1.1.1:12345  java.lang:type=ClassLoading TotalLoadedClassCount

已加载:

java -jar cmdline-jmxclient-0.10.3.jar - 1.1.1.1:12345  java.lang:type=ClassLoading  LoadedClassCount

已卸载:

java -jar cmdline-jmxclient-0.10.3.jar - 1.1.1.1:12345  java.lang:type=ClassLoading  UnloadedClassCount

zabbix监控类加载键值

加载总数: jmx["java.lang:type=ClassLoading","TotalLoadedClassCount"]
已加载: jmx["java.lang:type=ClassLoading","LoadedClassCount"]
已卸载: jmx["java.lang:type=ClassLoading","UnloadedClassCount"]

10)java线程

查看java线程

总开启线程:

java -jar cmdline-jmxclient-0.10.3.jar controlRole:tomcat 1.1.1.1:12345 java.lang:type=Threading TotalStartedThreadCount

活动线程:

java -jar cmdline-jmxclient-0.10.3.jar controlRole:tomcat 1.1.1.1:12345 java.lang:type=Threading PeakThreadCount

线程峰值:

java -jar cmdline-jmxclient-0.10.3.jar controlRole:tomcat 1.1.1.1:12345 java.lang:type=Threading PeakThreadCount

zabbix 监控java线程键值

总开启线程: jmx["java.lang:type=Threading","TotalStartedThreadCount"]
活动线程: jmx["java.lang:type=Threading","ThreadCount"]
线程峰值: jmx["java.lang:type=Threading","PeakThreadCount"]

11)tomcat线程

查看tomcat 线程

最大线程:

java -jar cmdline-jmxclient-0.10.3.jar -1.1.1.1:12345 Catalina:name=\"http-nio-18080\",type=ThreadPool maxThreads

当前线程:

java -jar cmdline-jmxclient-0.10.3.jar - 1.1.1.1:12345 Catalina:name=\"http-nio-18080\",type=ThreadPool currentThreadCount

繁忙线程:

java -jar cmdline-jmxclient-0.10.3.jar - 1.1.1.1:12345 Catalina:name=\"http-nio-18080\",type=ThreadPool currentThreadsBusy

zabbix监控tomcat 线程键值

最大线程:jmx["Catalina:type=ThreadPool,name="http-nio-8080"",maxThreads]
当前线程:jmx["Catalina:type=ThreadPool,name="http-nio-8080"",currentThreadCount]
繁忙线程 jmx["Catalina:type=ThreadPool,name="http-nio-8080"",currentThreadsBusy]

12)tomcat请求

查看tomcat请求

tomcat请求数:

java -jar cmdline-jmxclient-0.10.3.jar - 1.1.1.1:12345 Catalina:name=\"http-nio-18080\",type=GlobalRequestProcessor requestCount

tomcat出错请求:

java -jar cmdline-jmxclient-0.10.3.jar - 1.1.1.1:12345 Catalina:name=\"http-nio-18080\",type=GlobalRequestProcessor errorCount

zabbix 监控tomcat请求键值

tomcat请求数: jmx["Catalina:type=GlobalRequestProcessor,name="http-nio-8080"",requestCount]
tomcat出错请求: jmx["Catalina:type=GlobalRequestProcessor,name="http-nio-8080"",errorCount]

13)网络流量

查看网络流量

接收的字节:

java -jar cmdline-jmxclient-0.10.3.jar - 1.1.1.1:12345 Catalina:name=\"http-nio-18080\",type=GlobalRequestProcessor bytesReceived

发送的字节:

java -jar cmdline-jmxclient-0.10.3.jar -1.1.1.1:12345 Catalina:name=\"http-nio-18080\",type=GlobalRequestProcessor bytesSent

zabbix监控tomcat网络流量键值

接收的字节:jmx["Catalina:type=GlobalRequestProcessor,name="http-nio-18080"",bytesReceived]
发送的字节:jmx["Catalina:type=GlobalRequestProcessor,name="http-nio-18080"",bytesSent]