Wiki source code of Monitoring
Version 22.3 by Vincent Massol on 2014/11/04
Hide last authors
author | version | line-number | content |
---|---|---|---|
![]() |
6.1 | 1 | {{box cssClass="floatinginfobox" title="**Contents**"}} |
2 | {{toc/}} | ||
3 | {{/box}} | ||
4 | |||
![]() |
13.2 | 5 | There are various solutions you can use to monitor a running XWiki instance: |
6 | * Install and configure [[JavaMelody>>http://code.google.com/p/javamelody/]] | ||
![]() |
13.4 | 7 | * [[Use a Profiler>>http://dev.xwiki.org/xwiki/bin/view/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. |
![]() |
3.2 | 8 | * Starting with XWiki Enterprise 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: |
![]() |
1.1 | 9 | ** Monitor the Velocity macro caches |
![]() |
3.3 | 10 | ** Monitor the JBossCache caches XWiki is using to cache Document data, Users & Groups data and more |
![]() |
8.1 | 11 | ** (starting with XE 3.1) Monitor the JGroups channel and protocols (when the XWiki Cluster feature is turned on) |
12 | ** (starting with XE 3.1) Monitor the Logback Logging configuration and change it | ||
![]() |
1.1 | 13 | |
![]() |
2.3 | 14 | {{info}} |
![]() |
17.3 | 15 | XWiki also has a [[Monitor Plugin>>platform:AdminGuide.Logging#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. |
![]() |
2.3 | 16 | {{/info}} |
17 | |||
![]() |
13.2 | 18 | = JavaMelody = |
19 | |||
![]() |
13.3 | 20 | [[[[image:http://javamelody.googlecode.com/svn/trunk/javamelody-core/src/site/resources/screenshots/graphs.png||width="50%"]]>>http://code.google.com/p/javamelody/wiki/Screenshots||style="width:50%"]] |
![]() |
13.2 | 21 | |
![]() |
17.3 | 22 | To install JavaMelody for XWiki follow these steps (see the [[JavaMelody user guide>>http://code.google.com/p/javamelody/wiki/UserGuide]] for more details): |
23 | * Download the latest [[javamelody.jar>>http://code.google.com/p/javamelody/downloads/list]] and [[jrobin-x.jar>>http://javamelody.googlecode.com/files/jrobin-1.5.9.jar]] and put them in the ##WEB-INF/lib## folder | ||
![]() |
13.2 | 24 | * Edit ##web.xml## and add the following information:((( |
25 | {{code}} | ||
26 | ... | ||
27 | <filter> | ||
28 | <filter-name>monitoring</filter-name> | ||
29 | <filter-class>net.bull.javamelody.MonitoringFilter</filter-class> | ||
30 | </filter> | ||
31 | ... other <filter>s from the default web.xml here ... | ||
32 | |||
33 | <filter-mapping> | ||
34 | <filter-name>monitoring</filter-name> | ||
35 | <url-pattern>/*</url-pattern> | ||
36 | </filter-mapping> | ||
37 | ... other <filter-mapping>s from the default web.xml here ... | ||
38 | |||
39 | <listener> | ||
40 | <listener-class>net.bull.javamelody.SessionListener</listener-class> | ||
41 | </listener> | ||
42 | ... other <listener>s from the default web.xml here ... | ||
43 | ... | ||
44 | {{/code}} | ||
45 | ))) | ||
46 | * Edit ##hibernate.cfg.xml## and add:((( | ||
47 | {{code}} | ||
48 | <property name="jdbc.factory_class">net.bull.javamelody.HibernateBatcherFactory</property> | ||
49 | {{/code}} | ||
50 | ))) | ||
51 | |||
52 | Then restart XWiki and access JavaMelody at ##http:~//localhost:8080/xwiki/monitoring##. | ||
53 | |||
![]() |
1.1 | 54 | = JMX Console = |
55 | |||
![]() |
17.3 | 56 | 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. |
![]() |
1.1 | 57 | |
![]() |
22.3 | 58 | 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). |
![]() |
22.1 | 59 | |
![]() |
11.1 | 60 | == XWiki Caches Monitoring == |
61 | |||
![]() |
14.1 | 62 | XWiki can use different cache implementations. The JBoss Cache and JBoss Infinispan implementations have nice JMX features available as shown below. |
![]() |
11.1 | 63 | |
![]() |
17.3 | 64 | Starting with XWiki 3.3 the default implementation is JBoss Infinispan. |
![]() |
14.1 | 65 | |
66 | === With JBoss Infinispan === | ||
67 | |||
68 | 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]]). | ||
69 | |||
![]() |
17.3 | 70 | {{info}} |
71 | Prior to XWiki Enterprise 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 | ||
72 | {{/info}} | ||
![]() |
14.1 | 73 | |
74 | Example showing the cache list and some statistic for a given cache: | ||
75 | |||
![]() |
17.3 | 76 | {{image reference="infinispancache.png"/}} |
![]() |
14.1 | 77 | |
![]() |
20.1 | 78 | Example showing how to clear a given cache from all its entries: |
79 | |||
80 | {{image reference="infinispancacheclearing.png"/}} | ||
81 | |||
![]() |
14.1 | 82 | === With JBoss Cache === |
83 | |||
![]() |
17.3 | 84 | 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]]). |
![]() |
14.1 | 85 | |
![]() |
11.1 | 86 | Example showing all JBoss Caches in memory in a running instance, showing all the elements in the cache (example on the document cache): |
87 | |||
![]() |
17.2 | 88 | {{image reference="jbosscache.png"/}} |
![]() |
11.1 | 89 | |
90 | Example showing Cache stats (for the document cache): | ||
91 | |||
![]() |
17.2 | 92 | {{image reference="jbosscache-stats.png"/}} |
![]() |
11.1 | 93 | |
![]() |
4.1 | 94 | == Velocity Cache Monitoring == |
![]() |
1.1 | 95 | |
![]() |
12.2 | 96 | Velocity caches Velocity macros. XWiki offers a JMX view of the content of the Velocity caches. |
97 | |||
![]() |
4.1 | 98 | JConsole examples showing the Velocity Cache monitoring: |
99 | |||
![]() |
17.2 | 100 | {{image reference="jconsole1.png"/}} |
![]() |
1.1 | 101 | |
![]() |
17.2 | 102 | {{image reference="jconsole2.png"/}} |
![]() |
1.1 | 103 | |
![]() |
4.1 | 104 | == JGroups Monitoring == |
105 | |||
106 | JConsole example showing the JGroups monitoring: | ||
107 | |||
![]() |
17.2 | 108 | {{image reference="jgroups.png"/}} |
![]() |
4.1 | 109 | |
110 | Interesting things to do on JGroups in the JMX console: | ||
111 | * Change the log level on the protocols to enable logging | ||
112 | * Disconnect a node from the cluster and reconnect it | ||
113 | |||
![]() |
10.1 | 114 | == Logback Monitoring == |
115 | |||
116 | JConsole example showing how to modify the logging level for a category: | ||
117 | |||
![]() |
17.2 | 118 | {{image reference="jmx-logging.png"/}} |
![]() |
10.1 | 119 | |
![]() |
7.1 | 120 | = Tomcat JMX Proxy Servlet = |
121 | |||
122 | 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]]. | ||
123 | |||
124 | Here's some useful URLs to use the JMX Servlet Proxy to list and set JGroups Protocol Levels: | ||
125 | * To display the current log level for the TCPPING protocol: {{{http://localhost:8080/manager/jmxproxy?qry=jgroups:type=protocol,cluster=event,protocol=TCPPING}}} | ||
126 | * 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}}} | ||
127 | |||
![]() |
18.1 | 128 | = Others = |
![]() |
7.1 | 129 | |
![]() |
18.1 | 130 | * It's possible to [[write a Groovy script in a wiki page to access the JMX MBeans>>extensions:Extension.JMX Access]]. |
131 | * [[JMX Monitoring Application>>extensions:Extension.JMX Monitoring Application]] | ||
![]() |
19.1 | 132 | * [[XInit>>extensions:Extension.Xinit]] |