There are several ways to monitor your server, with different purposes and related tools. Nagios or Inca could be used to manage infrastructure and applications on a range of parameters that can be measured. Think disk space, memory usage, availability of protocol API’s. These are central monitoring applications probing the environment.
There are specific (SaaS based) application monitoring tools like New-Relic (against Alfresco) and Scout. They integrate with your application server like Tomcat and can determine how the processing time is shared over transport, real calculations, database activity etc. This break-up of the numbers can be of value when looking at a performance problem. however the SaaS concept can be a problem for some of my customers.
Next to that there are tools one can use from the server itself like VisualVM and JConsole. They can display the JMX-like values like the memory usage, disk space, running processes etc. You often need to run the tools at the server, or have enough ports open to access it remotely. Often I just cannot.
My intention of use of JavaMelody is in the play field of New-Relic; I need to check performance and point to a bottle neck. I tried New Relic before, but a commercial SaaS like solution is not always viable. This blog (in Spanish, try the English), and this screenshot in particular made me try JavaMelody. (This seems to be something the psi-probe tool does not do?) If the time spent at SQL queries can be determined in the context of a single http call, then I am fixed. And using 2 locally added jars instead of outside connections.
I guess, the world has changed a little bit since Toni’s blog. I downloaded the latest javamelody-1.42.0.zip from Google Code. From the inside of this zip, copy javamelody.jar and jrobin.184.108.40.206.jar into tomcat/webapps/alfresco/WEB-INF/lib.
I did not get the plain JDBC route working for Alfresco. I can get it to work using JNDI only. So, run Alfresco using JNDI to locate your JDBC resources. Follow the next 3 steps and enjoy the insights!
1. Open your tomat/webapps/alfresco/WEB-INF/web.xml. Look for the context-param contextConfigLocation. Tweak this element to look like:
<context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath:net/bull/javamelody/monitoring-spring-datasource.xml /WEB-INF/web-application-context.xml </param-value> <description>Spring config file location</description> </context-param>
Add a new section:
<filter> <filter-name>monitoring</filter-name> <filter-class>net.bull.javamelody.MonitoringFilter</filter-class> </filter> <filter-mapping> <filter-name>monitoring</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <listener> <listener-class>net.bull.javamelody.SessionListener</listener-class> </listener>
2. Edit the two following files (keep the content identical!)
- tomcat/conf/Catalina/localhost/alfresco.xml and
Uncomment the first resource element and adjust the username/password/url accordingly. make sure the name attribute has the value jdbc/dataSource (that is the name Alfresco expects)
3. Update your tomcat/shared/classes/alfresco/extension/alfresco-global.properies. I made the db.username (and/or db.password) invalid. This to prevent Alfresco using the direct JDBC database connection (failing your statistics).
(Re)Start Alfresco, and off you go. Point your webbrowser to http://localhost:8080/alfresco/monitoring and enjoy!
I got it working!
The SQL time measured is the time from invoking the statement from JDBC until there is a resultset. It does not include the time to fetch the data for a select, nor does it include the time for jdbc ResultSet.next().
If you got this working, consider modifying your alfresco.bat/alfresco.sh in here there is the definitionof JAVA_OPTS. Add to this definition (in the same line, no line breaks):
What is does?
- The part ‘monitoring-path=’ moves the URL of the monitoring page to http://localhost:8080/alfresco/faces/jsp/admin/monitoring, and you get Alfresco admin-only protection for free!
- The second part (‘javamelody.storage=’) moves the location where JavaMelody stores its measured history from Tomcat’s temp folder to a more reasonable location. I collect it in alf_data/javamelody-repo (and alf_data/javamelody-share for my separated Tomcat-Share instance). Makes life easy when making your nightly backup 🙂
Wait a little for a next post on how to use the collect server. This is a little work to configure this securely.
Apart from this you get a lot more! Among others:
- historical insight in your memory usage,
- System and http errors (and details)
- List of threads (connected to SQL statements) frequency, time of execution, deviation…
- All sessions
- Sql statements, frequency, time of execution, deviation…
- Overview of the garbage collection (even manually invoke if you feel you need that)
- your full JMX details (MBeans) (Hey, I ve seen this working, it is broken in my install right now)
- All OS processes
- Java (jar) dependencies
- The full set of JVM JAVA_OPTS and (in my case) a lot of MySQL settings
I really appreciate the sortable table columns (click the headers) :0)
(Cool Tool! Anyone got this working on the direct JDBC definition?)
[update 12-12-2012: removed javamelody-objectfactory.jar because not needed (triggered by Emeric Vernat, lead of JavaMelody)]
[update 14-12-2012: added what’s in/out the SQL measured time (triggered by discussion with Emeric Vernat). Also added additional configuration of JAVA_OPTS to move the datafiles and to change the URL]