What is the best way for a Java program to monitor system health? [closed]

你说的曾经没有我的故事 提交于 2019-12-09 05:25:00

问题


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?

回答1:


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).




回答2:


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.




回答3:


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)?




回答4:


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.




回答5:


JMX + JNI = YourSolution



来源:https://stackoverflow.com/questions/117043/what-is-the-best-way-for-a-java-program-to-monitor-system-health

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!