Last active
April 2, 2018 18:15
-
-
Save fxg42/dd65f9151883b9baf4c215a275fb7dfe to your computer and use it in GitHub Desktop.
JShell script to connect to JMX server
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 javax.management.* | |
import javax.management.remote.* | |
var serverUrl = "service:jmx:rmi:///jndi/rmi://0.0.0.0:9090/jmxrmi" | |
var connection = JMXConnectorFactory.connect(new JMXServiceURL(serverUrl)).getMBeanServerConnection() | |
var objectName = new ObjectName("my-domain:type=my-bean-type,name=my-bean-name") | |
var pingResult = (int) connection.invoke(objectName, "ping", null, null) // Assumes an `int ping()` method that returns the error code. | |
/exit pingResult |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment