SHARE
TWEET

Untitled

a guest May 19th, 2017 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Author : Jayan Kandathil
  2. // Last Updated : May 19, 2017
  3. // Version : 0.1
  4.  
  5. import java.lang.management.*
  6. import javax.management.ObjectName
  7. import javax.management.remote.JMXConnectorFactory as JmxFactory
  8. import javax.management.remote.JMXServiceURL as JmxUrl
  9.  
  10. import java.text.DecimalFormat;
  11.  
  12. DecimalFormat df = new DecimalFormat("###,##0");
  13.  
  14. def serverUrl = 'service:jmx:rmi:///jndi/rmi://localhost:10000/jmxrmi'
  15. String beanName = "org.apache.sling:type=queues,name=AllQueues"
  16.  
  17. try
  18. {
  19.  
  20.     def server = JmxFactory.connect(new JmxUrl(serverUrl)).MBeanServerConnection
  21.     def gmxb = new GroovyMBean(server, beanName)
  22.  
  23.     long lngQueuedJobs = gmxb.getProperty("NumberOfQueuedJobs")
  24.     long lngActiveJobs = gmxb.getProperty("NumberOfActiveJobs")
  25.     long lngJobs = gmxb.getProperty("NumberOfJobs")
  26.     long lngFinishedJobs = gmxb.getProperty("NumberOfFinishedJobs")
  27.     long lngProcessedJobs = gmxb.getProperty("NumberOfProcessedJobs")
  28.     long lngCancelledJobs = gmxb.getProperty("NumberOfCancelledJobs")
  29.     long lngFailedJobs = gmxb.getProperty("NumberOfFailedJobs")
  30.  
  31.     println df.format(lngQueuedJobs) + "," + df.format(lngActiveJobs) + "," + df.format(lngJobs) + "," + df.format(lngFinishedJobs) + "," + df.format(lngProcessedJobs) + "," + df.format(lngCancelledJobs) + "," + df.format(lngFailedJobs);
  32.  
  33. }
  34. catch(java.io.IOException e)
  35. {
  36.     println "Unable to connect to JVM"
  37.     System.exit(0)
  38. }
RAW Paste Data
Top