Wiki source code of Monitoring

Version 27.1 by Denis Gervalle on 2017/11/18

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:
Ecaterina Moraru (Valica) 26.1 6
Maxime Sinclair 24.2 7 * Install and configure [[JavaMelody>>https://github.com/javamelody/javamelody/wiki]]
Ecaterina Moraru (Valica) 26.1 8 * [[Use a Profiler>>dev: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.
9 * Starting with XWiki 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 10 ** Monitor the Velocity macro caches
Vincent Massol 3.3 11 ** Monitor the JBossCache caches XWiki is using to cache Document data, Users & Groups data and more
Vincent Massol 8.1 12 ** (starting with XE 3.1) Monitor the JGroups channel and protocols (when the XWiki Cluster feature is turned on)
13 ** (starting with XE 3.1) Monitor the Logback Logging configuration and change it
Vincent Massol 1.1 14
Vincent Massol 2.3 15 {{info}}
Ecaterina Moraru (Valica) 26.4 16 XWiki also has a [[Monitor Plugin>>Documentation.AdminGuide.Logging||anchor="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 17 {{/info}}
18
Vincent Massol 13.2 19 = JavaMelody =
20
Vincent Massol 24.3 21 [[[[image:https://raw.githubusercontent.com/wiki/javamelody/javamelody/resources/screenshots/graphs.png||width="50%"]]>>https://github.com/javamelody/javamelody/wiki/Screenshots#charts||style="width:50%"]]
Vincent Massol 13.2 22
Maxime Sinclair 24.2 23 To install JavaMelody for XWiki follow these steps (see the [[JavaMelody user guide>>https://github.com/javamelody/javamelody/wiki/UserGuide]] for more details):
Ecaterina Moraru (Valica) 26.1 24
Maxime Sinclair 24.2 25 * Download the latest [[javamelody.jar>>https://github.com/javamelody/javamelody/releases]] and [[jrobin-x.jar>>https://github.com/javamelody/javamelody/releases/download/javamelody-core-1.49.0/jrobin-1.5.9.jar]] and put them in the ##WEB-INF/lib## folder
Vincent Massol 13.2 26 * Edit ##web.xml## and add the following information:(((
27 {{code}}
28 ...
29 <filter>
30 <filter-name>monitoring</filter-name>
31 <filter-class>net.bull.javamelody.MonitoringFilter</filter-class>
32 </filter>
Pascal Bastien 25.1 33 <!-- to enable BASIC authentication with username and password, but do no want to use a realm and "security-constraint"
34 <filter>
35 <filter-name>javamelody</filter-name>
36 <filter-class>net.bull.javamelody.MonitoringFilter</filter-class>
37 <init-param>
38 <param-name>authorized-users</param-name>
39 <param-value>user1:pwd1, user2:pwd2</param-value>
40 </init-param>
41 </filter> -->
Vincent Massol 13.2 42 ... other <filter>s from the default web.xml here ...
43
44 <filter-mapping>
45 <filter-name>monitoring</filter-name>
46 <url-pattern>/*</url-pattern>
47 </filter-mapping>
48 ... other <filter-mapping>s from the default web.xml here ...
49
50 <listener>
51 <listener-class>net.bull.javamelody.SessionListener</listener-class>
52 </listener>
53 ... other <listener>s from the default web.xml here ...
54 ...
55 {{/code}}
56 )))
57 * Edit ##hibernate.cfg.xml## and add:(((
58 {{code}}
59 <property name="jdbc.factory_class">net.bull.javamelody.HibernateBatcherFactory</property>
60 {{/code}}
61 )))
62
Ecaterina Moraru (Valica) 26.1 63 Then restart XWiki and access JavaMelody at ##http:~/~/localhost:8080/xwiki/monitoring##.
Vincent Massol 13.2 64
Denis Gervalle 27.1 65 {{warning}}
66 Recent versions of JavaMelody (at least 1.70+ ?) require the configuration in this guide to be adapted like this:
67
68 {{code}}
69 in web.xml:
70 -----------
71
72 <filter>
73 <filter-name>javamelody</filter-name>
74 <filter-class>net.bull.javamelody.MonitoringFilter</filter-class>
75 <async-supported>true</async-supported>
76 </filter>
77 <filter-mapping>
78 <filter-name>javamelody</filter-name>
79 <url-pattern>/*</url-pattern>
80 <dispatcher>REQUEST</dispatcher>
81 <dispatcher>ASYNC</dispatcher>
82 </filter-mapping>
83 <listener>
84 <listener-class>net.bull.javamelody.SessionListener</listener-class>
85 </listener>
86
87
88
89 in hibernate.cfg.xml:
90 ---------------------
91
92 <property name="connection.driver_class">net.bull.javamelody.JdbcDriver</property>
93 <property name="connection.driver">com.mysql.jdbc.Driver</property>
94 {{/code}}
95 {{/warning}}
96
Vincent Massol 1.1 97 = JMX Console =
98
Manuel Smeria 17.3 99 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 a console called [[JConsole>>http://docs.oracle.com/javase/7/docs/technotes/guides/management/jconsole.html]] which is bundled by default in the Java Runtime you're using. To start it, simply execute the ##jconsole## executable.
Vincent Massol 1.1 100
Vincent Massol 24.1 101 {{info}}
102 Note that starting with XWiki 6.3, if you're using the Standalone Distribution (which bundles Jetty) you can now use ##start_xwiki.sh -j## (or ##start_xwiki.sh ~-~-jmx##) to monitor/manage the Jetty instance itself (it adds Jetty-specific MBeans):
Vincent Massol 22.1 103
Vincent Massol 24.1 104 {{image reference="jettymbeans.png"/}}
105 {{/info}}
106
Vincent Massol 11.1 107 == XWiki Caches Monitoring ==
108
Vincent Massol 14.1 109 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 110
Manuel Smeria 17.3 111 Starting with XWiki 3.3 the default implementation is JBoss Infinispan.
Vincent Massol 14.1 112
113 === With JBoss Infinispan ===
114
115 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]]).
116
Manuel Smeria 17.3 117 {{info}}
Ecaterina Moraru (Valica) 26.1 118 Prior to XWiki 3.5 the JMX support was not enabled by default. To enable it, edit ##WEB-INF/cache/infinispan/config.xml## and uncomment the two places where the "jmx" string is mentioned
Manuel Smeria 17.3 119 {{/info}}
Vincent Massol 14.1 120
121 Example showing the cache list and some statistic for a given cache:
122
Manuel Smeria 17.3 123 {{image reference="infinispancache.png"/}}
Vincent Massol 14.1 124
Vincent Massol 20.1 125 Example showing how to clear a given cache from all its entries:
126
127 {{image reference="infinispancacheclearing.png"/}}
128
Vincent Massol 14.1 129 === With JBoss Cache ===
130
Manuel Smeria 17.3 131 Since JBoss Cache natively supports JMX we benefit from this feature directly (JBoss documentation available [[here>>https://access.redhat.com/knowledge/docs/en-US/JBoss_Enterprise_Web_Platform/5/html/JBoss_Cache_User_Guide/jmx_reference.html]]).
Vincent Massol 14.1 132
Vincent Massol 11.1 133 Example showing all JBoss Caches in memory in a running instance, showing all the elements in the cache (example on the document cache):
134
Silvia Macovei 17.2 135 {{image reference="jbosscache.png"/}}
Vincent Massol 11.1 136
137 Example showing Cache stats (for the document cache):
138
Silvia Macovei 17.2 139 {{image reference="jbosscache-stats.png"/}}
Vincent Massol 11.1 140
Vincent Massol 4.1 141 == Velocity Cache Monitoring ==
Vincent Massol 1.1 142
Vincent Massol 12.2 143 Velocity caches Velocity macros. XWiki offers a JMX view of the content of the Velocity caches.
144
Vincent Massol 4.1 145 JConsole examples showing the Velocity Cache monitoring:
146
Silvia Macovei 17.2 147 {{image reference="jconsole1.png"/}}
Vincent Massol 1.1 148
Silvia Macovei 17.2 149 {{image reference="jconsole2.png"/}}
Vincent Massol 1.1 150
Vincent Massol 4.1 151 == JGroups Monitoring ==
152
153 JConsole example showing the JGroups monitoring:
154
Silvia Macovei 17.2 155 {{image reference="jgroups.png"/}}
Vincent Massol 4.1 156
157 Interesting things to do on JGroups in the JMX console:
Ecaterina Moraru (Valica) 26.1 158
Vincent Massol 4.1 159 * Change the log level on the protocols to enable logging
160 * Disconnect a node from the cluster and reconnect it
161
Vincent Massol 10.1 162 == Logback Monitoring ==
163
164 JConsole example showing how to modify the logging level for a category:
165
Silvia Macovei 17.2 166 {{image reference="jmx-logging.png"/}}
Vincent Massol 10.1 167
Vincent Massol 7.1 168 = Tomcat JMX Proxy Servlet =
169
170 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]].
171
172 Here's some useful URLs to use the JMX Servlet Proxy to list and set JGroups Protocol Levels:
Ecaterina Moraru (Valica) 26.1 173
Vincent Massol 7.1 174 * To display the current log level for the TCPPING protocol: {{{http://localhost:8080/manager/jmxproxy?qry=jgroups:type=protocol,cluster=event,protocol=TCPPING}}}
175 * 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}}}
176
Vincent Massol 18.1 177 = Others =
Vincent Massol 7.1 178
Vincent Massol 18.1 179 * It's possible to [[write a Groovy script in a wiki page to access the JMX MBeans>>extensions:Extension.JMX Access]].
180 * [[JMX Monitoring Application>>extensions:Extension.JMX Monitoring Application]]
Vincent Massol 19.1 181 * [[XInit>>extensions:Extension.Xinit]]

Get Connected