Ubuntu: Need an applet to report web sites unavailability


Is there a gnome applet that will let me configure a list of URLs to be verified and report when some is unavailable ? Preferably using notifiations.

The validation must use HTTP GET or HEAD .


Maybe you can take this as a base (needs python-appindicator and python-notify):

import gtk  import gobject  import urllib2  import pynotify  import appindicator    urls = ["http://askubuntu.com",          "http://not.available.com"]    ind = appindicator.Indicator("url-checker", "indicator-messages",                                appindicator.CATEGORY_APPLICATION_STATUS)  ind.set_status(appindicator.STATUS_ACTIVE)  ind.set_attention_icon ("indicator-messages-new")  menu = gtk.Menu()  # yadda yadda yadda  ind.set_menu(menu)    def update(urls, ind):      err = ""      for url in urls:          try:              if (urllib2.urlopen(url).getcode() != 200):                  err += "%s is down\n" % url          except urllib2.URLError:              err += "%s is down\n" % url      if err:          ind.set_status(appindicator.STATUS_ATTENTION)          pynotify.Notification("Bad news:", err).show()      else:          ind.set_status(appindicator.STATUS_ACTIVE)        return True    update(urls, ind)  timeout = 300000 # 5 minutes  gobject.timeout_add(timeout, update, urls, ind)  gtk.main()  


You could write a small bash script to throw notifications at you... Something like:

#!/bin/bash    for site in $(cat ~/.sites); do      if ! ping -c 1 -w 5 "$site" &>/dev/null ; then         notify-send "$site is down!!"      fi  done  

Your list of sites to check lives in ~/.sites.

Then you just need to cron that up to run. You might need to export DISPLAY=:0 in cron so the notification shows up in the right place.

Note that if you use a DNS intermediary like OpenDNS, if a domain name you ping doesn't exist, it'll hit their no-domain search server. Therefore it's probably safer (though less informative) to use IPs.

oli@bert:~$ ping asasdslfkjsdlff.com  PING asasdslfkjsdlff.com ( 56(84) bytes of data.  64 bytes from hit-nxdomain.opendns.com ( icmp_req=1 ttl=54 time=33.1 ms  64 bytes from hit-nxdomain.opendns.com ( icmp_req=2 ttl=54 time=32.8 ms  


You can install the link-monitor-applet (see the homepage) which puts this functionality on your gnome panel very elegantly. Link Monitor is in repositories, so :

sudo apt-get install link-monitor-applet  

However, I suspect that since you said "URL" you might be looking at something that does a GET to the websites, reporting if it doesn't get a response? Can you clarify if a simple ping is enough? Some websites, for example, won't let you ping them. Worse, getting a ping doesn't guarantee that the website is actually up.

Since you've specified that you'd like this solution to be URL-based, you can use Oli's solution above, but first :

sudo apt-get install httping

And the script becomes :

#!/bin/bash    for site in $(cat ~/.sites); do      if ! httping -c 1 -g "$site" &>/dev/null ; then         notify-send "$site is down!!"      fi  done  

NOTE : This wasn't working for me until I realised that I had configured my home router to use OpenDNS. This means that timed-out sites are redirected to the OpenDNS landing page instead, meaning that this script never generated an on-screen notification! One to watch.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »