Skip to content

Instantly share code, notes, and snippets.

@MarshalW
Last active January 8, 2021 14:25
Show Gist options
  • Select an option

  • Save MarshalW/4e143a243a00db41ed631a4b56b1bd65 to your computer and use it in GitHub Desktop.

Select an option

Save MarshalW/4e143a243a00db41ed631a4b56b1bd65 to your computer and use it in GitHub Desktop.
简易的网站HTTP监控

简易的网站HTTP监控

需要安装httpie

执行命令:

watch -n 60 'xargs ./check.sh < urls.txt'  
#!/bin/bash
for url in "$@"
do
if http --check-status --timeout=5.5 HEAD $url &> /dev/null; then
echo "200 OK, $url"
else
case $? in
2) echo "Request timed out! $url" ;;
3) echo "Unexpected HTTP 3xx Redirection! $url" ;;
4) echo "HTTP 4xx Client Error! $url" ;;
5) echo "HTTP 5xx Server Error! $url" ;;
6) echo "Exceeded --max-redirects=<n> redirects! $url" ;;
*) echo "Other Error! $url" ;;
esac
fi
done
https://www.baidu.com
https://www.qq.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment