Monitoring GlassFish with jconsole
The default GlassFish installations has a JMX listening socket on port 8686 (for GlassFish v2ur2) or 8696 (for GlassFish v2.1-b60) that speaks some type of RMI protocol. To connect jconsole to this port, start jconsole and enter this URL:
If you have firewalled this port, you can tunnel jmxrmi over ssh. You need to make ssh forward two ports: 8686 (or 8696) and a randomized port with a high port number. This unknown port number can be determined like this:
Now you can track the memory and CPU load of GlassFish on your remote server. If the CPU load seems abnormally high, you can take a snapshot of all the threads by doing "
[Footnote: GlassFish v2.1-b60a has moved back the rmi socket to port 8686 again]
service:jmx:rmi:///jndi/rmi://www.example.com:8686/jmxrmiand fill in "admin" as the username, plus the corresponding password. And change
www.example.com
to the GlassFish host, and change the port number to 8696 if you are running v2.1-something (I don't know when they changed the port number).If you have firewalled this port, you can tunnel jmxrmi over ssh. You need to make ssh forward two ports: 8686 (or 8696) and a randomized port with a high port number. This unknown port number can be determined like this:
# lsof -nPp 4711 | grep LISTENwhere you change "4711" to whatever the GlassFish pid is. The line below
TCP *:8686 (LISTEN)
will typically contain the second port number. If it doesn't work, try one of the other high port numbers. Then create the ssh tunnels, start jconsole, and enter localhost
as the host in the jmxrmi URL.Now you can track the memory and CPU load of GlassFish on your remote server. If the CPU load seems abnormally high, you can take a snapshot of all the threads by doing "
jstack 4711
" in a server shell. For some bizarre reason, jstack running as root refuses to dump stack traces of a GlassFish process that is running as some other user. So you need to do e.g. "sudo -u myglassfishuser jstack 4711
" from your root shell. [Footnote: GlassFish v2.1-b60a has moved back the rmi socket to port 8686 again]