Wiki source code of Monitoring

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

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.3 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.
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
Vincent Massol 1.1 65 = JMX Console =
66
Manuel Smeria 17.3 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.
Vincent Massol 1.1 68
Vincent Massol 24.1 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):
Vincent Massol 22.1 71
Vincent Massol 24.1 72 {{image reference="jettymbeans.png"/}}
73 {{/info}}
74
Vincent Massol 11.1 75 == XWiki Caches Monitoring ==
76
Vincent Massol 14.1 77 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 78
Manuel Smeria 17.3 79 Starting with XWiki 3.3 the default implementation is JBoss Infinispan.
Vincent Massol 14.1 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
Manuel Smeria 17.3 85 {{info}}
Ecaterina Moraru (Valica) 26.1 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
Manuel Smeria 17.3 87 {{/info}}
Vincent Massol 14.1 88
89 Example showing the cache list and some statistic for a given cache:
90
Manuel Smeria 17.3 91 {{image reference="infinispancache.png"/}}
Vincent Massol 14.1 92
Vincent Massol 20.1 93 Example showing how to clear a given cache from all its entries:
94
95 {{image reference="infinispancacheclearing.png"/}}
96
Vincent Massol 14.1 97 === With JBoss Cache ===
98
Manuel Smeria 17.3 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]]).
Vincent Massol 14.1 100
Vincent Massol 11.1 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
Silvia Macovei 17.2 103 {{image reference="jbosscache.png"/}}
Vincent Massol 11.1 104
105 Example showing Cache stats (for the document cache):
106
Silvia Macovei 17.2 107 {{image reference="jbosscache-stats.png"/}}
Vincent Massol 11.1 108
Vincent Massol 4.1 109 == Velocity Cache Monitoring ==
Vincent Massol 1.1 110
Vincent Massol 12.2 111 Velocity caches Velocity macros. XWiki offers a JMX view of the content of the Velocity caches.
112
Vincent Massol 4.1 113 JConsole examples showing the Velocity Cache monitoring:
114
Silvia Macovei 17.2 115 {{image reference="jconsole1.png"/}}
Vincent Massol 1.1 116
Silvia Macovei 17.2 117 {{image reference="jconsole2.png"/}}
Vincent Massol 1.1 118
Vincent Massol 4.1 119 == JGroups Monitoring ==
120
121 JConsole example showing the JGroups monitoring:
122
Silvia Macovei 17.2 123 {{image reference="jgroups.png"/}}
Vincent Massol 4.1 124
125 Interesting things to do on JGroups in the JMX console:
Ecaterina Moraru (Valica) 26.1 126
Vincent Massol 4.1 127 * Change the log level on the protocols to enable logging
128 * Disconnect a node from the cluster and reconnect it
129
Vincent Massol 10.1 130 == Logback Monitoring ==
131
132 JConsole example showing how to modify the logging level for a category:
133
Silvia Macovei 17.2 134 {{image reference="jmx-logging.png"/}}
Vincent Massol 10.1 135
Vincent Massol 7.1 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:
Ecaterina Moraru (Valica) 26.1 141
Vincent Massol 7.1 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
Vincent Massol 18.1 145 = Others =
Vincent Massol 7.1 146
Vincent Massol 18.1 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]]
Vincent Massol 19.1 149 * [[XInit>>extensions:Extension.Xinit]]

Get Connected