转载

zabbix监控tomcat 自定义监控项

1、tomcat上开启监控

下载 catalina-jmx-remote.jar 保存到tomcat/lib 目录下

编辑tomcat/bin/setenv.sh 添加如下

CATALINA_OPTS=”-Dcom.sun.management.jmxremote.port=8088 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Djava.rmi.server.hostname=192.168.15.84″

2、使用VisualVm测试监控tomcat,效果如下如果可以通过VisualVM监控tomcat说明tomcat配置正确

zabbix监控tomcat 自定义监控项

3、Zabbix server支持java

在编译安装zabbix前必须先配置好jdk并启用–enable-java 编译参数,具体如下

./configure –prefix=/usr/local/zabbix

–enable-server /

–enable-java /

–enable-agent /

–enable-proxy /

–with-mysql=/usr/local/mysql/bin/mysql_config /

–with-libcurl /

–with-libxml2 /

–with-ldap

在zabbix 服务器上开启zabbix java gateway

vim /usr/local/zabbix/sbin/zabbix_java/settings.sh

zabbix监控tomcat 自定义监控项
启动 java gateway

zabbix监控tomcat 自定义监控项

zabbix监控tomcat 自定义监控项
编辑zabbix server配置并重启服务

vim /usr/local/zabbix/etc/zabbix_server.conf

zabbix监控tomcat 自定义监控项

4、被监控服务器添加jvm监控

自定义监控

使用cmdline-jmxclient-0.10.3.jar工具查看tomcat中有哪些可监控项,然后根据实际情况自定义监控模板

列出所有项目:java -jar cmdline-jmxclient-0.10.3.jar – 192.168.15.84:8088 ,结果类似如下

zabbix监控tomcat 自定义监控项

获取堆内存信息:

java -jar cmdline-jmxclient-0.10.3.jar – 192.168.15.84:8088 java.lang:type=Memory HeapMemoryUsage

获取栈内存信息:

java -jar cmdline-jmxclient-0.10.3.jar – 192.168.15.84:8088 java.lang:type=Memory NonHeapMemoryUsage

——————–Threading —————-

获取线程数:

java -jar cmdline-jmxclient-0.10.3.jar – 192.168.15.84:8088 java.lang:type=Threading ThreadCount

当前线程cpu时间:

java -jar cmdline-jmxclient-0.10.3.jar – 192.168.15.84:8088 java.lang:type=Threading CurrentThreadCpuTime

当前线程用户时间:

java -jar cmdline-jmxclient-0.10.3.jar – 192.168.15.84:8088 java.lang:type=Threading CurrentThreadUserTime

获取Java 虚拟机启动或峰值重置以来峰值活动线程计数。

java -jar cmdline-jmxclient-0.10.3.jar – 192.168.15.84:8088 java.lang:type=Threading PeakThreadCount

————-CMS Old Gen,type=MemoryPool———-

java -jar cmdline-jmxclient-0.10.3.jar – 192.168.15.84:8088 ‘java.lang:name=CMS Old Gen,type=MemoryPool’ UsageThresholdCount

java -jar cmdline-jmxclient-0.10.3.jar – 192.168.15.84:8088 ‘java.lang:name=CMS Old Gen,type=MemoryPool’ CollectionUsageThreshold

java -jar cmdline-jmxclient-0.10.3.jar – 192.168.15.84:8088 ‘java.lang:name=CMS Old Gen,type=MemoryPool’ CollectionUsageThresholdCount

java -jar cmdline-jmxclient-0.10.3.jar – 192.168.15.84:8088 ‘java.lang:name=CMS Old Gen,type=MemoryPool’ CollectionUsage

—————– ClassLoading —————

java -jar cmdline-jmxclient-0.10.3.jar – 192.168.15.84:8088 java.lang:type=ClassLoading TotalLoadedClassCount

java -jar cmdline-jmxclient-0.10.3.jar – 192.168.15.84:8088 java.lang:type=ClassLoading LoadedClassCount

java -jar cmdline-jmxclient-0.10.3.jar – 192.168.15.84:8088 java.lang:type=ClassLoading UnloadedClassCount

——————GarbageCollector————-

java -jar cmdline-jmxclient-0.10.3.jar – 192.168.15.84:8088 java.lang:name=ParNew,type=GarbageCollector CollectionCount

java -jar cmdline-jmxclient-0.10.3.jar – 192.168.15.84:8088 java.lang:name=ParNew,type=GarbageCollector CollectionTime

java -jar cmdline-jmxclient-0.10.3.jar – 192.168.15.84:8088 java.lang:name=ConcurrentMarkSweep,type=GarbageCollector CollectionCount

java -jar cmdline-jmxclient-0.10.3.jar – 192.168.15.84:8088 java.lang:name=ConcurrentMarkSweep,type=GarbageCollector CollectionTime

zabbix监控tomcat 自定义监控项

zabbix监控tomcat 自定义监控项

zabbix监控tomcat 自定义监控项

zabbix监控tomcat 自定义监控项

zabbix监控tomcat 自定义监控项
原文  http://www.zhengdazhi.com/archives/1420
正文到此结束
Loading...