Wiki source code of Monitoring

Version 27.1 by Denis Gervalle on 2017/11/18

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
7 * Install and configure [[JavaMelody>>https://github.com/javamelody/javamelody/wiki]]
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:
10 ** Monitor the Velocity macro caches
11 ** Monitor the JBossCache caches XWiki is using to cache Document data, Users & Groups data and more
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
14
15 {{info}}
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.
17 {{/info}}
18
19 = JavaMelody =
20
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%"]]
22
23 To install JavaMelody for XWiki follow these steps (see the [[JavaMelody user guide>>https://github.com/javamelody/javamelody/wiki/UserGuide]] for more details):
24
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
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>
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> -->
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
63 Then restart XWiki and access JavaMelody at ##http:~/~/localhost:8080/xwiki/monitoring##.
64
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
97 = JMX Console =
98
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.
100
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):
103
104 {{image reference="jettymbeans.png"/}}
105 {{/info}}
106
107 == XWiki Caches Monitoring ==
108
109 XWiki can use different cache implementations. The JBoss Cache and JBoss Infinispan implementations have nice JMX features available as shown below.
110
111 Starting with XWiki 3.3 the default implementation is JBoss Infinispan.
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
117 {{info}}
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
119 {{/info}}
120
121 Example showing the cache list and some statistic for a given cache:
122
123 {{image reference="infinispancache.png"/}}
124
125 Example showing how to clear a given cache from all its entries:
126
127 {{image reference="infinispancacheclearing.png"/}}
128
129 === With JBoss Cache ===
130
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]]).
132
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
135 {{image reference="jbosscache.png"/}}
136
137 Example showing Cache stats (for the document cache):
138
139 {{image reference="jbosscache-stats.png"/}}
140
141 == Velocity Cache Monitoring ==
142
143 Velocity caches Velocity macros. XWiki offers a JMX view of the content of the Velocity caches.
144
145 JConsole examples showing the Velocity Cache monitoring:
146
147 {{image reference="jconsole1.png"/}}
148
149 {{image reference="jconsole2.png"/}}
150
151 == JGroups Monitoring ==
152
153 JConsole example showing the JGroups monitoring:
154
155 {{image reference="jgroups.png"/}}
156
157 Interesting things to do on JGroups in the JMX console:
158
159 * Change the log level on the protocols to enable logging
160 * Disconnect a node from the cluster and reconnect it
161
162 == Logback Monitoring ==
163
164 JConsole example showing how to modify the logging level for a category:
165
166 {{image reference="jmx-logging.png"/}}
167
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:
173
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
177 = Others =
178
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]]
181 * [[XInit>>extensions:Extension.Xinit]]

Get Connected