Package com.agent
Class javamon
java.lang.Object
java.lang.Thread
com.agent.javamon
public class javamon
extends java.lang.Thread
Javamon is a lightweight JVM monitoring agent. It is compatible with Java 1.4 and later.
Javamon exposes an HTTP endpoint compatible with Prometheus, an open source monitoring system.
The following metrics are exposed:
Metric name | Metric type | Units | Description |
---|---|---|---|
heap_size_bytes | gauge | bytes | Current JVM heap size |
heap_free_bytes | gauge | bytes | Bytes currently available in the Java heap |
uptime_sec | counter | seconds | Seconds since last javamon restart (normally this value matches the JVM uptime) |
-
Constructor Summary
Constructor Description javamon(String host, int port)
Allocates a newjavamon
object configured for the given host or IP address and port number. The HTTP listener will bind after callingstart()
on this object.-
Method Summary
Modifier and Type Method Description void
shut()
Signal the HTTP listener to shutdown gracefully.void
start()
Launch the HTTP endpoint in a separate thread.static void
main(String[] args)
Launch javamon as a wrapper from the command line.Methods inherited from class java.lang.Thread
activeCount checkAccess countStackFrames currentThread destroy dumpStack enumerate getContextClassLoader getName getPriority getThreadGroup holdsLock interrupt interrupted isAlive isDaemon isInterrupted join resume run setContextClassLoader setDaemon setName setPriority sleep stop suspend toString yield
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait
-
Constructor Details
-
javamon
public javamon(String host, int port)
Allocates a newjavamon
object. The HTTP listener will bind to the specifiedhost
(hostname or IP address) andport
number after callingstart()
.- Parameters:
host
- the HTTP listener hostname or IP address. Ifnull
, the listener is bound to0.0.0.0
.port
- the HTTP listener port number, or0
to use a port number that is automatically allocated.
-
Method Details
-
shut
public final void shut()Signal the HTTP listener to shutdown gracefully. Does nothing if the listener is already shutting down or already stopped. This method should be called before exiting the main thread. This method doesn't block. -
start
public final void start()Launch the HTTP endpoint in a separate thread. This method must be called at most once on thisjavamon
object.- Throws:
IllegalThreadStateException
- if the thread was already started.
-
main
public static final void main()Launch javamon as a wrapper from the command line. This method should not be called directly, ifjavamon
is used as a Java library.The following system properties are supported:
Property Description Default value jm.host The HTTP endpoint hostname or IP address 127.0.0.1 jm.port The HTTP endpoint port 9091 jm.main The Java application main class For security reasons, the default javamon host is not
0.0.0.0
, but127.0.0.1
. Therefore, if thejm.host
configuration parameter is missing or empty, the HTTP endpoint will be bound to localhost. This means that by default it will be accessible only if Prometheus is running on the same host.If
jm.main
is not specified, the wrapper will launch the HTTP endpoint only.
-
-
© 2025 Vladimir Kameñar
All rights reserved
-