Skip to content

Instantly share code, notes, and snippets.

@rah003
Last active October 27, 2020 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rah003/c586e57e9239f6f49fe3cd905d2c87c9 to your computer and use it in GitHub Desktop.
Save rah003/c586e57e9239f6f49fe3cd905d2c87c9 to your computer and use it in GitHub Desktop.
Get number of active sessions in Magnolia in Tomcat using Groovy
import java.lang.management.ManagementFactory
import javax.management.ObjectName
import org.apache.commons.lang3.StringUtils
ObjectName objectName = new ObjectName("Catalina:type=Manager,context="+StringUtils.defaultIfBlank(ctx.contextPath,"/")+",host=localhost");
Object activeSessions = ManagementFactory.getPlatformMBeanServer().getAttribute(objectName, "activeSessions");
println(activeSessions);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment