Anybody knows a Java library similar to Hyperic SIGAR?. I'm interested mostly in process monitoring & CPU usage.
That's pretty much exactly what Hyperic's SIGAR does and SIGAR does offer its API in Java. Just out of interest, why would you need an alternative?
If you have licensing constraints, that's a problem as I am not aware of a good alternative. One possible solution might be DIY: If you just want to get process and CPU usage info, you could of course write some code that executes shell commands (from your Java app) to inspect the process tables and OS info on the CPU. That would be fairly simple to implement, however, I suspect you may get disappointing performance from such a solution. Then again, this should not take more than an hour or two to implement and then you can test its performance. I hope this helps.
We've been having the same problems: native DLL and GPL. There's a new project, OSHI that aims to solve both. It's licensed under EPL v2. It's very young, but with a bit of work it can easily cover all of SIGARs functionality without any native code.
You could use JavaMelody. It is free (LGPL).
It give reports with graphics to monitor the cpu of the java process but also memory (heap and non heap), GC, threads, http sessions, jdbc connections and a lot more in your server.
http://javamelody.googlecode.com
Or if you just want to check from time to time, you can manually connect to your java process with jconsole or jvisualvm of the JDK.
Although the SIGAR website says it's licensed under GPL, according the Changelog the license was changed from GPL v2 -> Apache2 with the 1.6.4 release. So perhaps it is ok for commercial use as of the 1.6.4 release.
2010-04-28 Doug MacEachern <[email protected]>
* 1.6.4 release
* GPL v2 license -> Apache 2 license
...snip..