I occasionally have problems with the power or with a machine that causes the web server on the machine to be inaccessible. This program was written to regularly check the sites that I administer. The program checks a set of URL's to ensure that it can connect and download the content. A report is generated that gives the status, either "ok" or the message from the exception, of each URL, and the report is sent to me via email. I use cron to run the program at the desired interval.
Example
To use the program you must first setup a configuration file. The first part provides the information needed to send the report:
to = you@yourdomain.com from = you@yourdomain.com subject = Website Status Report mail_server = cs.unt.edu
The second part provides a list of URL's to visit. The protocol specifier will be added automatically. Any number of sites can be checked. It will loop through the sites starting with site_0 and will keep going until there is no key site_n. A sample properties file is available in the downloads section.
site_0 = www.yourdomain.com site_1 = www.yourdomain.com:8080 site_2 = www.someotherdomain.com
To run:
- Set the classpath with the program itself and the jar files for Commons Email, JavaMail, and the Activation Framework.
- Run the program with the path to the configuration file as the only parameter.
If everything is in the current working directory the command would look like:
shell$ export CLASSPATH=./:commons-email.jar:javamail.jar:activation.jar shell$ java SiteCheck sample.properties
Third Party Libraries
- Commons Email: Used to send report via email.
- JavaMail: Needed for commons email.
- Activation Framework: Needed for JavaMail.