Created
January 29, 2013 16:30
-
-
Save nicholashagen/4665567 to your computer and use it in GitHub Desktop.
JMX via Groovy with Authentication
This file contains hidden or 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 javax.management.* | |
import javax.management.remote.* | |
def creds = [ 'username', 'password' ] as String[] | |
def env = [ (JMXConnector.CREDENTIALS) : creds ] | |
def serverUrl = 'service:jmx:rmi:///jndi/rmi://hostname:port/jmxrmi' | |
def server = JMXConnectorFactory.connect(new JMXServiceURL(serverUrl), env).MBeanServerConnection | |
new GroovyMBean(server, 'java.lang:type=Threading').dumpAllThreads(true, true).each { thread -> | |
println "THREAD: ${thread.threadName}" | |
} | |
true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment