4: zabbix5.0 automatically discovers website domain names and monitors access status and request time

Monitor domain name script

 [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

Domain name list file

[root@k8s-master01 shell]# cat erp_url.txt
    baidu.com
    51cto.com

Create template

4: zabbix5.0 automatically discovers website domain names and monitors access status and request time
Configure automatic discovery rules

4: zabbix5.0 automatically discovers website domain names and monitors access status and request time
4: zabbix5.0 automatically discovers website domain names and monitors access status and request time
Configure monitor prototype
4: zabbix5.0 automatically discovers website domain names and monitors access status and request time
4: zabbix5.0 automatically discovers website domain names and monitors access status and request time
4: zabbix5.0 automatically discovers website domain names and monitors access status and request time
Configure trigger
4: zabbix5.0 automatically discovers website domain names and monitors access status and request time
4: zabbix5.0 automatically discovers website domain names and monitors access status and request time
4: zabbix5.0 automatically discovers website domain names and monitors access status and request time
Configure graphical prototype
4: zabbix5.0 automatically discovers website domain names and monitors access status and request time

Host association template

4: zabbix5.0 automatically discovers website domain names and monitors access status and request time

Data monitoring will automatically appear after a while

Guess you like

Origin blog.51cto.com/9025736/2591709