From version < 13.1 >
edited by Vincent Massol
on 2011/07/31
To version < 13.2 >
edited by Vincent Massol
on 2011/11/28
< >
Change comment: Added doc on how to setup JavaMelody

Summary

Details

Page properties
Content
... ... @@ -2,7 +2,8 @@
2 2  {{toc/}}
3 3  {{/box}}
4 4  
5 -There are 2 solutions you can use to monitor a running XWiki instance:
5 +There are various solutions you can use to monitor a running XWiki instance:
6 +* Install and configure [[JavaMelody>>http://code.google.com/p/javamelody/]]
6 6  * [[Use a Profiler>>http://dev.xwiki.org/xwiki/bin/view/Community/Profiling]]. This has the advantage of providing advanced information, but has the drawback of being resource intensive and thus slowing the XWiki instance. It also requires a special startupscript.
7 7  * Starting with XWiki Enterprise 2.4M2 we're now using the [[JMX Technology>>http://en.wikipedia.org/wiki/Java_Management_Extensions]] to provide runtime monitoring of XWiki instances. The following features are currently available:
8 8  ** Monitor the Velocity macro caches
... ... @@ -14,6 +14,42 @@
14 14  XWiki also has a [[Monitor Plugin>>platform:AdminGuide.Logging#HActivatingtheXWikimonitoringfeature]] that you can use to monitor execution times. However this plugin is going to be deprecated in the future and replaced by the JMX technology.
15 15  {{/info}}
16 16  
18 += JavaMelody =
19 +
20 +[[image:http://javamelody.googlecode.com/svn/trunk/javamelody-core/src/site/resources/screenshots/graphs.png>>http://code.google.com/p/javamelody/wiki/Screenshots||style="width:50%"]]
21 +
22 +To install JavaMelody for XWiki follow these steps (see the [[JavaMelody user guide for more details>>http://code.google.com/p/javamelody/wiki/UserGuide]]):
23 +* Download the latest [[javamelody.jar>>http://code.google.com/p/javamelody/downloads/list]] and [[jrobin-x.jar>>http://javamelody.googlecode.com/files/jrobin-1.5.9.jar]] and put them in ##WEB-INF/lib##
24 +* Edit ##web.xml## and add the following information:(((
25 +{{code}}
26 +...
27 +<filter>
28 + <filter-name>monitoring</filter-name>
29 + <filter-class>net.bull.javamelody.MonitoringFilter</filter-class>
30 +</filter>
31 +... other <filter>s from the default web.xml here ...
32 +
33 +<filter-mapping>
34 + <filter-name>monitoring</filter-name>
35 + <url-pattern>/*</url-pattern>
36 +</filter-mapping>
37 +... other <filter-mapping>s from the default web.xml here ...
38 +
39 +<listener>
40 + <listener-class>net.bull.javamelody.SessionListener</listener-class>
41 +</listener>
42 +... other <listener>s from the default web.xml here ...
43 +...
44 +{{/code}}
45 +)))
46 +* Edit ##hibernate.cfg.xml## and add:(((
47 +{{code}}
48 +<property name="jdbc.factory_class">net.bull.javamelody.HibernateBatcherFactory</property>
49 +{{/code}}
50 +)))
51 +
52 +Then restart XWiki and access JavaMelody at ##http:~//localhost:8080/xwiki/monitoring##.
53 +
17 17  = JMX Console =
18 18  
19 19  Since JMX is a standard you can use [[any JMX-compatible monitoring console>>http://stackoverflow.com/questions/1744900/what-is-the-best-or-most-commonly-used-jmx-console-client]] (most application servers provide a web-based JMX console). There's also such a console called [[JConsole>>http://java.sun.com/developer/technicalArticles/J2SE/jconsole.html]] and which is bundled by default in the Java Runtime you're using. To start it, simply execute the ##jconsole## executable.

There are 2 solutions you can use to monitor a running XWiki instance:

There are various solutions you can use to monitor a running XWiki instance:

  • Install and configure JavaMelody
  • Use a Profiler. This has the advantage of providing advanced information, but has the drawback of being resource intensive and thus slowing the XWiki instance. It also requires a special startupscript.
  • Starting with XWiki Enterprise 2.4M2 we're now using the JMX Technology to provide runtime monitoring of XWiki instances. The following features are currently available:
    • Monitor the Velocity macro caches
    • Monitor the JBossCache caches XWiki is using to cache Document data, Users & Groups data and more
    • (starting with XE 3.1) Monitor the JGroups channel and protocols (when the XWiki Cluster feature is turned on)
    • (starting with XE 3.1) Monitor the Logback Logging configuration and change it

XWiki also has a Monitor Plugin that you can use to monitor execution times. However this plugin is going to be deprecated in the future and replaced by the JMX technology.

JavaMelody

http://javamelody.googlecode.com/svn/trunk/javamelody-core/src/site/resources/screenshots/graphs.png

To install JavaMelody for XWiki follow these steps (see the JavaMelody user guide for more details):

  • Download the latest javamelody.jar and jrobin-x.jar and put them in WEB-INF/lib
  • Edit web.xml and add the following information:
    ...

     monitoring
     net.bull.javamelody.MonitoringFilter

    ... other s from the default web.xml here ...


     monitoring
     /*

    ... other s from the default web.xml here ...


     net.bull.javamelody.SessionListener

    ... other s from the default web.xml here ...
    ...
  • Edit hibernate.cfg.xml and add:
    name="jdbc.factory_class">net.bull.javamelody.HibernateBatcherFactory

Then restart XWiki and access JavaMelody at http://localhost:8080/xwiki/monitoring.

JMX Console

Since JMX is a standard you can use any JMX-compatible monitoring console (most application servers provide a web-based JMX console). There's also such a console called JConsole and which is bundled by default in the Java Runtime you're using. To start it, simply execute the jconsole executable.

XWiki Caches Monitoring

XWiki uses JBoss Cache and since JBoss Cache natively supports JMX we benefit from this feature directly (JBoss documentation available here).

Example showing all JBoss Caches in memory in a running instance, showing all the elements in the cache (example on the document cache):

jbosscache.png

Example showing Cache stats (for the document cache):

jbosscache-stats.png

Velocity Cache Monitoring

Velocity caches Velocity macros. XWiki offers a JMX view of the content of the Velocity caches.

JConsole examples showing the Velocity Cache monitoring:

jconsole1.png

jconsole2.png

JGroups Monitoring

JConsole example showing the JGroups monitoring:

jgroups.png

Interesting things to do on JGroups in the JMX console:

  • Change the log level on the protocols to enable logging
  • Disconnect a node from the cluster and reconnect it

Logback Monitoring

JConsole example showing how to modify the logging level for a category:

jmx-logging.png

Tomcat JMX Proxy Servlet

Tomcat has a JMX Proxy Servlet bundled in their manager webapp (see here and here for more details on Tomcat and JMX]].

Here's some useful URLs to use the JMX Servlet Proxy to list and set JGroups Protocol Levels:

  • To display the current log level for the TCPPING protocol: http://localhost:8080/manager/jmxproxy?qry=jgroups:type=protocol,cluster=event,protocol=TCPPING
  • To set the log level to info for the TCPPING protocol: http://localhost:8080/manager/jmxproxy?set=jgroups:type=protocol,cluster=event,protocol=TCPPING&att=Level&val=info

Using Groovy

It's possible to write a Groovy script in a wiki page to access the JMX MBeans.

Get Connected