Created
June 2, 2011 13:19
-
-
Save ran488/1004405 to your computer and use it in GitHub Desktop.
Sample of invoking JMX operations from Groovy
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
#!/usr/bin/env groovy | |
import java.lang.management.* | |
import javax.management.ObjectName | |
import javax.management.remote.JMXConnectorFactory as JmxFactory | |
import javax.management.remote.JMXServiceURL as JmxUrl | |
def serverUrl = 'service:jmx:rmi:///jndi/rmi://localhost:9987/jmxrmi' | |
String beanName = "com.somecompany.Scheduler:k=ScheduledTasks" | |
def server = JmxFactory.connect(new JmxUrl(serverUrl)).MBeanServerConnection | |
def gmxb = new GroovyMBean(server, beanName) | |
println "Connected to:\n$gmxb\n" | |
println "Executing runTaskNow()" | |
gmxb.runTaskNow() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment