Thứ Ba, 24 tháng 7, 2018

Monitoring tomcat using zabbix

Platform: CentOS 7 64bit, Tomcat 7


1. Install Zabbix Server

rpm -ivh https://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
yum install zabbix-web-mysql -y
yum install zabbix-java-gateway -y
yum -y install httpd
yum -y install mariadb-server

#mysql -uroot
mysql>create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by '<password>';
mysql> quit;
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix

Edit /etc/zabbix/zabbix_server.conf:
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
JavaGateway=x.x.x.x
JavaGatewayPort=10052
StartJavaPollers=1
2. Config tomcat to enable jmx monitoring:
- Install Zabbix Agent:
rpm -ivh https://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
yum install zabbix-agent
- Download and install catalina-jmx-remote.jar 
 #wget http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.90/bin/extras/catalina-jmx-remote.jar
- mv the jar file to /usr/local/tomcat7/lib/ 
- edit /usr/local/tomcat7/conf/server.xml and add Listener


<Listener className="org.apache.catalina.mbeans.JmxRemoteLifecycleListener" rmiRegistryPortPlatform="8090" rmiServerPortPlatform="8090" />
- edit /usr/local/tomcat7/bin/setenv.sh and add the follow lines:
export JAVA_OPTS="$JAVA_OPTS -Xms128M -Xmx512M -server -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"
Restart tomcat:
cd /opt/apache-tomcat-7.0.90/bin/
./shutdown.sh
./startup.sh

Configuring JMX interfaces and items in Zabbix frontend

With Java gateway running, server knowing where to find it and a Java application started with support for remote JMX monitoring, it is time to configure the interfaces and items in Zabbix GUI.
Configuring JMX interface
You begin by creating a JMX-type interface on the host of interest:

Adding JMX agent item
For each JMX counter you are interested in you add JMX agent item attached to that interface.
The key in the screenshot below says jmx["java.lang:type=Memory","HeapMemoryUsage.used"].

The fields that require specific information for JMX items are:
Type Set JMX agent here.
Key The jmx[] item key contains two parameters:
object name - the object name of an MBean;
attribute name - an MBean attribute name with optional composite data field names separated by dots.
See below for more detail on JMX item keys.
Since Zabbix 3.4, you may discover MBeans and MBean attributes using a jmx.discovery[] low-level discovery item.
JMX endpoint You may specify a custom JMX endpoint. Make sure that JMX endpoint connection parameters match the JMX interface. This can be achieved by using {HOST.*} macros as done in the default JMX endpoint.
This field is supported since 3.4.0. {HOST.*} macros and user macros are supported.
User name Specify the user name, if you have configured authentication on your Java application.
User macros are supported.
Password Specify the password, if you have configured authentication on your Java application.
User macros are supported.



Share This!


Không có nhận xét nào:

Đăng nhận xét