Re: Getting CPU usage percentage

205 views
Skip to first unread message

Jez Humble

unread,
Jan 19, 2010, 1:21:52 PM1/19/10
to Stas Oskin, javas...@googlegroups.com
Hey Stas
 
Thanks Jez, it would be one step closer to help me switch from SIGAR.

First I've heard of it - thanks for pointing me in that direction. 

By the way, can you share how exactly you made the native lib work out of JAR? Is there any resource out there that explains how to do it?

Sure - originally I used one-jar, but it means you can't use the jar as a library. So that was no good. What I do now is have a static method in the Java classes that use JNI that instantiates the class NativeLibraryLoader: http://github.com/jezhumble/javasysmon/blob/master/src/main/java/com/jezhumble/javasysmon/NativeLibraryLoader.java

That class copies the native library from inside the jar to a temporary file on the filesystem, and then uses System.load to get the JVM to recognize it.
 
Last but not least - how stable is the process control? I.e., if I want to kill a process, how stable is it - won't it crash the JVM by chance

They should all be pretty stable - it shouldn't crash the JVM unless you tell it to ;-)

Having said that, the library hasn't been tested very extensively yet, so YMMV.

Thanks,

Jez.
Reply all
Reply to author
Forward
0 new messages