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.