![QQ截图20180707214246.png](http://www.xwblog.club/usr/uploads/2018/07/1349414879.png) ![QQ截图20180707214258.png](http://www.xwblog.club/usr/uploads/2018/07/4242477472.png) ```bash #!/bin/env bash #================================================================ # # systemos=centos6.9 # #this is Domain_Monitor script # Author:xw thank you!!! # Date:2018.7.7 # Description:Domain Monitor # wang.cong@aliyun.com #================================================================ function usage() { echo $"usage:$0 url" exit 1 } ##帮助函数 function check_url() { ##检测url wget --spider -q -o /dev/null --tries=1 -T 5 $1 ##采用wget返回值方法,这里的$1就是函数传参 #curl -s -o /dev/null $1 ##采用curl返回值方法也是可以的。 if [ $? -eq 0 ] then echo "$1 is yes." exit 0 else echo "$1 is fail." exit 1 fi } function main() { if [ $# -ne 1 ] ##主函数 then usage ##提示 fi check_url $1 ##接收函数的传参,即把结尾的$*传到这里 } main $* ##这里的$*就是把命令行接收的所有参数作为函数参数传给函数内部,常用手法 ``` ./Domain_Monitor.sh www.xwblog.club 测试 也可以添加到zabbix监控进行报警