Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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 .

share|improve this question

3 Answers 3

up vote 3 down vote accepted

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()
share|improve this answer
    
It just needs a config dialog and it's perfect ;) –  João Pinto Nov 9 '10 at 16:04
    
That, a menu indicating which page is offline in case you missed the notification, a possibility to exit, nice icons, packaging, etc. etc. - unfortunately I'm way too unmotivated. :P –  htorque Nov 9 '10 at 16:09

You can install the link-monitor-applet Install link-monitor-applet (homepage : http://www.nongnu.org/link-monitor/) 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.

share|improve this answer
    
I do want a GET and check for an HTTP 200 (ok) reply. –  João Pinto Nov 9 '10 at 15:50

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 (67.215.65.132) 56(84) bytes of data.
64 bytes from hit-nxdomain.opendns.com (67.215.65.132): icmp_req=1 ttl=54 time=33.1 ms
64 bytes from hit-nxdomain.opendns.com (67.215.65.132): icmp_req=2 ttl=54 time=32.8 ms
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.