Wiki source code of Monitoring

Version 26.3 by Ecaterina Moraru (Valica) on 2017/09/06

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>>DocumentationAdminGuide.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 = JMX Console =
66
67 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.
68
69 {{info}}
70 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):
71
72 {{image reference="jettymbeans.png"/}}
73 {{/info}}
74
75 == XWiki Caches Monitoring ==
76
77 XWiki can use different cache implementations. The JBoss Cache and JBoss Infinispan implementations have nice JMX features available as shown below.
78
79 Starting with XWiki 3.3 the default implementation is JBoss Infinispan.
80
81 === With JBoss Infinispan ===
82
83 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]]).
84
85 {{info}}
86 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
87 {{/info}}
88
89 Example showing the cache list and some statistic for a given cache:
90
91 {{image reference="infinispancache.png"/}}
92
93 Example showing how to clear a given cache from all its entries:
94
95 {{image reference="infinispancacheclearing.png"/}}
96
97 === With JBoss Cache ===
98
99 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]]).
100
101 Example showing all JBoss Caches in memory in a running instance, showing all the elements in the cache (example on the document cache):
102
103 {{image reference="jbosscache.png"/}}
104
105 Example showing Cache stats (for the document cache):
106
107 {{image reference="jbosscache-stats.png"/}}
108
109 == Velocity Cache Monitoring ==
110
111 Velocity caches Velocity macros. XWiki offers a JMX view of the content of the Velocity caches.
112
113 JConsole examples showing the Velocity Cache monitoring:
114
115 {{image reference="jconsole1.png"/}}
116
117 {{image reference="jconsole2.png"/}}
118
119 == JGroups Monitoring ==
120
121 JConsole example showing the JGroups monitoring:
122
123 {{image reference="jgroups.png"/}}
124
125 Interesting things to do on JGroups in the JMX console:
126
127 * Change the log level on the protocols to enable logging
128 * Disconnect a node from the cluster and reconnect it
129
130 == Logback Monitoring ==
131
132 JConsole example showing how to modify the logging level for a category:
133
134 {{image reference="jmx-logging.png"/}}
135
136 = Tomcat JMX Proxy Servlet =
137
138 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]].
139
140 Here's some useful URLs to use the JMX Servlet Proxy to list and set JGroups Protocol Levels:
141
142 * To display the current log level for the TCPPING protocol: {{{http://localhost:8080/manager/jmxproxy?qry=jgroups:type=protocol,cluster=event,protocol=TCPPING}}}
143 * 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}}}
144
145 = Others =
146
147 * It's possible to [[write a Groovy script in a wiki page to access the JMX MBeans>>extensions:Extension.JMX Access]].
148 * [[JMX Monitoring Application>>extensions:Extension.JMX Monitoring Application]]
149 * [[XInit>>extensions:Extension.Xinit]]

Get Connected