Hyperic Plugin for JBoss; monitoring Active Sessions

--Mahesh Patil

The out of the box Hyperic HQ doesn't support number of parameters which you might want to monitor, such as Active Sessions. Active sessions are the number of HTTP sessions active at any point of time. Of course these sessions are specific to your application. If you have deployed your application on any of the application servers then normally there is a management console which allows you to see the active sessions of your application. For example JBoss exports various such parameters through the MBeans, which you can see through JMX-Console. But if you want to see the active sessions over a period of time then you'll need some monitoring tool like Hyperic which can continuously monitor configured parameters.

The hyperic supports writing JBoss plugins (Basically extending JBoss MBean plugins). This plugin is based on the Hyperic HQ 4.2 and JBoss Enterprise Application server 4.2. I'm sure it would work with other versions as well. Let's look at the various components required to write a simple plugin:

Service Type:

The JBoss server type defines several service types such as EJBs, Connection Pools and JMS Queues. Custom plugins define additional service types to provide management via custom MBeans. The service tag is used to create new types like so:
					
					
					
The server attribute must be that of JBoss and version attribute one of 3.2 or 4.0. The name attribute is the choice of the plugin implementor. These services will become part of the HQ inventory model, displayed along with the builtin JBoss service types throughout the UI and shell. JBoss service extensions will also inherit the server's configuration properties used to connect to the MBeanServer.

ObjectName:

In order to access custom MBeans, the plugin must define its JMX ObjectName to be used with various MBeanServer interface methods. Only one ObjectName is defined per-service type using the property tag within the service tag:
					
					
What we are interested in is the "activeSessions" property which is part of 'jboss.web' MBean. The URL to identify this url is "jboss.web:type=Manager,path=/,host=localhost". As you can see I've specified path variable instead of specifying '/' above to capture activeSessions from each application running on the JBoss instance.

Metrics:

Metrics are defined just as they are with other plugins, but in the case of custom JBoss services the OBJECT_NAME property is used to compose the metric template attribute. We are interested in capturing "activeSessions" attribute present on the 'jboss.web' MBean so our metric tag would look like:
				
				
The important attribute in metric tag is template. A service can have any number of metric tags, so if you want to monitor any other parameter from the same MBean (defined as OBJECT_NAME), you'll have to just add another metric tag.

Auto Inventory:

Auto Inventory is supported for custom JBoss services, again driven by the OBJECT_NAME property. Not enabled by default, to enable use the following within the service tag:
				
				

The complete XML file would look like this:

						
						  
						    
						    
						    
						    
								
						    
						    
						  
						
    				

Once you have completed the XML file you'll have to deploy it to the plug-in folder of HQ Server and Agent. You must stop the server before copying the File. Following are the folders on my server:

			"D:\Hyperic HQ 4.2.0\server-4.2.0\hq-engine\server\default\deploy\hq.ear\hq-plugins"
			"D:\Hyperic HQ 4.2.0\agent-4.2.0\bundles\agent-4.2.0-1260\pdk\plugins"
			
If you start the Hyperic server, you should see new option "JBoss 4.2 Active Sessions service" (click on monitoring default under Administration Tab) under JBoss 4.2. By selecting 'edit metric defaults' option against it, you would be able to specify the collection interval for the "Active Sessions" metric. That's it your agent should start gathering the active sessions of your applications running under JBoss 4.2.

Comments *
Name *
Email
Please Answer this simple math Question *(2 + 2) =

Comments
Nash. Hello Mahesh, This example is great, I have a question what if i want to create my own Jboss server having my url jmx and port number, and monitor the application running on that server memory usage for example. Sincerely, Nash.
23 Sep 2010
 
Mahesh Hi Nash, This example is basically extending the bundled JBoss plugin functionality provided by Hyperic HQ. You can use this method to literally monitor any Metric supported by JBoss JMX (MBean server). If you want to monitor application running on your own App Server then the Hyperic HQ should have support for your App Server in first place. You can check with Hyperic on how to register application server other than the supported ones. Cheers, Mahesh
27 Sep 2010
 
Nash. Hi Mahesh, I don't want to monitor metric that not supported by HQ i just want to be able to add my own server name of server type Jboss with the name i want without the need to do it using the UI, but using jmx. Any Idea? Sincerely, Nash.
27 Sep 2010
 
Mahesh Hi Nash, In Service Type xml tag the server and version values needs to be one of the supported ones. Cheers, Mahesh
4 Oct 2010