Zabbix实现对Tomcat的监控
环境准备
三台机器:
zabbix_agent 5.0(已安装) Zabbix_java_gateway 5.0 10.0.0.7
zabbix_server 5.0(已安装) 10.0.0.17
Tomcat-8.5(已安装) 10.0.0.27
1. Tomcat开启JMX监控
[root@tomcat ~]
CATALINA_OPTS="$CATALINA_OPTS
-Dcom.sun.management.jmxremote #启动远程监控JMX
-Dcom.sun.management.jmxremote.port=12345 #默认启动的JMX端口号,要和zabbix添加主机时候的端口一致即可
-Dcom.sun.management.jmxremote.authenticate=false #不使用用户名密码
-Dcom.sun.management.jmxremote.ssl=false #不使用ssl认证
-Djava.rmi.server.hostname=10.0.0.27"
CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=12345 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=10.0.0.27"
[root@tomcat ~]
[root@tomcat ~]
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 100 [::]:8080 [::]:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 50 [::]:12345 [::]:*
LISTEN 0 100 [::1]:25 [::]:*
LISTEN 0 50 [::]:34689 [::]:*
LISTEN 0 50 [::]:37610 [::]:*
2. 二进制安装Zabbix Java gateway
环境准备
[root@zabbix_java_gateway ~]
[root@zabbix_java_gateway ~]
[root@zabbix_java_gateway ~]
2.1 安装zabbix rpm源
[root@zabbix_java_gateway ~]
[root@zabbix_java_gateway ~]
[root@zabbix_java_gateway ~]
2.2 安装Zabbix Java gateway
[root@zabbix_java_gateway ~]
zabbix-java-gateway.x86_64 5.0.25-1.el7 zabbix
[root@zabbix_java_gateway ~]
2.3 修改Zabbix Java gateway配置文件
[root@zabbix_java_gateway ~]
LISTEN_IP="0.0.0.0"
LISTEN_PORT=10052
PID_FILE="/var/run/zabbix/zabbix_java.pid"
START_POLLERS=5
TIMEOUT=30
[root@zabbix_java_gateway ~]
LISTEN_IP="0.0.0.0"
LISTEN_PORT=10052
PID_FILE="/var/run/zabbix/zabbix_java.pid"
START_POLLERS=5
TIMEOUT=30
2.4 启动Zabbix Java gateway服务
[root@zabbix_java_gateway ~]
[root@zabbix_java_gateway ~]
● zabbix-java-gateway.service - Zabbix Java Gateway
Loaded: loaded (/usr/lib/systemd/system/zabbix-java-gateway.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2022-06-28 11:47:32 CST; 6min ago
Process: 2486 ExecStart=/usr/sbin/zabbix_java_gateway (code=exited, status=0/SUCCESS)
Main PID: 2489 (java)
CGroup: /system.slice/zabbix-java-gateway.service
└─2489 java -server -Dlogback.configurationFile=/etc/zabbix/zabbix_java_gateway_logback.xml -classpath l...
Jun 28 11:47:31 zabbix_java_gateway systemd[1]: Starting Zabbix Java Gateway...
Jun 28 11:47:32 zabbix_java_gateway systemd[1]: Started Zabbix Java Gateway.
[root@zabbix_java_gateway ~]
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:10050 *:*users:(("zabbix_agentd",pid=1333,fd=4),("zabbix_agentd",pid=1332,fd=4),("zabbix_agentd",pid=1331,fd=4),("zabbix_agentd",pid=1330,fd=4),("zabbix_agentd",pid=1329,fd=4),("zabbix_agentd",pid=1328,fd=4),("zabbix_agentd",pid=1327,fd=4),("zabbix_agentd",pid=1326,fd=4))
LISTEN 0 128 *:22 *:*users:(("sshd",pid=1309,fd=3))
LISTEN 0 100 127.0.0.1:25 *:*users:(("master",pid=1414,fd=13))
LISTEN 0 50 [::]:10052 [::]:*users:(("java",pid=1308,fd=12))
LISTEN 0 128 [::]:22 [::]:*users:(("sshd",pid=1309,fd=4))
LISTEN 0 100 [::1]:25 [::]:*users:(("master",pid=1414,fd=14))
[root@zabbix_java_gateway ~]
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 2300 zabbix 12u IPv6 31728 0t0 TCP *:10052 (LISTEN)
3. 配置zabbix server调用java gateway
[root@zabbix_server ~]
JavaGateway=10.0.0.7
JavaGatewayPort=10052
StartJavaPollers=5
[root@zabbix_server ~]
ListenPort=10051
LogType=file
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=500
DebugLevel=3
PidFile=/var/run/zabbix/zabbix_server.pid
SocketDir=/var/run/zabbix
DBHost=10.0.0.17
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBPort=3306
StartPollers=2
StartPreprocessors=3
StartPollersUnreachable=2
StartTrappers=5
StartPingers=5
StartHTTPPollers=3
StartTimers=3
StartEscalators=1
StartAlerters=3
JavaGateway=10.0.0.7
JavaGatewayPort=10052
StartJavaPollers=5
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
StartSNMPTrapper=1
HousekeepingFrequency=4
MaxHousekeeperDelete=1000000
CacheSize=128M
CacheUpdateFrequency=60
StartDBSyncers=6
HistoryCacheSize=128M
HistoryIndexCacheSize=32M
TrendCacheSize=16M
ValueCacheSize=16M
Timeout=30
UnavailableDelay=60
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
FpingLocation=/usr/sbin/fping
LogSlowQueries=3000
TmpDir=/var/run/zabbix/
StartProxyPollers=3
ProxyConfigFrequency=60
ProxyDataFrequency=60
AllowRoot=1
User=root
[root@zabbix_server ~]
[root@zabbix_server ~]
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 *:10050 *:*
LISTEN 0 128 *:10051 *:*
LISTEN 0 128 127.0.0.1:9000 *:*
LISTEN 0 80 [::]:3306 [::]:*
LISTEN 0 128 [::]:80 [::]:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 100 [::1]:25 [::]:*
LISTEN 0 128 [::]:10050 [::]:*
LISTEN 0 128 [::]:10051 [::]:*
4. zabbix server添加JMX监控
点击【配置-主机-10.0.0.7-web1-添加JMX接口】
5. zabbix server关联模板
6. 验证当前JMX状态及数据
#【JMX绿色】表示JMX主机可用,监控指标检查已成功
|