and check the HTTP response code to interpret if the Internet connection is working fine.
Now yesterday, there was some problem with my Internet.LAN was connected fine but just I couldn't access any site.So I keep on getting notifications as the script couldn't find 200 in the wget response.Now I want to make sure that it displays me notification when I do have internet connectivity.So, checking for DNS and LAN connectivity is a bit overkill for me as I don't have that much specific need to figure out what problem it is. Here is my script to keep checking downtime for my blog: &1` FLAG=0 # Traverse the string considering it as an array of words for x in $RESULT; do if [ "$x" = '200' ]; then FLAG=1 # This means all good fi done if [ $FLAG -eq '0' ]; then # A good point is to check if the internet is working or not # Check if we have internet connectivity by some other site RESULT=`wget --spider for x in $RESULT; do if [ "$x" = '200' ]; then FLAG=1 # This means we do have internet connectivity and the blog is actually down fi done if [ $FLAG -eq '1' ]; then DISPLAY=:0 notify-send -t 2000 -i /home/ashfame/Dropbox/Ubuntu/icons/"Downtime Alert!
" " is down." fi fi exit This way I need to check for internet connectivity only where there is an issue with my blog response code.Its a bit heavy (as I am not using ping) but should not give any false positives. Also how can I randomize pinging to a different site everytime, like facebook, google, yahoo etc.Also (I was trying to avoid any I/O) I can write to a log file by which I can check the count of downtime checks and then skip further checks till the site is down or cause longer checks (10mins instead of every min). "Internet connectivity" does not have a clear definition, you can only test the connectivity to a specific service or set of services.If you mean "LAN" connectivity a good option is to ping your network gateway. If your provider has cached your DNS record, but DNS server is down, others can't access your site, even though monitoring says everything is fine.In layman terms, I would define Internet connectivity is if you can access internet. I just need to differentiate between if its working fine or there is problem out of the set of problem that can be responsible. You can write short workaround with multiple well known sites (for example and ping.funet.fi) and check return codes to determine whether any of these is reachable.You can automatically check return code by using variable is limiting number of ping packets to one.