2

I want to create a JMX agent that has to be accessible from local host only.

  • Please advise how can I do that.
  • Also help with a Simple JMX client on same machine that will connect to that JMX agent.
  • If somehow we can get away with specifying an explicit port, that will be helpful.
MoveFast
  • 3,011
  • 2
  • 27
  • 53

1 Answers1

2

You might find this helpful. It uses the attach API for Oracle's JVM to connect to a running Java process and have it start a local only JMX agent. You would setup whatever MBeans you want to expose as usual. I get the impression that this code is similar to what JConsole does for connecting to local JVM processes. You might also want to investigate the source for Jmxterm which leverages JConsole for connecting to local JVM processes.

laz
  • 28,320
  • 5
  • 53
  • 50
  • 2
    The one advisory about using the attach API is that under the covers, it basically spins up a javax.management.remote.rmi.RMIConnectorServer which it then uses to provide you a JMXConnection and MBeanServerConnection. Whether or not that RMIConnectorServer is accessible from another host is dependent on a host (he he) of variables. In my experience, Windows yes, *nix no. – Nicholas Jul 09 '11 at 19:31