Wiki source code of Monitoring

Version 13.4 by Vincent Massol on 2011/11/28

Show last authors
1 {{box cssClass="floatinginfobox" title="**Contents**"}}
2 {{toc/}}
3 {{/box}}
4
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/]]
7 * [[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 startup script.
8 * 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:
9 ** Monitor the Velocity macro caches
10 ** Monitor the JBossCache caches XWiki is using to cache Document data, Users & Groups data and more
11 ** (starting with XE 3.1) Monitor the JGroups channel and protocols (when the XWiki Cluster feature is turned on)
12 ** (starting with XE 3.1) Monitor the Logback Logging configuration and change it
13
14 {{info}}
15 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.
16 {{/info}}
17
18 = JavaMelody =
19
20 [[[[image:http://javamelody.googlecode.com/svn/trunk/javamelody-core/src/site/resources/screenshots/graphs.png||width="50%"]]>>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
54 = JMX Console =
55
56 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.
57
58 == XWiki Caches Monitoring ==
59
60 XWiki uses JBoss Cache and since JBoss Cache natively supports JMX we benefit from this feature directly (JBoss documentation available [[here>>http://docs.redhat.com/docs/en-US/JBoss_Enterprise_Web_Platform/5/html/JBoss_Cache_User_Guide/jmx_reference.html]]).
61
62 Example showing all JBoss Caches in memory in a running instance, showing all the elements in the cache (example on the document cache):
63
64 image:jbosscache.png
65
66 Example showing Cache stats (for the document cache):
67
68 image:jbosscache-stats.png
69
70 == Velocity Cache Monitoring ==
71
72 Velocity caches Velocity macros. XWiki offers a JMX view of the content of the Velocity caches.
73
74 JConsole examples showing the Velocity Cache monitoring:
75
76 image:jconsole1.png
77
78 image:jconsole2.png
79
80 == JGroups Monitoring ==
81
82 JConsole example showing the JGroups monitoring:
83
84 image:jgroups.png
85
86 Interesting things to do on JGroups in the JMX console:
87 * Change the log level on the protocols to enable logging
88 * Disconnect a node from the cluster and reconnect it
89
90 == Logback Monitoring ==
91
92 JConsole example showing how to modify the logging level for a category:
93
94 image:jmx-logging.png
95
96 = Tomcat JMX Proxy Servlet =
97
98 Tomcat has a JMX Proxy Servlet bundled in their ##manager## webapp (see [[here>>http://tomcat.apache.org/tomcat-6.0-doc/manager-howto.html]] and [[here>>http://tomcat.apache.org/tomcat-6.0-doc/monitoring.html]] for more details on Tomcat and JMX]].
99
100 Here's some useful URLs to use the JMX Servlet Proxy to list and set JGroups Protocol Levels:
101 * To display the current log level for the TCPPING protocol: {{{http://localhost:8080/manager/jmxproxy?qry=jgroups:type=protocol,cluster=event,protocol=TCPPING}}}
102 * 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}}}
103
104 = Using Groovy =
105
106 It's possible to [[write a Groovy script in a wiki page to access the JMX MBeans>>extensions:Extension.JMX Access]].

Get Connected