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

Difference between revisions of "Jetty/Reference/jetty-monitor"

m
Line 14: Line 14:
 
# If you plan to run jetty-monitor as a standalone Java application, enable the remote JMX connector.
 
# If you plan to run jetty-monitor as a standalone Java application, enable the remote JMX connector.
  
== Configuring the In-process Monitor ==
+
=== Configuring the In-process Monitor ===
  
 
You can configure Jetty-monitor using the standard <tt>jetty.xml</tt> configuration file [[Jetty/Reference/jetty.xml_syntax|syntax]]. The following is an example of the jetty-monitor configuration file for the in-process monitor. It creates a monitor action (SimpleAction) that executes when the number of idle threads in Jetty's main thread pool is less than or equal to four, or greater than seven. When this action executes, it invokes a console notifier that outputs the message to the console.
 
You can configure Jetty-monitor using the standard <tt>jetty.xml</tt> configuration file [[Jetty/Reference/jetty.xml_syntax|syntax]]. The following is an example of the jetty-monitor configuration file for the in-process monitor. It creates a monitor action (SimpleAction) that executes when the number of idle threads in Jetty's main thread pool is less than or equal to four, or greater than seven. When this action executes, it invokes a console notifier that outputs the message to the console.
Line 76: Line 76:
 
</source>
 
</source>
  
== Configuring the Standalone Monitor ==
+
=== Configuring the Standalone Monitor ===
  
 
The configuration file for the standalone jetty-monitor uses the same format as the in-process monitor does. For jetty-monitor to be able to connect to the Jetty server you want it to monitor, the configuration file must specify the URL for the remote JMX connector as follows:
 
The configuration file for the standalone jetty-monitor uses the same format as the in-process monitor does. For jetty-monitor to be able to connect to the Jetty server you want it to monitor, the configuration file must specify the URL for the remote JMX connector as follows:
Line 92: Line 92:
 
</source>
 
</source>
  
=== Starting Standalone Application Monitoring ===
+
=== Starting Standalone Application Monitor ===
  
 
To start jetty-monitor as a standalone application, run the following command from the command line. You must specify
 
To start jetty-monitor as a standalone application, run the following command from the command line. You must specify

Revision as of 16:58, 5 May 2011



Introduction

Jetty-monitor module enables developers and system administrators to monitor Jetty-based servers.

  • It can run either inside a Jetty process or as a standalone Java application.
  • You can use it to monitor both regular and embedded Jetty servers.

Jetty-monitor is 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. You can configure it to execute actions if trigger condition(s) that you specify in MBean attribute value(s) are satisfied, as well as to call notifier(s) when it executes such actions. Currently, we provide only one action that calls the configured notifiers, and only logging and console output notifiers out of the box, but you can easily add custom actions and notifiers.

Jetty-monitor includes an integration with Java-monitor service via a custom action. This integration enables 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 performance and outages.

Installing jetty-monitor

To start using jetty-monitor:

  1. Enable and configure the jetty-jmx module in your server process. See Jetty JMX tutorial for instructions.
  2. If you plan to run jetty-monitor as a standalone Java application, enable the remote JMX connector.

Configuring the In-process Monitor

You can configure Jetty-monitor 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 executes when the number of idle threads in Jetty's main thread pool is less than or equal to four, or greater than seven. When this action executes, 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>

Starting the In-process Monitor

To use jetty-monitor inside the Jetty server process, add it to the server classpath by copying it into {jetty.home}/lib/ext directory. To enable jetty-monitor for your server, you can either specify the jetty-monitor configuration file 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 the Standalone Monitor

The configuration file for the standalone jetty-monitor uses the same format as the in-process monitor does. For jetty-monitor to be able to connect to the Jetty server you want it to monitor, the configuration file must 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>

Starting Standalone Application Monitor

To start jetty-monitor as a standalone application, run the following command from the command line. You must specify

  • The jetty-monitor configuration file.
  • The URL for the remote connector.
java -cp jetty-all-server-[version].jar -jar jetty-monitor-[version].jar org.eclipse.jetty.monitor.JMXMonitor <monitor.xml>

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