使用 nmap 提示被防火墙阻挡, 实际没有启用防火墙
- [[email protected]_filmora_haproxy:/usr/local/aegis]# nmap 172.20.103.202 -p 7000
- Starting Nmap 6.40 ( http://nmap.org ) at 2019-04-24 02:24 PDT
- Nmap scan report for redis01 (172.20.103.202)
- Host is up (0.000044s latency).
- PORT STATE SERVICE
- 7000/tcp filtered afs3-fileserver
- Mac Address: EE:FF:FF:FF:FF:FF (Unknown)
- Nmap done: 1 IP address (1 host up) scanned in 0.29 seconds
- [[email protected]_filmora_haproxy:/usr/local/zabbix_agents_3.2.0/scripts]# cat /usr/local/zabbix_agents_3.2.0/scripts/redis_server_status.sh
- #!/bin/bash
- # function:monitor Redis port status from zabbix
- web_ip_discovery () {
- WEB_IP=($(cat /usr/local/zabbix_agents_3.2.0/scripts/redis_servers.txt|grep -v "^#"))
- printf '{\n'
- printf '\t"data":[\n'
- for((i=0;i<${#WEB_IP[@]};++i))
- {
- num=$(echo $((${#WEB_IP[@]}-1)))
- if [ "$i" != ${num} ];
- then
- printf "\t\t{ \n"
- printf "\t\t\t\"{#SITENAME}\":\"${WEB_IP[$i]}\"},\n"
- else
- printf "\t\t{ \n"
- printf "\t\t\t\"{#SITENAME}\":\"${WEB_IP[$num]}\"}]}\n"
- fi
- }
- }
- web_site_code () {
- ip=`echo $1|awk -F ':' '{print $1}'`
- port=`echo $1|awk -F ':' '{print $2}'`
- #echo $ip
- /usr/bin/nc -w 1 ${ip} ${port} </dev/null && echo 200
- }
- case "$1" in
- web_ip_discovery)
- web_ip_discovery
- ;;
- web_site_code)
- web_site_code $2
- ;;
- *)
- echo "Usage:$0 {web_ip_discovery|web_site_code [URL]}"
- ;;
- esac
- # Redis 服务器列表
- [[email protected]_filmora_haproxy:/usr/local/zabbix_agents_3.2.0/scripts]# cat redis_servers.txt
- 172.20.103.202:7000:eus_filmora_redis01
- 172.20.103.202:7001:eus_filmora_redis01
- 172.20.103.203:7000:eus_filmora_redis02
- 172.20.103.203:7000:eus_filmora_redis02
- 172.20.73.210:7000:eus_filmora_redis04
- 172.20.73.210:7001:eus_filmora_redis04
- 172.20.73.211:7000:eus_filmora_redis03
- 172.20.73.211:7001:eus_filmora_redis03
- 172.20.103.202:7002:eus_filmora_redis01
- 172.20.103.202:7003:eus_filmora_redis01
- 172.20.103.203:7002:eus_filmora_redis02
- 172.20.103.203:7003:eus_filmora_redis02
- 172.20.73.210:7002:eus_filmora_redis04
- 172.20.73.210:7003:eus_filmora_redis04
- 172.20.73.211:7002:eus_filmora_redis03
- 172.20.73.211:7003:eus_filmora_redis03
- # 配置文件
- UserParameter=Web.ip.discovery,/usr/local/zabbix_agents_3.2.0/scripts/redis_server_status.sh web_ip_discovery
- UserParameter=Web.ip.code[*],/usr/local/zabbix_agents_3.2.0/scripts/redis_server_status.sh web_site_code $1
- # 测试
- [[email protected]_filmora_haproxy:/usr/local/zabbix_agents_3.2.0/scripts]# /usr/local/zabbix_agents_3.2.0/scripts/redis_server_status.sh web_ip_discovery
- {
- "data":[
- {
- "{#SITENAME}":"172.20.103.202:7000:eus_filmora_redis01"},
- {
- "{#SITENAME}":"172.20.103.202:7001:eus_filmora_redis01"},
- {
- "{#SITENAME}":"172.20.103.203:7000:eus_filmora_redis02"},
- {
- "{#SITENAME}":"172.20.103.203:7000:eus_filmora_redis02"},
- {
- "{#SITENAME}":"172.20.73.210:7000:eus_filmora_redis04"},
- {
- "{#SITENAME}":"172.20.73.210:7001:eus_filmora_redis04"},
- {
- "{#SITENAME}":"172.20.73.211:7000:eus_filmora_redis03"},
- {
- "{#SITENAME}":"172.20.73.211:7001:eus_filmora_redis03"},
- {
- "{#SITENAME}":"172.20.103.202:7002:eus_filmora_redis01"},
- {
- "{#SITENAME}":"172.20.103.202:7003:eus_filmora_redis01"},
- {
- "{#SITENAME}":"172.20.103.203:7002:eus_filmora_redis02"},
- {
- "{#SITENAME}":"172.20.103.203:7003:eus_filmora_redis02"},
- {
- "{#SITENAME}":"172.20.73.210:7002:eus_filmora_redis04"},
- {
- "{#SITENAME}":"172.20.73.210:7003:eus_filmora_redis04"},
- {
- "{#SITENAME}":"172.20.73.211:7002:eus_filmora_redis03"},
- {
- "{#SITENAME}":"172.20.73.211:7003:eus_filmora_redis03"}]}
- [[email protected]_filmora_haproxy:/usr/local/zabbix_agents_3.2.0/scripts]# /usr/local/zabbix_agents_3.2.0/scripts/redis_server_status.sh web_site_code 172.20.73.210:7002:eus_filmora_redis04
- 200
来源: http://www.bubuko.com/infodetail-3034737.html