Monitoring open socket

Enrico Olivelli eolivelli at gmail.com
Fri May 3 10:28:41 PDT 2013


Il 02/05/2013 22:44, Alan Bateman ha scritto:
> On 02/05/2013 20:35, Enrico Olivelli wrote:
>> Hi,
>> In jdk7 there is no way to ask the jvm for the list of actually active
>> sockets, witout jni or any other native non-portable solution.
>> Is there any plan to add a jmx set of beans to monitor jvm network
>> activity  in a portable manner?
>> Thanks
>> Enrico
> I don't know which operating system you are on but the JDK has a 
> platform-specific management interface named 
> com.sun.management.UnixOperatingSystemMXBean that allows the number of 
> open file descriptors to be monitored. This isn't enumerating the open 
> sockets so it might not be want you want. Personally I would use lsof 
> or /proc to look at the target VM for information like this.
>
> -Alan.
>
For Unix deployments I use lsof too but is not a portable solution and I 
don't like my JVM to start external processes to look inside itself
As you said UnixOperatingSystemMXBean  is useful only to get the number 
of open FD
I would like a standard facility to list all open sockets, at least:
- endpoint addresses (local address and port and remote address and port)
- connection status (ESTABLISHED, TIME_WAIT....)
- timestamp of creation...
- timestamp of last activity ?

thanks
Enrico





More information about the jdk8-dev mailing list