我们环境用zabbix mpm来监控mysql,不过最近官网已经不叫mpm了,而是叫fpmmm,理由为:
fpmmm is the successor of mpm. mpm was renamed to fpmmm because of the naming conflict with the Apache Multi-Processing Modules (MPM).
好啦,那是官方的行为,我们可以不管,于是我们下载了最新的fpmmm(fpmmm-0.10.5.tar.gz)监控模块
一切按照http://www.fromdual.com/fpmmm-installation-guide上的指导来安装就可以了。
导入模版一切正常,但却发现得不了数据:
用zabbix_sender发送数据也发不了
看日志(fpmmm模块):
less /tmp/fpmmm/fpmmm.log (发现有如下的大量重复log)
46819:2016-04-21 10:22:02.630 - WARN: ZabbixServer=122.54.133.40, ZabbixServerPort=10051, Hostname=52.29.mysql.3306
46819:2016-04-21 10:22:02.630 - WARN: Connection to zabbix server failed (rc=1800)!
46819:2016-04-21 10:22:02.648 - ERR : Failed to execute (rc=1107/ret=1).
看来是远程的ZabbixServer连接失败。
此时用telnet 去联接的话提示:
[[email protected] ~]$ telnet 122.54.133.40 10051
Trying 122.54.133.40...
telnet: connect to address 122.54.133.40: No route to host
看来应该是防火墙的问题:
开启防火墙:确保sever端开通了10051端口:
-A INPUT -s 122.54.133.40 -m state --state NEW -m tcp -p tcp --dport 10050:10051 -j ACCEPT
-A INPUT -s 122.54.133.40 -m state --state NEW -m udp -p udp --dport 10050:10051 -j ACCEPT
再次连接:
[[email protected] tpl]# telnet 122.54.133.40 10051
Trying 122.54.133.40...
telnet: connect to address 122.54.133.40: Connection refused
很奇怪,server端已经开启了10051端口了呀,再用如下命令扫描一下这个端口:
[[email protected] chenzejin]# nmap -p10051 122.54.133.40
Starting Nmap 5.51 ( http://nmap.org ) at 2016-04-21 10:15 CST
Nmap scan report for 122.54.133.40
Host is up (0.0021s latency).
PORT STATE SERVICE
10051/tcp closed unknown
Nmap done: 1 IP address (1 host up) scanned in 0.14 seconds
发现是closed状态,所以连接不了。
奇怪,在本地测试都好好的,现在搬到生产环境上的测试就不行了
于是看了zabbix_server上的10051端口如下:
[[email protected] zabbix]# netstat -lnpt | grep 10051
tcp 0 127.0.0.1:10051 0.0.0.0:* LISTEN 58116/zabbix_server
再对比了本地正常可监听的环境,发现了一点点不了样
[[email protected] zabbix]# netstat -lnpt | grep 10051
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 58116/zabbix_server
所以应该是zabbix_server的配置问题了。
再打开zabbix_server.conf的配置文件,发现有如下的配置:
### Option: ListenIP
# List of comma delimited IP addresses that the trapper should listen on.
# Trapper will listen on all network interfaces if this parameter is missing.
#
# Mandatory: no
# Default:
# ListenIP=0.0.0.0
ListenIP=127.0.0.1
我在本地的ListenIP=127.0.0.1是被注释掉的,而生产上这个选项被打开了
发现了这个选项,怪不得,于是把服务器的ip也加上,如下:
ListenIP=127.0.0.1,122.54.133.40
重启zabbix server服务
再在agent端执行:
[[email protected] zabbix]# nmap -p10050 122.54.133.40
Starting Nmap 5.51 ( http://nmap.org ) at 2016-04-21 10:43 CST
Nmap scan report for 122.54.133.40
Host is up (0.0021s latency).
PORT STATE SERVICE
10050/tcp open unknown
Nmap done: 1 IP address (1 host up) scanned in 0.15 seconds
一切正常,可以连接通讯了。
数据也正常获取到了。
至此解决了了zabbix mpm获取不到数据的情况
总结:
第一步:看log,log永远是第一手资料
第二步:防火墙检查,端口检查
第三步:zabbix_server配置检查
122.54.133.40此ip为虚构ip,如果碰巧,纯属巧合。