views:

243

answers:

4

Anybody knows a Java library similar to Hyperic SIGAR?. I'm interested mostly in process monitoring & CPU usage.

A: 

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.

mttr
- On the opensource part it is GPL, which is not easy to handle in a commercial product - the library needs to be installed manually and you have to not link your product to a GPL library.- On the commercial part(we want to pay a license), you cannot license the library, you have to buy the whole Hyperic package. We just need a way to query for process stats, fast and reliable.
adrian.tarau
+1  A: 

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.

dblock
Thanks dblock, looks interesting but unfortunately no support for Linux/Solaris yet.
adrian.tarau
A: 

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.

evernat
adrian.tarau
+1  A: 

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..
David
That's great, thank you!! However, there is no official 1.6.4 distribution. I could find all binary files for 1.6.4 - http://svn.hyperic.org/projects/sigar_bin/dist/SIGAR_1_6_4/lib/ - but on SourceForge there is only 1.6.3 available. Where did you find the change list?
adrian.tarau
I found the ChangeLog in the source hosted on github (http://github.com/hyperic/sigar/blob/master/ChangeLog), that's supposed to be the master git repository according to the 'Source' section on the website.You're right though I guess there's no official 1.6.4 distribution yet. However you could try one of the binary snapshot builds I guess which seems to go up to 1.6.5 or build from the source.
David