zabbix 服务器无法连接到 java 网关

zabbix server can't connect to java gateway

我在同一个linux服务器上安装了zabbix服务器和java网关,并启动了zabbix-server和zabbix-java-gateway服务。 OS是CentOS6.5,java是JDK1.6.0_45,IP是192.98.12.240,zabbix server和zabbix java网关版本是2.2 .9.我已经停止了 iptables 服务。

然后在zabbix web控制台,我添加了一个启用了jmx接口的主机。我的主机 IP 是 192.98.12.198,JMX post 是 9999。在 Jconsole 中,我可以连接到这个启用了 JMX 的 java 应用程序。但是在 zabbix web console 中,它显示错误:

下面是我的zabbix_server.conf

LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
DebugLevel=4
PidFile=/var/run/zabbix/zabbix_server.pid
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBSocket=/var/lib/mysql/mysql.sock
JavaGateway=192.98.12.240
JavaGatewayPort=10052
StartJavaPollers=5
SNMPTrapperFile=/var/log/snmptt/snmptt.log
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts

下面是我的zabbix_java_gateway.conf

LISTEN_IP=192.98.12.240
LISTEN_PORT=10052
PID_FILE="/var/run/zabbix/zabbix_java.pid"
START_POLLERS=5

下面是 zabbix_server.log

的一些片段
13573:20150321:100114.503 In substitute_key_macros() data:'jmx[java.lang:type=Memory,HeapMemoryUsage.used]'
13573:20150321:100114.503 End of substitute_key_macros():SUCCEED data:'jmx[java.lang:type=Memory,HeapMemoryUsage.used]'
13573:20150321:100114.503 In substitute_simple_macros() data:'9999'
13573:20150321:100114.503 In substitute_simple_macros() data:EMPTY
13573:20150321:100114.503 In substitute_simple_macros() data:EMPTY
13573:20150321:100114.503 In get_values_java() host:'myhost' addr:'192.98.12.198' num:1
13573:20150321:100114.503 getting Java values failed: cannot connect to [[192.98.12.240]:10052]: [13] Permission denied
13573:20150321:100114.503 End of get_values_java()
13573:20150321:100114.503 In deactivate_host() hostid:10106 itemid:23899 type:16
13573:20150321:100114.503 query [txnlev:1] [begin;]
13573:20150321:100114.503 query [txnlev:1] [update hosts set jmx_disable_until=1426903334,jmx_error='cannot connect to [[192.98.12.240]:10052]: [13] Permission denied' where hostid=10106]
13573:20150321:100114.504 query [txnlev:1] [commit;]
13573:20150321:100114.526 deactivate_host() errors_from:1426901309 available:2
13573:20150321:100114.526 End of deactivate_host()
13573:20150321:100114.526 End of get_values():1

下面是我的zabbix_java_gateway.log

2015-03-21 10:54:29.078 [main] INFO  com.zabbix.gateway.JavaGateway - Zabbix Java Gateway 2.2.9 (revision 52686) has started
2015-03-21 10:54:29.086 [main] DEBUG c.z.gateway.ConfigurationManager - starting to parse configuration parameters
2015-03-21 10:54:29.086 [main] DEBUG c.z.gateway.ConfigurationManager - found pidFile configuration parameter with value '/var/run/zabbix/zabbix_java.pid'
2015-03-21 10:54:29.087 [main] DEBUG c.z.gateway.ConfigurationManager - received pidFile configuration parameter, daemonizing
2015-03-21 10:54:29.088 [main] DEBUG c.z.gateway.ConfigurationManager - found listenIP configuration parameter with value '192.98.12.240'
2015-03-21 10:54:29.089 [main] DEBUG c.z.gateway.ConfigurationManager - found listenPort configuration parameter with value '10052'
2015-03-21 10:54:29.089 [main] DEBUG c.z.gateway.ConfigurationManager - found startPollers configuration parameter with value '5'
2015-03-21 10:54:29.089 [main] DEBUG c.z.gateway.ConfigurationManager - finished parsing configuration parameters
2015-03-21 10:54:29.092 [main] INFO  com.zabbix.gateway.JavaGateway - listening on /192.98.12.240:10052
2015-03-21 10:54:29.097 [main] DEBUG com.zabbix.gateway.JavaGateway - created a thread pool of 5 pollers

请帮忙,谢谢。

ps: 我把zabbix_server.conf里面的JavaGateway改成了localhost或者127.0.0.1,也没用

# Modify zabbix_server.conf


JavaGateway=127.0.0.1

# Modify zabbix_java_gateway.conf

LISTEN_IP=127.0.0.1

# Restart Services 
service zabbix-server restart

service zabbix-java-gateway restart

注意:确保 SELinux 或 iptables 没有阻止请求。

我自己找到了解决方案。 在VM选项中添加-Djava.net.preferIPv4Stack=true解决问题