Last active
October 27, 2020 19:25
-
-
Save rah003/c586e57e9239f6f49fe3cd905d2c87c9 to your computer and use it in GitHub Desktop.
Get number of active sessions in Magnolia in Tomcat using Groovy
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.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