views:

2365

answers:

6

I would like to be able to monitor my major system health indicators from inside our Java-based system. Major points of interest include CPU temperature, motherboard temperature, fan speed, etc.

Is there a package available that:

  1. Makes this sort of data available to Java?
  2. Works on Windows or Linux or both?
  3. Is open / free / cheap?
A: 

A few months ago I looked for such a library and I found nothing interesting. It is not impossible to create one, so I would recommend doing so. You'll probably need to access native libraries, to do that use JNA (it's easier than JNI). Start by adding support for a few things on one platform, then start adding support for other features and platforms.

The share it with us! People will starts using it, maybe even help with development and soon you'll have a fully featured system monitoring library for Java.

Andreas Holstenson
Thanks, I had never heard of JNA.
Bob Cross
A: 

JMX + JNI = YourSolution

l_39217_l
This isn't really an answer. Do you have something specific in mind?
Bob Cross
+5  A: 

The closest thing you'll find is the Hyperic Sigar library:

http://www.hyperic.com/products/sigar.html

It doesn't get down to temperatures AFAIK but does show you a number of native stats like CPU, memory, disk I/O, network I/O, etc. It's ported to most of the architectures people are deploying Java on today. License is GPL although I think you can buy commercial licenses as well.

We use Sigar with Terracotta for cluster monitoring and have been very happy with it.

Alex Miller
CPU temperature is something that we specifically need so this is a major limitation.
Bob Cross
+5  A: 

I believe most of this sort of thing is usually done over SNMP (for professional system) is the usual way to make this sort of information available in a standards-based manner. JMX is also available over SNMP. The question then becomes, which are the better SNMP libraries for Java (and does your system support it)?

Tom Hawtin - tackline
+2  A: 

There are MIBs supported by both Windows and Linux that expose the parameters you are looking for via SNMP. Also, most major vendors have special MIBs published for their server hardware.

I have implemented SNMP MIBs and monitoring for Java applications using the commercial iReasoning SNMP API and they worked great. There is also the open source SNMP4J, which I don't personally have experience with, but looks pretty good.

So, for your needs, you would turn on the publishing of SNMP information for the hosts you want to monitor. No coding necessary. This is just a configuration issue.

For CPU temperature, for example, you must enable the MIB LM-SENSORS-MIB. Under Linux you can use the snmpwalk client to take a look at OID .1.3.6.1.4.1.2021.13.16.2.1.3 to see CPU temperature. Once you have that up and you know it's publishing data correctly, you can begin to implement your real monitoring solution.

You can use a Java SNMP library to poll and subscribe to SNMP traps for the hosts you want to monitor. You could also use any commercial or open-source monitoring tool (Google for SNMP console).

shadit
A: 

This is a good link providing information on Java SE monitoring and management... http://java.sun.com/javase/6/docs/technotes/guides/management/toc.html

Thanks, JC