1.
zabbix 服务端安装,监控jmx 需要--enable-java
zabbix 客户端不需要 --enable-java
2.zabbix_server端安装jdk
安装jdk
[root@nginx tmp]# tar xf jdk-7u9-linux-x64.tar.gz -C /usr/local/
[root@nginx tmp]# ls /usr/local/jdk1.7.0_09/
bin jre README.html THIRDPARTYLICENSEREADME.txt
COPYRIGHT lib release
db LICENSE src.zip
include man THIRDPARTYLICENSEREADME-JAVAFX.txt
3.修改zabbix_java相关选项
然后进入到下面的目录下面进行seeting.sh脚本编辑
zabbix:/usr/local/sbin/zabbix_java# pwd
/usr/local/sbin/zabbix_java
zabbix:/usr/local/sbin/zabbix_java# chmod +x settings.sh
zabbix:/usr/local/sbin/zabbix_java# ls
bin lib settings.sh shutdown.sh startup.sh
LISTEN_IP="0.0.0.0"
LISTEN_PORT=10052
PID_FILE="/tmp/zabbix_java.pid"
START_POLLERS=5
zabbix:/usr/local/sbin/zabbix_java# ./startup.sh
-------------------
5
zabbix:/usr/local/sbin/zabbix_java# cat startup.sh
#!/bin/bash
cd $(dirname $0)
source settings.sh
echo "-------------------"
echo $START_POLLERS
其中 LISTEN_PORT 和 LISTEN_IP 可以不配置,zabbix_java 会采用默认值。但是 PID_FILE 和 START_POLLERS 必须配置,尤其主意 START_POLLERS,若不配置 zabbix_java 依旧可以启动但是是不工作的。
[root@nginx zabbix_java]#
4.修改配置选项:在zabbix服务端上配置
/etc/zabbix/zabbix_server.conf
添加:
JavaGateway=127.0.0.1 ##这个地址是服务端的地址
JavaGatewayPort=10052
StartJavaPollers=5
zabbix:/usr/local/sbin/zabbix_java# netstat -nap | grep 10052
tcp 0 0 127.0.0.1:54229 127.0.0.1:10052 TIME_WAIT -
tcp 0 0 127.0.0.1:53891 127.0.0.1:10052 TIME_WAIT -
tcp 0 0 :::10052 :::* LISTEN 15763/java
tcp 0 0 ::ffff:127.0.0.1:10052 ::ffff:127.0.0.1:54499 TIME_WAIT -
tcp 0 0 ::ffff:127.0.0.1:10052 ::ffff:127.0.0.1:54149 TIME_WAIT -
tcp 0 0 ::ffff:127.0.0.1:10052 ::ffff:127.0.0.1:54128 TIME_WAIT -
tcp 0 0 ::ffff:127.0.0.1:10052 ::ffff:127.0.0.1:53930 TIME_WAIT -
tcp 0 0 ::ffff:127.0.0.1:10052 ::ffff:127.0.0.1:54207 TIME_WAIT -
tcp 0 0 ::ffff:127.0.0.1:10052 ::ffff:127.0.0.1:53610 TIME_WAIT -
tcp 0 0 ::ffff:127.0.0.1:10052 ::ffff:127.0.0.1:53641 TIME_WAIT -
tcp 0 0 ::ffff:127.0.0.1:10052 ::ffff:127.0.0.1:53590 TIME_WAIT -
tcp 0 0 ::ffff:127.0.0.1:10052 ::ffff:127.0.0.1:54184 TIME_WAIT -
zabbix:/usr/local/sbin/zabbix_java# ps -ef | grep 15763
root 15763 1 3 09:38 pts/0 00:00:01 java -server -classpath lib:lib/logback-classic-0.9.27.jar:lib/logback-core-0.9.27.jar:lib/org-json-2010-12-28.jar:lib/slf4j-api-1.6.1.jar:bin/zabbix-java-gateway-2.2.2.jar
-Dzabbix.pidFile=/tmp/zabbix_java.pid -Dzabbix.listenIP=0.0.0.0 -Dzabbix.listenPort=10052 -Dzabbix.startPollers=5 com.zabbix.gateway.JavaGateway
root 15804 14315 0 09:39 pts/0 00:00:00 grep 15763
5.启动zabbix_java
找到zabbix_java目录路径,然后执行命令./startup.sh
[root@nginx zabbix-2.2.0]# find / -name zabbix_java
/usr/local/sbin/zabbix_java
tomcat 端配置:
6.调整tomcat端,安装catalina-jmx-remote.jar
wget http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.8/bin/extras/catalina-jmx-remote.jar
[tomcat@wx01 lib]$ mv /home/tomcat/catalina-jmx-remote.jar .
[tomcat@wx01 lib]$ ls -ltr catalina-jmx-remote.jar
-rw-rw-r-- 1 tomcat tomcat 9533 Feb 5 2011 catalina-jmx-remote.jar
7.修改catalina.sh文件
修改catalina.sh文件,添加
# -----------------------------------------------------------------------------
JAVA_OPTS='-Xms8192m -Xmx8192m'
export JAVA_HOME=/usr/java/jdk1.8.0_20
CATALINA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=10085"
10085端口自定义,自定义端口号
[tomcat@wx01 bin]$ netstat -na | grep 10085
tcp 0 0 0.0.0.0:10085 0.0.0.0:* LISTEN
8.重启启动tomcat服务和zabbix_agentd服务
9.zabbix服务器端测试是否能正常获取信息
zabbix:/root# java -jar /root/cmdline-jmxclient-0.10.3.jar - 120.55.118.32:5566 java.lang:type=Memory NonHeapMemoryUsage
10/27/2016 15:23:08 +0800 org.archive.jmx.Client NonHeapMemoryUsage:
committed: 83623936
init: 2555904
max: -1
used: 81181776
zabbix:/root# java -jar /root/cmdline-jmxclient-0.10.3.jar - 192.168.11.187:10085 java.lang:type=Memory NonHeapMemoryUsage
10/27/2016 15:23:37 +0800 org.archive.jmx.Client NonHeapMemoryUsage:
committed: 25231360
init: 2555904
max: -1
used: 24549416