第一步:需要安装jdk
1.# tar xvf jdk-7u21-linux-x64.tar.gz -C /usr/localource /etc/bashrc
2.# ln -s /usr/local/jdk1.7.0_21 /usr/local/jdk
3.# echo 'JAVA_HOME=/usr/local/jdk' >> /etc/bashrc
4.# echo 'PATH=$PATH:${JAVA_HOME}/bin/' >> /etc/bashrc
5.# echo 'CLASSPATH=.:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar ' >> /etc/bashrc
5.# echo 'export JAVA_HOME PATH CLASSPATH' >> /etc/bashrc
6.# source /etc/bashrc
第二步:安装zabbix java
1.# tar xvf zabbix-2.0.6.tar.gz
2.# cd zabbix-2.0.6
3.# ./configure --prefix=/usr/local/zabbix_java_gateway-2.0.6 --enable-java
4.# make && make install
5.# ln -s /usr/local/zabbix_java_gateway-2.0.6 /usr/local/zabbix_java_gateway
6.# test -d /etc/zabbix || mkdir /etc/zabbix
7.# cp /usr/local/zabbix_java_gateway/sbin/zabbix_java/settings.sh /etc/zabbix/zabbix_java_gateway.conf
8.此处看情况:
# wget https://raw.github.com/pengyao/zabbix/master/Zabbix_Java_GateWay/scripts/zabbix_java_gateway -O /etc/init.d/zabbix_java_gateway --no-check-certificate
# chmod +x /etc/init.d/zabbix_java_gateway
# chkconfig zabbix_java_gateway on
9.配置setting.sh 文件:
LISTEN_IP 指定bind的地址,默认值为0.0.0.0
LISTEN_PORT 指定bind的端口,默认值为10052
PID_FILE 指定PID文件存放目录,默认为 /tmp/zabbix_java.pid
START_POLLERS 指定启动多少进程, 默认为5,设定为30
10.配置zabbix server 中的配置文件:
JavaGateway 指定Zabbix Java GateWay地址
JavaGatewayPort 指定Zabbix Java GateWay端口,默认为10052
StartJavaPollers 指定启动时启动的Java Pollers数量
注: StartJavaPollers设置的值要小于等于START_POLLERS设置的值
第三步:对tomcat 下的 catalina.sh 进行配置:
export CATALINA_OPTS="$CATALINA_OPTS
-Djava.rmi.server.hostname=192.168.32.79
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=10053
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false"
第四步:在tomcat lib下面下载:
wget http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.8/bin/extras/catalina-jmx-remote.jar
第五步:在 zabbix_server 下面:
cd
wget http://crawler.archive.org/cmdline-jmxclient/cmdline-jmxclient-0.10.3.jar
java -jar /root/cmdline-jmxclient-0.10.3.jar - 192.168.32.79:10053 java.lang:type=Memory NonHeapMemoryUsage
注:由于zabbix 不支持catalina key 模板,所以得用新的模板 key 来替换该 jmx tomcat 模板 ,见 笔记 :zabbix 监控tomcat 模板