zabbix_server端
在编译时加入参数
--enable-java
编辑 zabbix_server.conf
JavaGateway=127.0.0.1
JavaGatewayPort=10052
StartJavaPollers=5
重启 zabbix_server
service zabbix_server restart
备份 zabbix_java/settings.sh, 也可不做修改保持默认。
cp /usr/local/zabbix2.4/sbin/zabbix_java/settings.sh{,.backup}
# grep -E -v '(#|^$)' settings.sh
LISTEN_IP="0.0.0.0"
LISTEN_PORT=10052
PID_FILE="/tmp/zabbix_java.pid"
START_POLLERS=5
启动 java_gateway
/usr/local/zabbix2.4/sbin/zabbix_java/startup.sh
netstat -anlp |grep 10052
tcp 0 0 ::ffff:127.0.0.1:10052 :::* LISTEN 9936/java
zabbix客户端(Zabbix 3.x):
wget http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.8/bin/extras/catalina-jmx-remote.jar
mv catalina-jmx-remote.jar tomcat/lib/
// edit tomcat/conf/server.xml and add(at line: 35):
<Listener className="org.apache.catalina.mbeans.JmxRemoteLifecycleListener" rmiRegistryPortPlatform="18090" rmiServerPortPlatform="18090" />
// edit tomcat/bin/catalina.sh and add the follow lines:
export CATALINA_OPTS="
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Djava.rmi.server.hostname=192.168.1.28"
192.168.1.28
是 Tomcat 所在服务器的IP。
测试
java -jar cmdline-jmxclient-0.10.3.jar - 192.168.1.28:18090 java.lang:type=Memory
最后,重启 Tomcat 和 zabbix_agentd。