Introduction

The goal of this toolkit is to provide a quick way to set up a status page in a Java application and provides runtime informations (services statistics, configuration values, batch process state) which really helps for both development and production.

Quickstart for webapps

This project is best used with Maven.

Add Maven dependency :

<repository>
	<id>appstatus-repository</id>
	<name>App Status repository</name>
	<url>http://appstatus.sourceforge.net/maven2/repository</url>
</repository>

(...)

<dependency>
    	<groupId>net.sf.appstatus </groupId>
    	<artifactId>appstatus-web</artifactId>
    	<version>0.4.5</version>
    	<scope>compile</scope>
</dependency>

Add servlet to web.xml :

<servlet>
        <servlet-name>status</servlet-name>
        <servlet-class>net.sf.appstatus.web.StatusServlet</servlet-class>
</servlet>
        
<servlet-mapping>
        <servlet-name>status</servlet-name>
        <url-pattern>/status</url-pattern>
</servlet-mapping>

Create a test for your application (implementing ICheck):

public class GooglePingStatusChecker extends AbstractCheck {

	public ICheckResult checkStatus() {
		ICheckResult result = null;

		try {
			InetAddress address = InetAddress.getByName("www.google.com");

			if (address.isReachable(2000)) {
				result = createResult(OK);
				result.setDescription("Google Access ok");

			} else {
				throw new Exception("Ping timeout (2000ms)");
			}

		} catch (Exception e) {
			result = createResult(WARN);
			result.setDescription("Google ping failed");
			result.setResolutionSteps("Ping failed. This means that ICMP messages are blocked by this host. (This may not be an issue) "
					+ e.getMessage());

		}

		return result;
	}

	public String getGroup() {
		return "google";
	}

	public String getName() {
		return "Google Ping check";
	}

}		

Register the test in /status-check.properties :

			check.google.ping=net.sf.appstatus.dummy.GooglePingStatusChecker
		

Go to http://<server>/<app-context>/status :

Status page example

Reporting war details for webapps built with Maven

If you are using Maven to build your webapp, AppStatus provides a property provider which reports artifactId, groupId and version. Just add the following property provider :

			property.maven=net.sf.appstatus.core.property.impl.WarMavenVersionProvider
		

Reporting JVM informations

			property.jvm=net.sf.appstatus.core.property.impl.JvmPropertyProvider
		

Reporting Host informations

Both hostname and ip are reported.

			property.localhost=net.sf.appstatus.core.property.impl.HostPropertyProvider