Java CAPS 5.1 monitoring eGate and eInsight with Groovy and JMX
Introduction
Following the previous tip on JMX monitoring for JAVA CAPS 5.1. I presented only sample scripts to monitor the Java Virtual Machine. However with the JMX-Console it is easy to extract information and build Groovy JMX scripts to monitor the SeeBeyond eGate and eInsight modules. The scripts presented here are monitoring eInsight (the active BPEL instances) and eGate (the active JCD). For the sake of simplicity I have hardcoded parameters relevant to my local settings and the test projects I am using, but I think it is very easy to generalize.
Configuration
Install Groovy as described here To monitor eInsight you need to add the following JAR files in groovy/lib:
Monitoring eGate JCDs
The following script is list all the JCDs deployed on the application server:
Monitoring eInsight BPEL instances
The following script is listing all the active BPEL instances:
Following the previous tip on JMX monitoring for JAVA CAPS 5.1. I presented only sample scripts to monitor the Java Virtual Machine. However with the JMX-Console it is easy to extract information and build Groovy JMX scripts to monitor the SeeBeyond eGate and eInsight modules. The scripts presented here are monitoring eInsight (the active BPEL instances) and eGate (the active JCD). For the sake of simplicity I have hardcoded parameters relevant to my local settings and the test projects I am using, but I think it is very easy to generalize.
Configuration
Install Groovy as described here To monitor eInsight you need to add the following JAR files in groovy/lib:
| JAR File | Source Location relative to Java CAPS root directory |
|---|---|
| com.stc.codegenapi.jar | emanager\server\shared\lib |
| com.stc.codegenmetadataimpl.jar | emanager\server\shared\lib |
| com.stc.log4jadapter.jar | emanager\server\shared\lib | log4j.jar | emanager\server\shared\lib |
| com.stc.einsightruntimeimpl.jar | edesigner\usrdir\modules\ext\stc\eInsightCodeGen |
Monitoring eGate JCDs
The following script is list all the JCDs deployed on the application server:
package jcaps.jmx;
import javax.management.ObjectName
import javax.management.remote.JMXConnectorFactory as JmxFactory
import javax.management.remote.JMXServiceURL as JmxUrl
public def getAllCollaborations() {
def serverUrl = 'service:jmx:rmi:///jndi/rmi://localhost:9877/jmxrmi'
def server = JmxFactory.connect(new JmxUrl(serverUrl)).mBeanServerConnection
def query = new ObjectName('SeeBeyond:*')
String[] allNames = server.queryNames(query, null)
def allSeebeyondBeans = allNames.collect{ new GroovyMBean(server, it) }
def activationMBeans = allSeebeyondBeans.findAll {
it.info().getClassName().equals("com.stc.codegen.mbeans.CollabMonitor")
}
activationMBeans.each {
println it.name().getKeyProperty("Name")
println " is ${it.Status} since ${it.Since}"
println " messages processed per queue: ${it.NumberMsgProcessed}"
}
}
getAllCollaborations()
For example this output shows:
F:\scripts>JMXListCollaborations.groovy Deployment1TestSimpleJCD|TestSimpleJCD|Deployment1|CMap1_jcdProcess1 is UP since Fri Aug 01 09:47:49 CEST 2008 messages processed per queue: ["Queue1":3327] Deployment1TestSimpleJCD|TestSimpleJCD|Deployment1|CMap1_jcdTrigger1 is UP since Fri Aug 01 09:00:30 CEST 2008 messages processed per queue: ["Scheduler1":3327]We can see the full name of the JCD MBean, in the form of "ear|project|deployment|cmap_jcd". Using this name, I can recall the corresponding MBean and directly call a JMX operation.
package jcaps.jmx;
import javax.management.ObjectName
import javax.management.remote.JMXConnectorFactory as JmxFactory
import javax.management.remote.JMXServiceURL as JmxUrl
public def controlCollaboration(String collabFullName, String operation) {
def serverUrl = 'service:jmx:rmi:///jndi/rmi://localhost:9877/jmxrmi'
def server = JmxFactory.connect(new JmxUrl(serverUrl)).mBeanServerConnection
def query = new ObjectName("SeeBeyond:*,Name=${collabFullName}")
def allSeebeyondBeans = server.queryNames(query, null).collect{
new GroovyMBean(server, it)
}
if (allSeebeyondBeans.size()==1) {
allSeebeyondBeans[0]."${operation}"()
}
}
def collabFullName = "Deployment1TestSimpleJCD|TestSimpleJCD|Deployment1|CMap1_jcdProcess1"
if (this.args.size()!=1) {
controlCollaboration(collabFullName, "stop")
} else {
controlCollaboration(collabFullName, this.args[0])
}
With this script I can start the JCD processing using the command:
JMXControlCollaboration.groovy startand stop the JCD processing using the command:
JMXControlCollaboration.groovy stop
Monitoring eInsight BPEL instances
The following script is listing all the active BPEL instances:
package jcaps.jmx;
import javax.management.ObjectName
import javax.management.remote.JMXConnectorFactory as JmxFactory
import javax.management.remote.JMXServiceURL as JmxUrl
public def getAllInstances() {
def ret = [:]
def serverUrl = 'service:jmx:rmi:///jndi/rmi://localhost:9877/jmxrmi'
def server = JmxFactory.connect(new JmxUrl(serverUrl)).mBeanServerConnection
def query = new ObjectName('SeeBeyond:*')
String[] allNames = server.queryNames(query, null)
def metadataBeans = allNames.findAll{
name -> name.contains('type=MetaDataManager')
}.collect{ new GroovyMBean(server, it) }
metadataBeans.each { metadata ->
def earName = metadata.name().getKeyProperty("name")
def objects = metadata.getAllMetaDataObject().values()
bpelMetadatas = objects.findAll { o ->
o.getClass().getName().equals("com.stc.codegen.eInsightImpl.runtime.metadata.MDBpelMetadataImpl") }
bpelMetadatas.each { bpelMetadata ->
def bpengine = new GroovyMBean(server, 'SeeBeyond:EARId=' + earName + ',type=BPEngineMBean')
def instances = bpengine.getBPInstances(bpelMetadata.getName())
def instanceIds = []
if (instances == null) {
println bpelMetadata.getName() + " has 0 instance"
} else {
instances.values().each { l -> instanceIds.addAll(l) }
if (instanceIds.size() == 0) {
println bpelMetadata.getName() + " has 0 instance"
} else if (instanceIds.size()==1) {
println bpelMetadata.getName() + " has 1 instance:"
} else {
println bpelMetadata.getName() + " has " + instanceIds.size() + " instances:"
}
if (instanceIds != null && instanceIds.size()>=1) {
instanceIds.each {
v -> println v
ret[v] = bpelMetadata.getName()
}
}
}
println "------------------"
}
}
ret
}
getAllInstances()
An example output is:
F:\scripts>JMXListBpelInstances.groovy bpLoanProcessor has 2 instances: 192.168.0.4:-6a87fe3c:11b77e548e3:-7f90 192.168.0.4:-6a87fe3c:11b77e548e3:-7f9d ------------------The benefit of this script is that it works even when BPEL persistence to database is not configured. In this situation, I found it difficult to monitor precisely when the BPEL instances are created and destroyed. Now, with this script I can monitor the instance IDs. The BPEL instance IDs also appears in the log files so I can cross check the logging entries for this BPEL instance only.

You can optimize it a fair bit; one way would be to use server.getMBeanInfo(ObjectName).getClassName() instead of using GroovyMBean.info() -- and creating the GroovyMBeans only when we've really got the mean names we want.
Posted by sysprv on September 15, 2008 at 08:41 AM CEST #