Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Jetty/Reference/jetty-monitor



Introduction

Jetty-monitor module allows developers and system administrators to monitor Jetty-based servers. It can run either inside Jetty process or as a standalone Java application, and can be used to monitor both regular and embedded Jetty servers. Jetty-monitor is as a consumer of Jetty JMX integration, allowing it to access MBeans that supply statistical and runtime information about Jetty components and web applications, as well as Java Virtual Machine itself. It can be configured to execute actions that are performed in the event trigger condition(s) based on value(s) of specified MBean attribute(s) are satisfied, as well as to call notifier(s) that would be called when an action is performed. Currently, only one action that simply calls the configured notifiers, and only logging and console output notifiers are provided out of the box, with ability to easily add custom actions and notifiers.

In addition, jetty-monitor provides an integration with Java-monitor service via a custom action. This integration allows posting the data about the server to a Java-monitor account and using it to monitor the server remotely as well as gathering information about server's performance and outages.

Installing jetty-monitor

In order to start using jetty-monitor, it is necessary to enable and configure jetty-jmx module in your server process first. For instructions on how to do that, please see Jetty JMX tutorial. If jetty-monitor is going to be run as a standalone Java application, then remote JMX connector must be enabled.

In-process Monitoring

To use jetty-monitor inside the Jetty server process, it needs to be added to the server classpath by copying it into {jetty.home}/lib/ext directory. To enable jetty-monitor for your server, you could either specify the jetty-monitor configuration file (see below) on the command line as follows, or add the name of this file to the end of the start.ini configuration file.

java -jar start.jar <mymonitor.xml>
Configuring in-process monitor

Jetty-monitor can be configured using the standard jetty.xml configuration file syntax. The following is an example of the jetty-monitor configuration file for the in-process monitor. It creates a monitor action (SimpleAction) that is configured to execute when the number of idle threads in Jetty's main thread pool is less than or equal to 4, or greater when 7. When this action is executed, it invokes a console notifier that outputs the message to the console.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
 
<Configure id="Monitor" class="org.mortbay.jetty.monitor.JMXMonitor">
  <Call name="addActions">
    <Arg>
      <Array type="org.mortbay.jetty.monitor.MonitorAction">
        <Item>
          <New class="org.mortbay.jetty.monitor.SimpleAction">
            <Arg>
              <New class="org.mortbay.jetty.monitor.triggers.OrEventTrigger">
                <Arg>
                  <Array type="org.mortbay.jetty.monitor.EventTrigger">
                    <Item>
                      <New
                        class="org.mortbay.jetty.monitor.triggers.LessThanOrEqualToAttrEventTrigger">
                        <Arg>org.eclipse.jetty.util.thread:type=queuedthreadpool,id=0
                        </Arg>
                        <Arg>idleThreads</Arg>
                        <Arg type="java.lang.Integer">4</Arg>
                      </New>
                    </Item>
                    <Item>
                      <New
                        class="org.mortbay.jetty.monitor.triggers.GreaterThanAttrEventTrigger">
                        <Arg>org.eclipse.jetty.util.thread:type=queuedthreadpool,id=0
                        </Arg>
                        <Arg>idleThreads</Arg>
                        <Arg type="java.lang.Integer">7</Arg>
                      </New>
                    </Item>
                  </Array>
                </Arg>
              </New>
            </Arg>
            <Arg>
              <New class="org.mortbay.jetty.monitor.ConsoleNotifier">
                <Arg>%s</Arg>
              </New>
            </Arg>
            <Arg type="java.lang.Long">500</Arg>
          </New>
        </Item>
      </Array>
    </Arg>
  </Call>
</Configure>

Standalone Application Monitoring

To start jetty-monitor as a standalone application, run the following command from the command line. The jetty-monitor configuration file needs to be specified on the command line, and it is required to specify the URL for the remote connector (see below).

java -cp jetty-all-server-[version].jar -jar jetty-monitor-[version].jar org.eclipse.jetty.monitor.JMXMonitor <monitor.xml>
Configuring standalone monitor

Configuration file for the standalone jetty-monitor uses the same format as the in-process monitor does. In order for jetty-monitor to be able to connect to the Jetty server it will be monitoring, the configuration file is required to specify the URL for the remote JMX connector as follows.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
 
<Configure id="Monitor" class="org.mortbay.jetty.monitor.JMXMonitor">
  <Call name="setUrl">
    <Arg>service:jmx:rmi://localhost/jndi/rmi://localhost:1099/jettyjmx</Arg>
  </Call>
  ...
</Configure>

Additional Resources

See Jetty JMX tutorial for instructions on how to configure Jetty JMX integration.

See jetty.xml syntax reference for more information on configuration file syntax.

Back to the top