zabbix-2.4.2监控-使用JMX功能监控tomcat安装配置


使用zabbix-2.4.2监控tomcat,记录下来以后用。

环境:Centos7.0 zabbix2.4.2

1.在zabbix-2.4.2服务端配置java环境,下载jdk,配置jdk环境变量。

tar zxvf jdk-8u25-linux-x64.tar.gz

vim /etc/profile

JAVA_HOME=/opt/jdk1.8.0_25
PATH=$JAVA_HOME/bin:$PATH
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME
export PATH
export CLASSPATH

QQ截图20141215155113

2.重新编译安装zabbix添加对java监控的支持。

cd zabbix-2.4.2

./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-ssh --enable-java

make && make install

zabbix环境的配置这里不再介绍,只对增减java监控作说明。

修改/usr/local/zabbix/sbin/zabbix_java/settings.sh文件。

# This is a configuration file for Zabbix Java Gateway.
# It is sourced by startup.sh and shutdown.sh scripts.

### Option: zabbix.listenIP
#    IP address to listen on.
#
# Mandatory: no
# Default:
LISTEN_IP="0.0.0.0"

### Option: zabbix.listenPort
#    Port to listen on.
#
# Mandatory: no
# Range: 1024-32767
# Default:
LISTEN_PORT=10052

### Option: zabbix.pidFile
#    Name of PID file.
#    If omitted, Zabbix Java Gateway is started as a console application.
#
# Mandatory: no
# Default:
# PID_FILE=

PID_FILE="/tmp/zabbix_java.pid"

### Option: zabbix.startPollers
#    Number of worker threads to start.
#
# Mandatory: no
# Range: 1-1000
# Default:
START_POLLERS=5

修改zabbix_server配置文件/usr/local/zabbix/etc/zabbix_server.conf

添加以下几行:

JavaGateway=127.0.0.1
JavaGatewayPort=10052
StartJavaPollers=5
    启动javagateway
/usr/local/zabbix/sbin/zabbix_java/startup.sh
[[email protected] zabbix_java]# netstat -napl |grep 10052
tcp6       0      0 :::10052                :::*                    LISTEN      18805/java

添加开机启动

echo "/usr/local/zabbix/sbin/zabbix_java/startup.sh">>/etc/rc.local

3.tomcat配置,下载catalina-jmx-remote.jar文件放到tomcat/lib下面

http://mirror.bit.edu.cn/apache/tomcat/tomcat-8/v8.0.15/bin/extras/catalina-jmx-remote.jar

在tomcat/conf/server.xml文件中添加:

<Listener className="org.apache.catalina.mbeans.JmxRemoteLifecycleListener" rmiRegistryPortPlatform="12345" rmiServerPortPlatform="12346" />

在tomcat/bin/catalina.sh文件中添加

CATALINA_OPTS="-Dcom.sun.management.jmxremote  -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.port=12345 -Dcom.sun.management.jmxremote.ssh=false -Djava.rmi.server.hostname=192.168.0.86"

其中hostname是被监控端的ip。

启动tomcat,下载cmdline-jmxclient-0.10.3.jar文件测试。

java -jar cmdline-jmxclient-0.10.3.jar  - 192.168.0.86:12345 java.lang:type=Memory NonHeapMemoryUsage

[[email protected] lib]# java -jar ./cmdline-jmxclient-0.10.3.jar  - 192.168.0.86:12345 java.lang:type=Memory NonHeapMemoryUsage
12/15/2014 17:53:32 +0800 org.archive.jmx.Client NonHeapMemoryUsage:
committed: 82870272
init: 2555904
max: -1
used: 81061392

测试成功。

4.上传tomcat模版

QQ截图20141215175559

QQ截图20141215175650

QQ截图20141215175732

ok。

 

 

 


Whatever is worth doing is worth doing well.