监控域名脚本
[root@k8s-master01 shell]# cat erp_url.sh
#!/bin/bash
# function:monitor tcp connect status from zabbix
# License: GPL
# Auto: hanye
# version:1.0 date:2021-01-14
WEB_SITE_discovery () {
WEB_SITE=($(cat /usr/local/zabbix/shell/erp_url.txt|grep -v "^#"))
printf '{\n'
printf '\t"data":[\n'
for((i=0;i<${#WEB_SITE[@]};++i))
{
num=$(echo $((${#WEB_SITE[@]}-1)))
if [ "$i" != ${num} ];
then
printf "\t\t{ \n"
printf "\t\t\t\"{#SITENAME}\":\"${WEB_SITE[$i]}\"},\n"
else
printf "\t\t{ \n"
printf "\t\t\t\"{#SITENAME}\":\"${WEB_SITE[$num]}\"}]}\n"
fi
}
}
web_site_code () {
curl -I -m 10 -o /dev/null -s -w %{http_code} $1
}
case "$1" in
web_site_discovery)
WEB_SITE_discovery
;;
web_site_code)
web_site_code $2
;;
*)
echo "Usage:$0 {web_site_discovery|web_site_code [URL]}"
;;
esac
域名列表文件
[root@k8s-master01 shell]# cat erp_url.txt
baidu.com
51cto.com
创建模板
配置自动发现规则
配置 监控原型
配置触发器
配置图形原型