What I want to do: Using JConsole, monitor java application which running on guest OS.
First attempt
I couldn't connect to guest os, so I learnt how to configure the network between Guest OS and Host OS
Guest OS configuration
I'm using Vagrant to manage VMs(Virtual box) on my windows. Basically what I need to do is to configure Host-only adapter. Default adapter is NAT. This is mandatory. So we cannot change it to Host-only, instead, we need to add another adapter which is Host-only.
This can be achieved by adding 1 line in Vagrantfile.
config.vm.network "private_network", type: "dhcp"
or
config.vm.network "private_network", ip: "192.168.33.10"
Then you can see that a new adapter is added by "ip a". You can try pinging to the ip. In below example, it is 172.28.128.3.
Java option
To be visible from Jconsile, you need 2 options.
-Dcom.sun.management.jmxremote.port=PORT
-Djava.rmi.server.hostname=IPADDRESS
Connect as remote
You can connect to IPADDRESS:PORT in jconsole start screen.
Top comments (0)