What software is there that will play an alert (PC speaker) when there isn't any internet connectivity for 5 minutes?My switch/router seems to disconnect every few days, and I want to reset it when it happens.PC          -- TP-Link switch/router -- FO192.168.x.1 -- 192.168.x.2 / x.y.z.a -- a.b.c.d
Internet connection drop alert
networking;monitoring
You can use a modified version of this script to do what you want:#!/bin/bashdownTime=0lastAccessTime=$(date +%s)while [ true ]; doif ! ping -c1 google.com >& /dev/null; then    downTime=$(( $(date +%s) - $lastAccessTime ))else    downTime=0    lastAccessTime=$(date +%s)fisleep 15if [ $downTime -ge 300 ]; then   echo alertfidoneWe're CONNECTED ExampleWith debugging turned on so you can see what the script's doing. set -xRunning with a valid hostname to demonstrate the connection is up state.$ ./watcher.bash+ downTime=0++ date +%s+ lastAccessTime=1402276955+ '[' true ']'The above initializes a couple of variables and determines the last time we went through the loop, $lastAccessTime. We now try to ping Google.+ ping -c1 google.com+ downTime=0++ date +%s+ lastAccessTime=1402276955We now calculate any down time, $downTime, if ping fails, otherwise, we reset $downTime to zero, and recalculate $lastAccessTime.+ sleep 15Now we wait 15 seconds.+ '[' 0 -ge 300 ']'Now we check if we've been down for > 5 minutes (300 seconds). Then we repeat going through the while loop.+ '[' true ']'+ ping -c1 google.com+ downTime=0++ date +%s+ lastAccessTime=1402276970+ sleep 15....As long as we're up, nothing will happen other than we check with the ping command every 15 seconds.We're DISCONNECTED ExampleNow to simulate a connection is down state, we'll swap out the hostname we're pinging and use a fake one, google1234567890.com. Repeating a run of our script with debugging enabled we now see some actual down time getting calculated.$ ./watcher.bash+ downTime=0++ date +%s+ lastAccessTime=1402277506+ '[' true ']'+ ping -c1 google1234567890.com++ date +%s+ downTime=0+ sleep 15+ '[' 0 -ge 300 ']'+ '[' true ']'+ ping -c1 google1234567890.com++ date +%s+ downTime=15+ sleep 15...Notice above that $downTime is equal to 15 seconds so far. If we wait a while longer we'll see this:+ '[' true ']'+ ping -c1 google1234567890.com++ date +%s+ downTime=300+ sleep 15We've accrued 300 seconds of down time. So now when we check, we print the message, alert.+ '[' 300 -ge 300 ']'+ echo alertalert+ '[' true ']'+ ping -c1 google1234567890.com++ date +%s+ downTime=315+ sleep 15This state will continue until the connection is restored and the ping is once again successful.So what about a sound?That's easy. You can use a variety of tools to do this. I would use something like sox or mplayer to play an audio file such as an .mp3 or .wav file with an appropriate sound you want to hear every 15 seconds, while the connection is down.mplayer someaudio.wavSimply replace the alert message above with this line to get audio feedback that the connection is down.Timing out issues with pingIf you use ping in the manner above you'll likely encounter a slow lag time where it takes ping literally 10-20 seconds for it to fail when the connection is down. See my answer to this U&L Q&A titled: How to redirect the output of any command? for an example using the command line tool fing instead. This tool will fail more quickly than the traditional ping.