Wiki source code of Monitoring
Version 25.1 by Pascal Bastien on 2016/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: |
![]() |
24.2 | 6 | * Install and configure [[JavaMelody>>https://github.com/javamelody/javamelody/wiki]] |
![]() |
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 | |||
![]() |
24.3 | 20 | [[[[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%"]] |
![]() |
13.2 | 21 | |
![]() |
24.2 | 22 | To install JavaMelody for XWiki follow these steps (see the [[JavaMelody user guide>>https://github.com/javamelody/javamelody/wiki/UserGuide]] for more details): |
23 | * 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 | ||
![]() |
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> | ||
![]() |
25.1 | 31 | <!-- to enable BASIC authentication with username and password, but do no want to use a realm and "security-constraint" |
32 | <filter> | ||
33 | <filter-name>javamelody</filter-name> | ||
34 | <filter-class>net.bull.javamelody.MonitoringFilter</filter-class> | ||
35 | <init-param> | ||
36 | <param-name>authorized-users</param-name> | ||
37 | <param-value>user1:pwd1, user2:pwd2</param-value> | ||
38 | </init-param> | ||
39 | </filter> --> | ||
![]() |
13.2 | 40 | ... other <filter>s from the default web.xml here ... |
41 | |||
42 | <filter-mapping> | ||
43 | <filter-name>monitoring</filter-name> | ||
44 | <url-pattern>/*</url-pattern> | ||
45 | </filter-mapping> | ||
46 | ... other <filter-mapping>s from the default web.xml here ... | ||
47 | |||
48 | <listener> | ||
49 | <listener-class>net.bull.javamelody.SessionListener</listener-class> | ||
50 | </listener> | ||
51 | ... other <listener>s from the default web.xml here ... | ||
52 | ... | ||
53 | {{/code}} | ||
54 | ))) | ||
55 | * Edit ##hibernate.cfg.xml## and add:((( | ||
56 | {{code}} | ||
57 | <property name="jdbc.factory_class">net.bull.javamelody.HibernateBatcherFactory</property> | ||
58 | {{/code}} | ||
59 | ))) | ||
60 | |||
61 | Then restart XWiki and access JavaMelody at ##http:~//localhost:8080/xwiki/monitoring##. | ||
62 | |||
![]() |
1.1 | 63 | = JMX Console = |
64 | |||
![]() |
17.3 | 65 | 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 | 66 | |
![]() |
24.1 | 67 | {{info}} |
68 | 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 | 69 | |
![]() |
24.1 | 70 | {{image reference="jettymbeans.png"/}} |
71 | {{/info}} | ||
72 | |||
![]() |
11.1 | 73 | == XWiki Caches Monitoring == |
74 | |||
![]() |
14.1 | 75 | XWiki can use different cache implementations. The JBoss Cache and JBoss Infinispan implementations have nice JMX features available as shown below. |
![]() |
11.1 | 76 | |
![]() |
17.3 | 77 | Starting with XWiki 3.3 the default implementation is JBoss Infinispan. |
![]() |
14.1 | 78 | |
79 | === With JBoss Infinispan === | ||
80 | |||
81 | 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]]). | ||
82 | |||
![]() |
17.3 | 83 | {{info}} |
84 | 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 | ||
85 | {{/info}} | ||
![]() |
14.1 | 86 | |
87 | Example showing the cache list and some statistic for a given cache: | ||
88 | |||
![]() |
17.3 | 89 | {{image reference="infinispancache.png"/}} |
![]() |
14.1 | 90 | |
![]() |
20.1 | 91 | Example showing how to clear a given cache from all its entries: |
92 | |||
93 | {{image reference="infinispancacheclearing.png"/}} | ||
94 | |||
![]() |
14.1 | 95 | === With JBoss Cache === |
96 | |||
![]() |
17.3 | 97 | 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 | 98 | |
![]() |
11.1 | 99 | Example showing all JBoss Caches in memory in a running instance, showing all the elements in the cache (example on the document cache): |
100 | |||
![]() |
17.2 | 101 | {{image reference="jbosscache.png"/}} |
![]() |
11.1 | 102 | |
103 | Example showing Cache stats (for the document cache): | ||
104 | |||
![]() |
17.2 | 105 | {{image reference="jbosscache-stats.png"/}} |
![]() |
11.1 | 106 | |
![]() |
4.1 | 107 | == Velocity Cache Monitoring == |
![]() |
1.1 | 108 | |
![]() |
12.2 | 109 | Velocity caches Velocity macros. XWiki offers a JMX view of the content of the Velocity caches. |
110 | |||
![]() |
4.1 | 111 | JConsole examples showing the Velocity Cache monitoring: |
112 | |||
![]() |
17.2 | 113 | {{image reference="jconsole1.png"/}} |
![]() |
1.1 | 114 | |
![]() |
17.2 | 115 | {{image reference="jconsole2.png"/}} |
![]() |
1.1 | 116 | |
![]() |
4.1 | 117 | == JGroups Monitoring == |
118 | |||
119 | JConsole example showing the JGroups monitoring: | ||
120 | |||
![]() |
17.2 | 121 | {{image reference="jgroups.png"/}} |
![]() |
4.1 | 122 | |
123 | Interesting things to do on JGroups in the JMX console: | ||
124 | * Change the log level on the protocols to enable logging | ||
125 | * Disconnect a node from the cluster and reconnect it | ||
126 | |||
![]() |
10.1 | 127 | == Logback Monitoring == |
128 | |||
129 | JConsole example showing how to modify the logging level for a category: | ||
130 | |||
![]() |
17.2 | 131 | {{image reference="jmx-logging.png"/}} |
![]() |
10.1 | 132 | |
![]() |
7.1 | 133 | = Tomcat JMX Proxy Servlet = |
134 | |||
135 | 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]]. | ||
136 | |||
137 | Here's some useful URLs to use the JMX Servlet Proxy to list and set JGroups Protocol Levels: | ||
138 | * To display the current log level for the TCPPING protocol: {{{http://localhost:8080/manager/jmxproxy?qry=jgroups:type=protocol,cluster=event,protocol=TCPPING}}} | ||
139 | * 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}}} | ||
140 | |||
![]() |
18.1 | 141 | = Others = |
![]() |
7.1 | 142 | |
![]() |
18.1 | 143 | * It's possible to [[write a Groovy script in a wiki page to access the JMX MBeans>>extensions:Extension.JMX Access]]. |
144 | * [[JMX Monitoring Application>>extensions:Extension.JMX Monitoring Application]] | ||
![]() |
19.1 | 145 | * [[XInit>>extensions:Extension.Xinit]] |