Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jayankandathil/ecab361bc7ff0c892206 to your computer and use it in GitHub Desktop.
Save jayankandathil/ecab361bc7ff0c892206 to your computer and use it in GitHub Desktop.
Groovy script that reports average CQ and AEM workflow processing time
// Author : Jayan Kandathil
// Last Updated : June 18, 2014
// Version : 0.1
// Need following JVM init arguments for JMX access (Windows .bat example)
// set CQ_JVM_OPTS=%CQ_JVM_OPTS% -Dcom.sun.management.jmxremote
// set CQ_JVM_OPTS=%CQ_JVM_OPTS% -Dcom.sun.management.jmxremote.port=10000
// set CQ_JVM_OPTS=%CQ_JVM_OPTS% -Dcom.sun.management.jmxremote.authenticate=false
// set CQ_JVM_OPTS=%CQ_JVM_OPTS% -Dcom.sun.management.jmxremote.ssl=false
import java.lang.management.*
import javax.management.ObjectName
import javax.management.remote.JMXConnectorFactory as JmxFactory
import javax.management.remote.JMXServiceURL as JmxUrl
def serverUrl = 'service:jmx:rmi:///jndi/rmi://localhost:10000/jmxrmi'
String beanName = "org.apache.sling:type=queues,name=Granite Workflow Queue"
try
{
def server = JmxFactory.connect(new JmxUrl(serverUrl)).MBeanServerConnection
def gmxb = new GroovyMBean(server, beanName)
long x = gmxb.getProperty("AverageProcessingTime")
println x
}
catch(java.io.IOException e)
{
println "Unable to connect to JVM"
System.exit(0)
}
catch(javax.management.InstanceNotFoundException e)
{
println 0
}
catch(groovy.lang.MissingPropertyException e)
{
println "Unable to find " + prop
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment