Wiki source code of Monitoring

Version 14.1 by Vincent Massol on 2012/01/10

Hide last authors
Vincent Massol 6.1 1 {{box cssClass="floatinginfobox" title="**Contents**"}}
2 {{toc/}}
3 {{/box}}
4
Vincent Massol 13.2 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/]]
Vincent Massol 13.4 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.
Silvia Macovei 3.2 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:
Vincent Massol 1.1 9 ** Monitor the Velocity macro caches
Vincent Massol 3.3 10 ** Monitor the JBossCache caches XWiki is using to cache Document data, Users & Groups data and more
Vincent Massol 8.1 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
Vincent Massol 1.1 13
Vincent Massol 2.3 14 {{info}}
Silvia Macovei 3.2 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.
Vincent Massol 2.3 16 {{/info}}
17
Vincent Massol 13.2 18 = JavaMelody =
19
Vincent Massol 13.3 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%"]]
Vincent Massol 13.2 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
Vincent Massol 1.1 54 = JMX Console =
55
Vincent Massol 2.2 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.
Vincent Massol 1.1 57
Vincent Massol 11.1 58 == XWiki Caches Monitoring ==
59
Vincent Massol 14.1 60 XWiki can use different cache implementations. The JBoss Cache and JBoss Infinispan implementations have nice JMX features available as shown below.
Vincent Massol 11.1 61
Vincent Massol 14.1 62 Since XWiki 3.3 the default implementation is JBoss Infinispan.
63
64 === With JBoss Infinispan ===
65
66 Since JBoss Infinispan natively supports JMX we benefit from this feature directly (JBoss documentation available [[here>>https://docs.jboss.org/author/display/ISPN/Management+Tooling]]).
67
68 {{info}}By default the JMX support is not enabled. To enable it, edit ##WEB-INF/cache/infinispan/config.xml## and uncomment the two places where the "jmx" string is mentioned{{/info}}
69
70 Example showing the cache list and some statistic for a given cache:
71
72 image:infinispancache.png
73
74 === With JBoss Cache ===
75
76 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]]).
77
Vincent Massol 11.1 78 Example showing all JBoss Caches in memory in a running instance, showing all the elements in the cache (example on the document cache):
79
80 image:jbosscache.png
81
82 Example showing Cache stats (for the document cache):
83
84 image:jbosscache-stats.png
85
Vincent Massol 4.1 86 == Velocity Cache Monitoring ==
Vincent Massol 1.1 87
Vincent Massol 12.2 88 Velocity caches Velocity macros. XWiki offers a JMX view of the content of the Velocity caches.
89
Vincent Massol 4.1 90 JConsole examples showing the Velocity Cache monitoring:
91
Vincent Massol 1.1 92 image:jconsole1.png
93
94 image:jconsole2.png
95
Vincent Massol 4.1 96 == JGroups Monitoring ==
97
98 JConsole example showing the JGroups monitoring:
99
100 image:jgroups.png
101
102 Interesting things to do on JGroups in the JMX console:
103 * Change the log level on the protocols to enable logging
104 * Disconnect a node from the cluster and reconnect it
105
Vincent Massol 10.1 106 == Logback Monitoring ==
107
108 JConsole example showing how to modify the logging level for a category:
109
110 image:jmx-logging.png
111
Vincent Massol 7.1 112 = Tomcat JMX Proxy Servlet =
113
114 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]].
115
116 Here's some useful URLs to use the JMX Servlet Proxy to list and set JGroups Protocol Levels:
117 * To display the current log level for the TCPPING protocol: {{{http://localhost:8080/manager/jmxproxy?qry=jgroups:type=protocol,cluster=event,protocol=TCPPING}}}
118 * 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}}}
119
Vincent Massol 13.1 120 = Using Groovy =
Vincent Massol 7.1 121
Vincent Massol 13.1 122 It's possible to [[write a Groovy script in a wiki page to access the JMX MBeans>>extensions:Extension.JMX Access]].

Get Connected