Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 29 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions src/main/java/com/airhacks/ping/boundary/HealthResource.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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() {
Expand Down
3 changes: 3 additions & 0 deletions src/main/webapp/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ <h2>Health</h2>
<article>
<a href="./resources/health/start-time">Start (boot) time</a>
</article>
<article>
<a href="./resources/health/uptime">Uptime in milliseconds</a>
</article>
<article>
<a href="./resources/health/current-memory">Current memory stats</a>
</article>
Expand Down