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.

  JVM processjavamonhttp://IP:port/metricsPrometheus

 

The following metrics are exposed:

Metric nameMetric typeUnitsDescription
heap_size_bytesgaugebytesCurrent JVM heap size
heap_free_bytesgaugebytesBytes currently available in the Java heap
uptime_seccountersecondsSeconds since last javamon restart (normally this value matches the JVM uptime)

  •  

    Constructor Summary

    ConstructorDescription
    javamon(String host, int port)
    Allocates a new javamon object configured for the given host or IP address and port number. The HTTP listener will bind after calling start() 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 new javamon object. The HTTP listener will bind to the specified host (hostname or IP address) and port number after calling start().
      Parameters:
      host - the HTTP listener hostname or IP address. If null, the listener is bound to 0.0.0.0.
      port - the HTTP listener port number, or 0 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 this javamon 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, if javamon is used as a Java library.

        The following system properties are supported:

        PropertyDescriptionDefault value
        jm.hostThe HTTP endpoint hostname or IP address127.0.0.1
        jm.portThe HTTP endpoint port9091
        jm.mainThe Java application main class

        For security reasons, the default javamon host is not 0.0.0.0, but 127.0.0.1. Therefore, if the jm.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