zabbix通过JMX监控Tomcat金沙官网线上

六、自定义添加

jmx一般监控,都适用,讲讲自定义监控tomcat:
cd /usr/local/tomcat/
java -jar cmdline-jmxclient-0.10.3.jar - 192.168.1.106:12345 java.lang:type=Memory HeapMemoryUsage
java -jar cmdline-jmxclient-0.10.3.jar - 192.168.1.106:12345 java.lang:type=OperatingSystem ProcessCpuLoad

zabbix上添加监控:

先添加主机,使用jmx的接口进行监控。

jmx["java.lang:type=Memory",HeapMemoryUsage.used]默认(单位B)
jmx["java.lang:type=Memory",HeapMemoryUsage.max]默认(单位B)
jmx["java.lang:type=Memory",NonHeapMemoryUsage.max]  默认(单位B)
jmx["java.lang:type=Memory",NonHeapMemoryUsage.used]  默认(单位B)
jmx["java.lang:type=ClassLoading",UnloadedClassCount]  默认
jmx["java.lang:type=ClassLoading",LoadedClassCount]  默认
jmx["java.lang:type=ClassLoading",TotalLoadedClassCount] 默认
jmx["java.lang:type=OperatingSystem",OpenFileDescriptorCount] 默认
jmx["java.lang:type=OperatingSystem",MaxFileDescriptorCount] 默认
jmx["java.lang:type=OperatingSystem",ProcessCpuLoad]浮点数 % 自定义倍数100
jmx["java.lang:type=Runtime",Uptime] 默认 探测是否存活(nodata3分钟)

tomcat监控:

java -jar cmdline-jmxclient-0.10.3.jar - 192.168.1.106:12345 |grep -i Catalina
java -jar cmdline-jmxclient-0.10.3.jar - 192.168.1.106:12345 "Catalina:name="http-bio-8080",type=GlobalRequestProcessor" requestCount

zabbix上添加如下:

jmx["Catalina:name="http-bio-8080",type=GlobalRequestProcessor",requestCount] 每秒的请求数
jmx["Catalina:name="http-bio-8080",type=ThreadPool",maxThreads]

监控Zabbix使用JMX监控Tomcat

1.在zabix服务端安装java工具(服务器已安装zabbix)

[[email protected] ~]# rpm -ivh
http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-java-gateway-2.4.7-1.el6.x86_64.rpm

[[email protected] ~]# vim /etc/zabbix/zabbix_server.conf
JavaGateway=127.0.0.1
JavaGatewayPort=10055
StartJavaPollers=5
[[email protected] ~]# vim /etc/zabbix/zabbix_java_gateway.conf

LISTEN_IP="0.0.0.0"
LISTEN_PORT=10055
START_POLLERS=5

[[email protected] ~]# /etc/init.d/zabbix-server restart
Shutting down Zabbix server:          [  OK  ]
Starting Zabbix server:                    [  OK  ]
[[email protected] ~]# /etc/init.d/zabbix-java-gateway restart
Shutting down zabbix java gateway:      [  OK  ]
Starting zabbix java gateway:                [  OK  ]

[[email protected] ~]# netstat -antulp | grep 10055
tcp        0      0 :::10055                    :::*                        LISTEN      15958/java         
[[email protected] ~]#

 

2.在tomcat端添加一个端口,供zabbix获取数据

jmxcmd下载地址:

https://sourceforge.net/projects/jmxcmd/files/latest/download?source=typ_redirect

[[email protected] ~]# vim /usr/local/tomcat-7.0.67/bin/catalina.sh    --添加以下行,获取tomcat服务器的IP地址
CATALINA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=本机IP地址"

[[email protected] ~]# vim /usr/local/tomcat-7.0.67Html/conf/server.xml      --暴露一个端口给zabbix获取数据
  <Listener className="org.apache.catalina.mbeans.JmxRemoteLifecycleListener"  rmiRegistryPortPlatform="9999" rmiServerPortPlatform="9999"/>
[[email protected] ~]# /usr/local/tomcat-7.0.67/bin/shutdown.sh      --关闭tomcat服务
[[email protected] ~]# /usr/local/tomcat-7.0.67/bin/startup.sh          --启动tomcat服务

[[email protected] ~]# netstat -antulp | grep 9999
tcp        0      0 :::9999            :::*                LISTEN      12469/java             
[[email protected] ~]# java -jar jmxcmd.jar - localhost:9999 java.lang:type=Memory NonHeapMemoryUsage
04/26/2016 16:21:38 +0800 de.layereight.jmxcmd.Client NonHeapMemoryUsage:
committed: 136183808
init: 134676480
max: 318767104
used: 36691992
[[email protected] ~]# 

3.在zabbix中添加分类,项目,键

(1).启用jmx模块

金沙官网线上 1

(2).创建分类

金沙官网线上 2

一些Zabbix相关教程集合:

Ubuntu 14.04下Zabbix2.4.5 源码编译安装 

安装部署分布式监控系统Zabbix 2.06

《安装部署分布式监控系统Zabbix 2.06》

CentOS 6.3下Zabbix安装部署

Zabbix分布式监控系统实践

CentOS 6.3下Zabbix监控apache server-status

CentOS 6.3下Zabbix监控MySQL数据库参数

64位CentOS 6.2下安装Zabbix 2.0.6   

ZABBIX 的详细介绍:请点这里
ZABBIX 的下载地址:请点这里

本文永久更新链接地址:

http://www.bkjia.com/Linux/1124559.htmlwww.bkjia.comtruehttp://www.bkjia.com/Linux/1124559.htmlTechArticle监控Zabbix使用JMX监控Tomcat 1.在zabix服务端安装java工具(服务器已安装zabbix) [[email protected] ~]# rpm -ivh http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-java-...

七、使用模板

jmx generic
jmx tomcat 默认的很多不能用,得改下

tomcat的安装脚本:

#!/bin/sh
LANG=C

if [ -d "/usr/local/tomcat/" ];then
    echo "tomcat is install"
    exit 1
else
    echo "tomcat in not install"
fi

my_gcc=`rpm -qa gcc`
if [[ -n "$my_gcc" ]];then
    echo "$my_gcc" 
else
    yum -y install gcc
fi

my_make=`rpm -qa make`
if [[ -n "$my_make" ]];then
    echo "$my_make"
else
    yum -y install make 
fi

my_tar=`rpm -qa tar`
if [[ -n "$my_tar" ]];then
    echo "$my_tar"
else
    yum -y install tar
fi

my_openssl=`rpm -qa openssl`
if [[ -n "$my_openssl" ]];then
    echo "$my_openssl"
else
    yum -y install openssl
fi

my_openssl_devel=`rpm -qa openssl-devel`
if [[ -n "$my_openssl_devel" ]];then
    echo "$my_openssl_devel"
else
    yum -y install openssl-devel
fi

my_jdk=`rpm -qa java-1.7.0-openjdk`
if [[ -n "$my_jdk" ]];then
    echo "$my_jdk"
else
    yum -y install java-1.7.0-openjdk
fi

cd /usr/local/src
tar -zxvf apache-tomcat-7.0.63.tar.gz
mv apache-tomcat-7.0.63 /usr/local/tomcat
echo "install tomcat success. tomcat is in /usr/local/tomcat"
exit 0

 

五、tomcat服务器加入如下配置(vim /usr/local/tomcat/bin/catalina.sh)

CATALINA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=12345 -Djava.rmi.server.hostname=192.168.1.106"
重启tomcat:
/usr/local/tomcat/bin/startup.sh 

需要先下载一个cmdline-jmxclient-0.10.3.jar,用来测试jmx获取监控数据,获取没问题后再在zabbix网页上添加监控项目。

三、看下java gateway的监控端口(10052)

ps auxfw|grep JavaGateway

本文由金沙官网线上发布于操作系统,转载请注明出处:zabbix通过JMX监控Tomcat金沙官网线上

您可能还会对下面的文章感兴趣: