I want to write app in java which will get info about processes and threads running on Jboss JVM (%cpu usage, memory etc.). I also want to find info about memory usage and other important things in JVM (JBoss). How to write it in pure java?
I know about things like JConsole, but I need to write it by myself. I’ve found java.lang.managament interface which gives some information about system, memory etc, but not all needed information are provided. For example I’d like to have opportunity read cpu usage (not cpu time) and memory used by every thread. (something like top command in bash, but I need to make it in java).
Any help?
EDIT: Eventually I can use some libraries to get this info.
The JBoss AS 7 provide different management interfaces. All the management interfaces based on the Detyped Management representation (jboss-dmr).
You can implemet a custom Java client with the jboss-dmr library and the jboss-as-controller-client. For an example, see our github repository.
To get information about the JVM and other stuff, you need to implement the following operation:
Alternatively, you can also use the PlatformMBeanServer: