The original answer was written for Ubuntu 11.10 & 12.04.
Since then, the indicator interface was changed for 12.10 & 13.04. However, the maintainer has not released a version since then for later Ubuntu versions. No code commits in the launchpad PPA has been made since first quarter 2013.
Thus I have forked the project, fixed a few bugs and made it available for 14.04 Trusty users. Feel free to check out the code on GitHub and help out with the maintenance.
how to for 14.04
It requires an indicator from my PPA together with a custom ping test script:
sudo add-apt-repository ppa:fossfreedom/indicator-sysmonitor
sudo apt-get update
sudo apt-get install indicator-sysmonitor
mkdir -p ~/scripts && cd ~/scripts
Copy and paste the code below into the new file and save & close.
Give the file execute permission:
chmod +x pingtest.sh
Start the indicator
Then in the indicator-preferences click New:
Then enter the details as shown:
i.e. use the command
Click OK, followed by the following actions 1,2,3 & 4:
if ping -c 1 -W 2 google.com > /dev/null; then