diff --git a/README.md b/README.md index 2782a6b..d231297 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,34 @@ -##A 9 kB WAR Ping For JavaEE 7 Application Servers +# Tiny Ping For JavaEE 7 Application Servers -Ping exposes via a convenient URI basic health / jndi / jvm and OS information. +Ping exposes basic health, JNDI, JVM and OS metrics via a convenient URI, +which enables an easy integration into application monitoring solutions +and smoke tests. The whole WAR file is only a couple of kilobytes in size. -Tested with GlassFish, Payara, TomEE, WLP and Wildfly +Tested with GlassFish, Payara, TomEE, WebSphere Liberty and Wildfly. -###Installation: +## Features: + + * Echo Resource `/resources/pings/echo/{message}` + * List system properties `/resources/pings/system-properties` + * List environment variables `/resources/pings/environment-variables` + * List java: namespace `/resources/pings/jndi/java:` + * List java:comp/env namespace `/resources/pings/jndi/java:comp/env` + * List jave:global namespace `/resources/pings/jndi/java:global` + * Start boot time `/resources/health/start-time` + * Uptime in milliseconds `/resources/health/uptime` + * Current memory stats `/resources/health/current-memory` + * Operating system stats `/resources/health/os-info` + +## Installation: Drop the WAR https://github.com/AdamBien/ping/releases/ into your autodeploy folder and access the application with http://localhost:[YOUR_PORT]/ping + +## Build: + +Ping can be built with Maven like this: + + mvn clean package + +Your WAR file will be written to the following directory: + + target/ping.war diff --git a/src/main/java/com/airhacks/ping/boundary/HealthResource.java b/src/main/java/com/airhacks/ping/boundary/HealthResource.java index 7e1dcf2..70ff14c 100644 --- a/src/main/java/com/airhacks/ping/boundary/HealthResource.java +++ b/src/main/java/com/airhacks/ping/boundary/HealthResource.java @@ -1,6 +1,8 @@ package com.airhacks.ping.boundary; import com.airhacks.ping.control.ServerWatch; +import java.time.ZonedDateTime; +import java.time.temporal.ChronoUnit; import javax.inject.Inject; import javax.json.Json; import javax.json.JsonObject; @@ -28,6 +30,13 @@ public String bootTime() { return this.watch.getDateTime().toString(); } + @GET + @Path("/uptime") + @Produces(MediaType.TEXT_PLAIN) + public String uptime() { + return Long.toString(ChronoUnit.MILLIS.between(this.watch.getDateTime(), ZonedDateTime.now())); + } + @GET @Path("/current-memory") public JsonObject availableHeap() { diff --git a/src/main/webapp/index.html b/src/main/webapp/index.html index e882599..e768b5b 100644 --- a/src/main/webapp/index.html +++ b/src/main/webapp/index.html @@ -35,6 +35,9 @@

Health

Start (boot) time
+
+ Uptime in milliseconds +
Current memory stats