您好,登錄后才能下訂單哦!
zabbix 簡單監控ipv6地址的連通性,參照Template ICMP Ping模板
0-1、服務器已有ipv6地址,ipv6涉及配置文件(部分可不管):
/usr/share/oem/grub.cfg
/etc/modprobe*
/etc/sysconfig/network
/etc/sysctl.conf /etc/sysctl.conf.first
/etc/ssh/sshd_config
/etc/sysconfig/network-scripts/ifcfg-$ifcfg
/etc/sysconfig/network-scripts/route6-$ifcfg # ip -6 route add default dev "$ifcfg"
modprobe ipv6 && lsmod | grep ipv6
ip6tables
...
0-2、zabbix server端編譯(建議不開ipv6也可加上):
./configure --prefix=/usr/local/zabbix/ --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --enable-ipv6
make; make install # 重編譯安裝不會覆蓋老的配置文件等
1-0、因為fping和fping6是區分的,但zabbix本身會不支持兩個同時啟用且能識別ipv6地址,需要應下載最新fping包編譯安裝(或者自定義shell腳本過濾ipv4地址使之兼容,但相對繁瑣些。廢棄!)
wget http://www.fping.org/dist/fping-4.2.tar.gz
tar xf fping-4.2.tar.gz && cd fping-4.2
./configure && make && make install
chmod u+x /usr/local/sbin/fping
cp -ra /usr/sbin/fping{,.bak} && cp -ra /usr/sbin/fping6{,.bak}
cp -ra /usr/local/sbin/fping /usr/sbin/fping
# 可先測試看新fping是否兼容ipv4和ipv6
1-1、取消注釋Fping6Location=,且置空值
1-2、重啟zabbix_server
1-3、ps aux | grep fping # 查看沒有fping6就對了,不然之前同時存在fping和fping6命令的操作且fping不支持ipv6就會頁面顯示【Cannot send ICMP ping packets to this host.】
2-1、自定義發現key:
UserParameter=discovery.ipv6,sh /usr/local/zabbix/scripts/discovery_ipv6.sh discovery_ipv6
2-2、授權:
chown zabbix:zabbix /usr/local/zabbix/scripts/discovery_ipv6.sh
chmod +x /usr/local/zabbix/scripts/discovery_ipv6.sh
2-3、重啟zabbix_agentd
3-1、創建模板:
3-2、創建自動發現規則:
3-3、創建監控原型:
3-4、創建觸發器原型:
3-5、鏈接關聯Template IPv6 Address模板到監控原始模板(母模板)
4-1、ipv6地址可自動發現亦可根據資源記錄api獲取
4-2、其他監控如ip6tables加入/etc/sudoers用戶允許然后自定義防火墻監控
附件:
# cat /usr/local/zabbix/scripts/discovery_ipv6.sh
#!/bin/bash
# ipv6 地址發現
function discovery_ipv6(){
ipv6=($(ip a | grep 'scope global' | grep -oP '(?<=inet6 )[^/]+' | grep -v '^fe80'))
printf '{\n'
printf '\t"data":[\n'
for key in ${!ipv6[@]}
do
if [[ "${#ipv6[@]}" -gt 1 && "${key}" -ne "$((${#ipv6[@]}-1))" ]];then
printf '\t {\n'
printf "\t\t\t\"{#IPV6ADDRESS}\":\"${ipv6[${key}]}\"},\n"
else [[ "${key}" -eq "((${#ipv6[@]}-1))" ]]
printf '\t {\n'
printf "\t\t\t\"{#IPV6ADDRESS}\":\"${ipv6[${key}]}\"}\n"
fi
done
printf '\t ]\n'
printf '}\n'
}
if [ -z "$1" -o "$1" = "discovery_ipv6" ]; then
discovery_ipv6
else
echo "Usage: sh $0 [discovery_ipv6]"
exit 1
fi
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。