Recently, just need to test the stability of the new station, so write a shell script to the local (recently changed MAC), to real-time view you need to monitor the status of the Web page, and sent to the designated mailbox.
Here's a compliment. OS X with crontab scheduled tasks, you can test the script directly on the native ^_^
# VI check_web_alive.sh
Copy Code code as follows:
#!/bin/bash
Path=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
Export PATH
# define URL
Web_url= ("http://www.example.com" "http://www1.example.com" "http://www2.example.com")
# Check Network
net_alive=$ (ping-c 5 8.8.8.8 |grep ' received ' |awk ' BEGIN {fs= ', "} {print $} ' |awk ' {print $} ')
if [$NET _alive = 0]; Then
echo "Network is not active,please check your network configuration!"
Exit 0
Fi
# Check URL
for ((i=0; i!=${#WEB_URL [@]}; ++i))
{
alive=$ (Curl-o/dev/null-s-M 10-connect-timeout 10-w%{http_code} ${web_url[i]} |grep "000000")
If ["$ALIVE" = = "000000"]; Then
echo "' ${web_url[i]} ' can not be open,please check! | Mail-s "Website Notification to ${web_url[i]}" yourname@example.com
echo "Failed"
Else
echo "' ${web_url[i]} ' is ok!"
Fi
}