Wiki source code of Monitoring

Version 32.1 by Vincent Massol on 2020/08/04

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
Thomas Mortagne 29.1 7 * Install and configure [[Glowroot>>https://glowroot.org]]
Maxime Sinclair 24.2 8 * Install and configure [[JavaMelody>>https://github.com/javamelody/javamelody/wiki]]
Ecaterina Moraru (Valica) 26.1 9 * [[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.
Vincent Massol 32.1 10 * XWiki is using the [[JMX Technology>>http://en.wikipedia.org/wiki/Java_Management_Extensions]] to provide runtime monitoring of XWiki instances. The following features are available:
Vincent Massol 31.2 11 ** Monitor the InfiniSpan caches XWiki is using to cache Document data, Users & Groups data and more
12 ** Monitor the JGroups channel and protocols (when the XWiki Cluster feature is turned on)
13 ** Monitor the Logback Logging configuration and change it
14 ** Monitor Solr cores
Vincent Massol 32.1 15 ** Monitor Apache DBCP connection pool
16 ** Monitor Hibernate
Vincent Massol 1.1 17
Vincent Massol 2.3 18 {{info}}
Ecaterina Moraru (Valica) 26.4 19 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 20 {{/info}}
21
Thomas Mortagne 29.1 22 = Glowroot =
23
Vincent Massol 30.2 24 {{image reference="glowroot.png" width="650px"/}}
Thomas Mortagne 29.1 25
26 There is nothing specific about XWiki when you install Glowroot, just follow [[the standard documentation>>https://github.com/glowroot/glowroot/wiki/Agent-Installation-%28with-Embedded-Collector%29]].
27
Vincent Massol 13.2 28 = JavaMelody =
29
Vincent Massol 24.3 30 [[[[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 31
Maxime Sinclair 24.2 32 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 33
Maxime Sinclair 24.2 34 * 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 35 * Edit ##web.xml## and add the following information:(((
36 {{code}}
37 ...
38 <filter>
39 <filter-name>monitoring</filter-name>
40 <filter-class>net.bull.javamelody.MonitoringFilter</filter-class>
41 </filter>
Pascal Bastien 25.1 42 <!-- to enable BASIC authentication with username and password, but do no want to use a realm and "security-constraint"
Pascal Bastien 28.1 43 The storage files of statistics and of graphs are stored in the temporary directory of the server, unless if you have defined the "storage-directory" path
Pascal Bastien 25.1 44 <filter>
45 <filter-name>javamelody</filter-name>
46 <filter-class>net.bull.javamelody.MonitoringFilter</filter-class>
47 <init-param>
48 <param-name>authorized-users</param-name>
49 <param-value>user1:pwd1, user2:pwd2</param-value>
50 </init-param>
Pascal Bastien 28.1 51 <init-param>
52 <param-name>storage-directory</param-name>
53 <param-value>/path/of/javamelody/stats</param-value>
54 </init-param>
Pascal Bastien 25.1 55 </filter> -->
Vincent Massol 13.2 56 ... other <filter>s from the default web.xml here ...
57
58 <filter-mapping>
59 <filter-name>monitoring</filter-name>
60 <url-pattern>/*</url-pattern>
61 </filter-mapping>
62 ... other <filter-mapping>s from the default web.xml here ...
63
64 <listener>
65 <listener-class>net.bull.javamelody.SessionListener</listener-class>
66 </listener>
67 ... other <listener>s from the default web.xml here ...
68 ...
69 {{/code}}
70 )))
71 * Edit ##hibernate.cfg.xml## and add:(((
72 {{code}}
73 <property name="jdbc.factory_class">net.bull.javamelody.HibernateBatcherFactory</property>
74 {{/code}}
75 )))
76
Ecaterina Moraru (Valica) 26.1 77 Then restart XWiki and access JavaMelody at ##http:~/~/localhost:8080/xwiki/monitoring##.
Vincent Massol 13.2 78
Denis Gervalle 27.1 79 {{warning}}
80 Recent versions of JavaMelody (at least 1.70+ ?) require the configuration in this guide to be adapted like this:
81
82 {{code}}
83 in web.xml:
84 -----------
85
86 <filter>
87 <filter-name>javamelody</filter-name>
88 <filter-class>net.bull.javamelody.MonitoringFilter</filter-class>
89 <async-supported>true</async-supported>
90 </filter>
91 <filter-mapping>
92 <filter-name>javamelody</filter-name>
93 <url-pattern>/*</url-pattern>
94 <dispatcher>REQUEST</dispatcher>
95 <dispatcher>ASYNC</dispatcher>
96 </filter-mapping>
97 <listener>
98 <listener-class>net.bull.javamelody.SessionListener</listener-class>
99 </listener>
100
101
102
103 in hibernate.cfg.xml:
104 ---------------------
105
106 <property name="connection.driver_class">net.bull.javamelody.JdbcDriver</property>
107 <property name="connection.driver">com.mysql.jdbc.Driver</property>
108 {{/code}}
109 {{/warning}}
110
Vincent Massol 1.1 111 = JMX Console =
112
Manuel Smeria 17.3 113 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 114
Vincent Massol 24.1 115 {{info}}
116 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 117
Vincent Massol 24.1 118 {{image reference="jettymbeans.png"/}}
119 {{/info}}
120
Vincent Massol 11.1 121 == XWiki Caches Monitoring ==
122
Vincent Massol 14.1 123 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 124
Manuel Smeria 17.3 125 Starting with XWiki 3.3 the default implementation is JBoss Infinispan.
Vincent Massol 14.1 126
127 === With JBoss Infinispan ===
128
129 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]]).
130
Manuel Smeria 17.3 131 {{info}}
Ecaterina Moraru (Valica) 26.1 132 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 133 {{/info}}
Vincent Massol 14.1 134
135 Example showing the cache list and some statistic for a given cache:
136
Manuel Smeria 17.3 137 {{image reference="infinispancache.png"/}}
Vincent Massol 14.1 138
Vincent Massol 20.1 139 Example showing how to clear a given cache from all its entries:
140
141 {{image reference="infinispancacheclearing.png"/}}
142
Vincent Massol 14.1 143 === With JBoss Cache ===
144
Manuel Smeria 17.3 145 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 146
Vincent Massol 11.1 147 Example showing all JBoss Caches in memory in a running instance, showing all the elements in the cache (example on the document cache):
148
Silvia Macovei 17.2 149 {{image reference="jbosscache.png"/}}
Vincent Massol 11.1 150
151 Example showing Cache stats (for the document cache):
152
Silvia Macovei 17.2 153 {{image reference="jbosscache-stats.png"/}}
Vincent Massol 11.1 154
Vincent Massol 4.1 155 == Velocity Cache Monitoring ==
Vincent Massol 1.1 156
Vincent Massol 12.2 157 Velocity caches Velocity macros. XWiki offers a JMX view of the content of the Velocity caches.
158
Vincent Massol 4.1 159 JConsole examples showing the Velocity Cache monitoring:
160
Silvia Macovei 17.2 161 {{image reference="jconsole1.png"/}}
Vincent Massol 1.1 162
Silvia Macovei 17.2 163 {{image reference="jconsole2.png"/}}
Vincent Massol 1.1 164
Vincent Massol 4.1 165 == JGroups Monitoring ==
166
167 JConsole example showing the JGroups monitoring:
168
Silvia Macovei 17.2 169 {{image reference="jgroups.png"/}}
Vincent Massol 4.1 170
171 Interesting things to do on JGroups in the JMX console:
Ecaterina Moraru (Valica) 26.1 172
Vincent Massol 4.1 173 * Change the log level on the protocols to enable logging
174 * Disconnect a node from the cluster and reconnect it
175
Vincent Massol 10.1 176 == Logback Monitoring ==
177
178 JConsole example showing how to modify the logging level for a category:
179
Silvia Macovei 17.2 180 {{image reference="jmx-logging.png"/}}
Vincent Massol 10.1 181
Vincent Massol 7.1 182 = Tomcat JMX Proxy Servlet =
183
184 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]].
185
186 Here's some useful URLs to use the JMX Servlet Proxy to list and set JGroups Protocol Levels:
Ecaterina Moraru (Valica) 26.1 187
Vincent Massol 7.1 188 * To display the current log level for the TCPPING protocol: {{{http://localhost:8080/manager/jmxproxy?qry=jgroups:type=protocol,cluster=event,protocol=TCPPING}}}
189 * 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}}}
190
Vincent Massol 18.1 191 = Others =
Vincent Massol 7.1 192
Vincent Massol 28.2 193 * It's possible to [[write a Groovy script in a wiki page to access the JMX MBeans>>snippets:Extension.JMX Access]].
Vincent Massol 18.1 194 * [[JMX Monitoring Application>>extensions:Extension.JMX Monitoring Application]]
Vincent Massol 31.1 195 * [[Clearing Document Caches with JMX>>snippets:Extension.Clear Document Caches.WebHome]]
Vincent Massol 19.1 196 * [[XInit>>extensions:Extension.Xinit]]

Get Connected