Skip to content

Instantly share code, notes, and snippets.

@tembleking
Created October 5, 2018 22:53
Show Gist options
  • Save tembleking/2cc90577974b5b71f303c77b42b39b1a to your computer and use it in GitHub Desktop.
Save tembleking/2cc90577974b5b71f303c77b42b39b1a to your computer and use it in GitHub Desktop.
JMX MBean Main Example
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