155°

zabbix监控Tomcat

zabbix监控Tomcat

监控流程:

1)安装zabbix_java_gateway
2)配置zabbix_java_gateway配置文件和zabbix_server配置文件,指定监听端口,启动进程数
3)编辑Tomcat配置文件,开启JMX
4)添加host,指定JMX interface
5)链接TOMCAT模板

安装zabbix_java_gateway

[root@wangzb01 ~]# yum install -y zabbix-java-gateway

修改配置文件

[root@wangzb01 ~]# vim /etc/zabbix/zabbix_java_gateway.conf 
定义 LISTEN_PORT 和 START_POLLERS
LISTEN_IP="0.0.0.0"   //不指定IP,则默认全网
LISTEN_PORT=10052   //不开启则服务默认也是10052
START_POLLERS=5   //进程数

[root@wangzb01 ~]# vi /etc/zabbix/zabbix_server.conf
定义 JavaGateway 和 JavaGatewayPort 和  StartJavaPollers
JavaGateway=127.0.0.1
JavaGatewayPort=10052
StartJavaPollers=5

启动zabbix-java-gateway服务

[root@wangzb01 ~]# systemctl start zabbix-java-gateway
[root@wangzb01 ~]# ps aux |grep zabbix_java_gateway
zabbix     7458  4.4  3.6 2333192 36628 ?       Sl   21:30   0:00 java -server -Dlogback.configurationFile=/etc/zabbix/zabbix_java_gateway_logback.xml -classpath lib:lib/android-json-4.3_r3.1.jar:lib/logback-classic-0.9.27.jar:lib/logback-core-0.9.27.jar:lib/slf4j-api-1.6.1.jar:bin/zabbix-java-gateway-4.0.5.jar -Dzabbix.pidFile=/var/run/zabbix/zabbix_java.pid -Dzabbix.listenIP=0.0.0.0 -Dzabbix.listenPort=10052 -Dzabbix.startPollers=5 -Dsun.rmi.transport.tcp.responseTimeout=3000 com.zabbix.gateway.JavaGateway
root       7471  0.0  0.0 112724   992 pts/0    S+   21:30   0:00 grep --color=auto zabbix_java_gateway

重启zabbix-server服务

[root@wangzb01 ~]# systemctl restart zabbix-server

查看端口:

[root@wangzb01 ~]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:21              0.0.0.0:*               LISTEN      6665/pure-ftpd (SER 
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      6636/sshd           
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      6909/master         
tcp        0      0 0.0.0.0:10050           0.0.0.0:*               LISTEN      7189/zabbix_agentd  
tcp        0      0 0.0.0.0:10051           0.0.0.0:*               LISTEN      7483/zabbix_server  
tcp6       0      0 :::3306                 :::*                    LISTEN      6816/mysqld         
tcp6       0      0 :::80                   :::*                    LISTEN      7109/httpd          
tcp6       0      0 :::21                   :::*                    LISTEN      6665/pure-ftpd (SER 
tcp6       0      0 :::22                   :::*                    LISTEN      6636/sshd           
tcp6       0      0 ::1:25                  :::*                    LISTEN      6909/master         
tcp6       0      0 :::10050                :::*                    LISTEN      7189/zabbix_agentd  
tcp6       0      0 :::10051                :::*                    LISTEN      7483/zabbix_server  
tcp6       0      0 :::10052                :::*                    LISTEN      7458/java           

开启JMX

vi /usr/local/tomcat/bin/catalina.sh #在#!/bin/sh下增加
export CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote
-Djava.rmi.server.hostname=192.168.222.128
-Dcom.sun.management.jmxremote.port=9999
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false"

重启tomcat

[root@wangzb01 ~]# /usr/local/tomcat/bin/shutdown.sh 
[root@wangzb01 ~]# /usr/local/tomcat/bin/startup.sh

查看Tomcat的9999端口是否已开启

[root@wangzb01 ~]# netstat -lntp

添加Hosts链接模板

Configuration -> Hosts -> Create host
Agent interfaces -> remove
JMX interfaces -> Add -> 192.168.222.128  9999

Templates -> Select -> Template App Apache Tomcat JMX -> select -> Add -> Add

monitoring -> latest data -> 选择刚刚添加的主机 -> apply 就可以看到出现相应的监控指标,并且有数值

本文由【w】发布于开源中国,原文链接:https://my.oschina.net/u/3954059/blog/3018965

全部评论: 0

    我有话说: