Saturday, September 26, 2009

VaaS - VisualVM as a Service

Recently, I had to monior some java6 process running as a windows service. Since VisualVM + java6 gives an out-of-the-box tracing/monitoring capability, I wanted to try out VisualVM - but it would not list the process at all!

Turns out that VVM cannot reach out to Local System processes - due to permission issues most likely. But, there are a couple of hacks* to it.

1. Run Visual VM as a Windows Service

2. Run cmd.exe as a windows service. A cool way to get a hook to run any executable as a windows service process. Then launch Visual VM from the same.

The key thing here was to enable the service to Interact with desktop.

On a remote machine(Windows 2003) using Remote Desktop, I tried both of them (for some reason I like the cmd.exe as a service better). I could see the processes launched, but I cannot see them in my desktop. I used Process Explorer and saw that I cannot access the Window for these processes. The same thing works on my desktop though (again Win2003).

Then it struck me that I have not logged in on the remote machine on the console session. (Console session is the one that user logs in on the actual machine).

I launched another RDC as "mstsc /console -v " and I got the thing working.

Nothing more** to stop us from VisualVM on any JVM!


=============================================================

* Of course, one can enable JMX monitoring capabilities and attach Visual VM through JMX. I dint want to do this for need of changing the way my process was launched


** Conditions apply!

No comments: