zabbix
監控tomcat
1.編譯zabbix的時候須要添加參數--enable-java
html
關於如何安裝zabbix
,能夠參考上一篇文章http://blog.unix178.com/java
備份zabbix_server.conf
和zabbix_agentd.conf
文件,從新編譯安裝zabbix
mysql
[root@nginx zabbix-2.2.0]# ./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-ssh2 --enable-java
2.zabbix_server端安裝jdklinux
安裝jdk
nginx
[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相關選項sql
而後進入到下面的目錄下面進行seeting.sh
腳本編輯apache
[root@nginx zabbix-2.2.0]# find / -name zabbix_java /usr/local/sbin/zabbix_java /tmp/zabbix-2.2.0/src/zabbix_java [root@nginx zabbix-2.2.0]# [root@nginx zabbix-2.2.0]# ls bin lib settings.sh shutdown.sh startup.sh
該文件默認所有註釋的,啓用下面幾項便可vim
[root@nginx zabbix_java]# vim settings.sh [root@nginx zabbix_java]# sed -e '/^#/d;/^$/d' settings.sh LISTEN_IP="0.0.0.0" LISTEN_PORT=10052 PID_FILE="/tmp/zabbix_java.pid" START_POLLERS=5 [root@nginx zabbix_java]#
4.修改zabbix_server文件tomcat
啓用其中的幾項服務器
[root@nginx zabbix_java]# sed -e '/^#/d;/^$/d' /usr/local/etc/zabbix_server.conf LogFile=/tmp/zabbix_server.log DBName=zabbix DBUser=zabbix DBPassword=zabbix [root@nginx zabbix_java]# vim /usr/local/etc/zabbix_server.conf [root@nginx zabbix_java]# sed -e '/^#/d;/^$/d' /usr/local/etc/zabbix_server.conf LogFile=/tmp/zabbix_server.log DBName=zabbix DBUser=zabbix DBPassword=zabbix JavaGateway=127.0.0.1 JavaGatewayPort=10052 StartJavaPollers=5
5.啓動zabbix_java
找到zabbix_java
目錄路徑,而後執行命令./startup.sh
[root@nginx zabbix-2.2.0]# find / -name zabbix_java /usr/local/sbin/zabbix_java /tmp/zabbix-2.2.0/src/zabbix_java [root@nginx zabbix-2.2.0]# [root@nginx zabbix-2.2.0]# ls bin lib settings.sh shutdown.sh startup.sh [root@nginx zabbix-2.2.0]# ss -tunlp | grep 10052 tcp LISTEN 0 50 :::10052 :::* users:(("java",16405,12))
6.調整tomcat
端,安裝catalina-jmx-remote.jar
下載來安裝:
root@tomcat5 tmp]# wget http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.8/bin/extras/catalina-jmx-remote.jar
將下載好的文件存放到tomcat
子目錄目錄lib
錄下
[root@tomcat5 tmp]# mv catalina-jmx-remote.jar /usr/local/tomcat/lib/ [root@tomcat5 tmp]#
7.修改catalina.sh
文件
修改catalina.sh文件,添加
CATALINA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=**ip**"
8.重啓啓動tomcat
服務和zabbix_agentd
服務
9.服務器端測試是否能正常獲取信息
[root@nginx zabbix-2.2.0]# java -jar /root/cmdline-jmxclient-0.10.3.jar - 192.168.146.130:9999 java.lang:type=Memory NonHeapMemoryUsage 05/24/2014 15:42:02 +0800 org.archive.jmx.Client NonHeapMemoryUsage: committed: 47316992 init: 24313856 max: 136314880 used: 47012784
10.服務器端自定義監控項
添加jmx監控端口
自定義監控項
查看繪圖結果
直接上圖,本身看吧
添加jmx監控端口
自定義監控項
查看繪圖結果
11.參考網站