Chapter 12. Additional Services

This chapter discusses useful MBean services that are not discussed elsewhere either because they are utility services not necessary for running JBoss, or they don't fit into a current section of the book.

12.1. Memory and Thread Monitoring

The jboss.system:type=ServerInfo MBean provides several attributes that can be used to monitor the thread and memory usage in a JBoss instance. These attributes can be monitored in many ways: through the JMX Console, from a third-party JMX management tool, from shell scripts using the twiddle command, etc... The most interesting attributes are shown below.
FreeMemory
This is the current free memory available in the JVM.
ActiveThreadCount
This is the number of active threads in the JVM.
ActiveThreadGroupCount
This is the number of active thread groups in the JVM.
These are useful metrics for monitoring and alerting, but developers and administrators need a little more insite than this. The Java 5 JVMs from Sun provide more detailed information about the current state of the JVM. Some of these details are exposed by JBoss through operations on the SystemInfo MBean.
listMemoryPools
This operations shows the size and current usage of all JVM memory pools. This operation is only available when using Java 5.
listThreadDump
This operations shows all threads currently running in the JVM. When using Java 5, JBoss will display a complete stack trace for each thread, showing you exactly what code each thread is executing.
listThreadCpuUtilization
This operations shows all threads currently running in the JVM along with the total CPU time each thread has used. The operation is only available in Java 5.