web站点可用性监控

背景:
web.txt


#官网
https://platscan.platon.network/
#游戏
https://horsemango.com      
https://horsemango.com/game/
#基金会官网
https://latticex.foundation/

##################    web可用性监控 ###############
UserParameter=web.discovery, /etc/zabbix/script/web.sh discovery
UserParameter=web.code[*],   /etc/zabbix/script/web.sh code $1

web.sh

#!/bin/bash
shell_dir=$(dirname $(readlink -f "$0"))
web_file=web.txt
discovery(){
    last_list=$(cat ${shell_dir}/${web_file} |grep -Ev "(^$|^#)"|tail -1)
    echo -e "{\"data\":["
    for i in `cat ${shell_dir}/${web_file} |grep -Ev "(^$|^#)"`
    {
        if [ $i != $last_list ];then
            echo -e "\t  {\"{#WEB}\":\"$i\"},"
        else 
            echo -e "\t  {\"{#WEB}\":\"$i\"}\n]}"
        fi
    }
}
code(){
    /usr/bin/curl  -k -o /dev/null -s -w %{http_code} -L --connect-timeout 10  $1
}
case "$1" in
    discovery)
        discovery
    ;;

    code)
        code $2
    ;;
    *)
        echo "Usage:$0 [discovery |code [url]]"
    ;;
esac

curl -o /dev/null -s -w %{time_namelookup}---%{time_connect}---%{time_starttransfer}---%{time_total}---%{speed_download}"\n" https://platscan.test.platon.network

你可能感兴趣的:(web站点可用性监控)