Created
October 5, 2018 22:53
-
-
Save tembleking/2cc90577974b5b71f303c77b42b39b1a to your computer and use it in GitHub Desktop.
JMX MBean Main Example
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 java.lang.management.ManagementFactory; | |
public class Main { | |
public static void main(String[] args) { | |
try { | |
String programName = (args.length == 0) ? "Java" : args[0]; | |
// Initialize the object | |
SystemStatus systemStatus = new SystemStatus(programName); | |
// Register the object in the MBeanServer | |
MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer(); | |
ObjectName objectName = new ObjectName("com.sysdig.app:name=SystemStatusExample"); | |
platformMBeanServer.registerMBean(systemStatus, objectName); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment