Created
January 30, 2013 20:25
-
-
Save nshaw/4676589 to your computer and use it in GitHub Desktop.
Groovy script to display the current number of active Tomcat sessions. Useful if you don't have a Tomcat monitoring solution in place.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.lang.management.ManagementFactory | |
import javax.management.MBeanServer | |
import javax.management.ObjectName | |
import com.liferay.portal.kernel.util.StringUtil | |
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); | |
ObjectName objectName = new ObjectName("Catalina:type=Manager,context=/,host=localhost") | |
Object mbean = mbs.getMBeanInfo(objectName); | |
println "Found manager bean" | |
//println mbean.toString() | |
String ids = (String) mbs.invoke(objectName, "listSessionIds", null, null) | |
//println ids | |
String[] list = StringUtil.split(ids, " ") | |
println "Total number of sessions: " + list.size() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment