前言
在Zabbix中,JMX监控数据的获取由专门的代理程序来实现,即Zabbix-Java-Gateway来负责数据的采集,Zabbix-Java-Gateway和JMX的Java程序之间通信获取数据
安装tomcat
准备
关闭防火墙和selinux
[[email protected] ~]# systemctl stop firewalld && setenforce 0
第一步:首先需要准备下面的两个包,可在网上下载
第二步:上传至linux,移动到/usr/local下面并解压
[[email protected] ~]# rz z waiting to receive.**B0100000023be50 [[email protected] ~]# ls anaconda-ks.cfg create.sql jdk-linux-x64.tar.gz original-ks.cfg test.sh apache-tomcat-7.0.91.tar.gz create.sql.gz ks-pre.log schema.sql zabbix.sh [[email protected] ~]# mv jdk-linux-x64.tar.gz /usr/local [[email protected] ~]# mv apache-tomcat-7.0.91.tar.gz /usr/local [[email protected] local]# tar xf apache-tomcat-7.0.91.tar.gz [[email protected] local]# tar xf jdk-linux-x64.tar.gz
第三步:做软连接
[[email protected] local]# ln -s apache-tomcat-7.0.91 tomcat [[email protected] local]# ln -s jdk1.8.0_131 java
第四步:编辑tomcat配置文件。添加如下几行
...[[email protected] local]# vim tomcat/bin/startup.sh # ----------------------------------------------------------------------------- # Start Script for the CATALINA Server # ----------------------------------------------------------------------------- export JAVA_HOME=/usr/local/java export TOMCAT_HOME=/usr/local/tomcat export CATALINA_HOME=/usr/local/tomcat export CLASS_PATH=/usr/local/java/jre/lib/:/usr/local/java/lib/tools.jar export PATH=$PATH:/usr/local/tomcat/bin/:/usr/local/java/bin/ # Better OS/400 detection: see Bugzilla 31132 ...
第五步:启动tomcat
[[email protected] local]# tomcat/bin/startup.sh Using CATALINA_BASE: /usr/local/tomcat Using CATALINA_HOME: /usr/local/tomcat Using CATALINA_TMPDIR: /usr/local/tomcat/temp Using JRE_HOME: /usr/local/java Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar Tomcat started. [[email protected] local]# ss -tnl | grep 8080 LISTEN 0 100 :::8080 :::*
第六步:页面测试
在浏览器输入ip:8080 看到如下界面即为成功
安装java-gateway及配置
第一步:安装zabbix-java-gateway
[[email protected] ~]# yum install zabbix-java-gateway -y
第二步:配置zabbix-java-gateway文件
[[email protected] ~]# vim /etc/zabbix/zabbix_java_gateway.conf ... ### Option: zabbix.listenIP # IP address to listen on. # # Mandatory: no # Default: LISTEN_IP="10.220.5.138" #监听的本机IP ### Option: zabbix.listenPort # Port to listen on. # # Mandatory: no # Range: 1024-32767 # Default: LISTEN_PORT=10052 #监听的端口...
第三步:重启zabbix-java-gateway
[[email protected] ~]# systemctl restart zabbix-java-gateway [[email protected] ~]# ss -tnl | grep 10052 LISTEN 0 50 ::ffff:10.220.5.138:10052 :::*
配置zabbix-server文件
第一步:现在修改zabbix-server的配置文件,即zabbix监控端,因为要指定java-gateway的地址
[[email protected] ~]# vim /etc/zabbix/zabbix_server.conf ... ### Option: JavaGateway # IP address (or hostname) of Zabbix Java gateway. # Only required if Java pollers are started. # # Mandatory: no # Default: JavaGateway=10.220.5.138 #指定javagateway的监听地址 ### Option: JavaGatewayPort # Port that Zabbix Java gateway listens on. # # Mandatory: no # Range: 1024-32767 # Default: JavaGatewayPort=10052 #指定监听的端口 ...
第二步:重启zabbix-server
[[email protected] ~]# systemctl restart zabbix-server
配置catalina.sh脚本
这是一个远程调试的脚本,我们需要修改它,使得我们能够在window端使用工具来监控。
第一步:配置catalina.sh.这个脚本在tomcat的安装包的目录下.在这个文件添加如下几行
[[email protected] ~]# vim /usr/local/tomcat/bin/catalina.sh # USE_NOHUP (Optional) If set to the string true the start command will 103 # use nohup so that the Tomcat process will ignore any hangup 104 # signals. Default is "false" unless running on HP-UX in which 105 # case the default is "true" 106 # ----------------------------------------------------------------------------- 107 CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote 108 -Dcom.sun.management.jmxremote.port=12345 109 -Dcom.sun.management.jmxremote.ssl=false 110 -Dcom.sun.management.jmxremote.authenticate=false 111 -Djava.rmi.server.hostname=10.220.5.138" #指定提供数据的IP,即被监控节点 112 113 # OS specific support. $var _must_ be set to either true or false.
第二步:重启tomcat
[[email protected] ~]# /usr/local/tomcat/bin/shutdown.sh [[email protected] ~]# /usr/local/tomcat/bin/startup.sh
windows下监控
第一步:准备下面这个文件。可在网上下载
第二步:windows上安装
略
输入被监控节点的IP以及端口号为12345
第三步:启动。看到如下界面即为成功。
原文地址:https://www.cnblogs.com/kenken2018/p/9917943.html
时间: 2024-10-27 16:30:44