You want to get notified is something goes weird on a web site you develop and that should be running 24/7?
Given a list of url, you want to check if they exist and send receive an email in case of trouble.
The problem is so common and hundreds of solutions exists on the web, from simple crontab shell to more complex system (hyperic & co).
We propose here one more system. The constraints were:
- check availability of url, response time or contents,
- get email to be notified in case of failure,
- a simple configuration system.
Perl is perfect for that task. Install URL::Check from CPAN
sudo perl -MCPAN -e 'install URL::Check'
A script url-check.pl is installed in the default script directory.
To get mail sent, your server must be able to sendmail with basic sendmail...
Or add in crontab, to get it run every hour:
0 * * * * url-check.pl --config=my-config.txt
Well, everything resides here. Here is an example from the CPAN package
#report errors on console
#report errors via mail
#just check if the page can be loaded
#check is this page can be loaded in less than 30s
#we check for the google page in 5ms, so that should produce an error...
#check that a text is contained in a url. Those should produce error
check.contains=microsoft is the best
check.contains=ipad is only for dummies
#this should work