Java 如何获取 PC 的主板温度(以及其他硬件统计数据)?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/123575/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 08:34:13  来源:igfitidea点击:

How to get the temperature of motherboard of a PC (and other hardware statistics)?

javastatisticshardwaretemperature

提问by ramayac

does any one know how to get the current motherboard, processor or HD temperature statistics?
In GNU/Linux, I know I could use something like hddtemp or sensord to get the info, and then parse it... but in Windows: How can I do this? And, Can it be done with with C# or Java or any other hight level programming language?
Thanks!

有谁知道如何获取当前的主板、处理器或HD 温度统计数据?
在 GNU/Linux 中,我知道我可以使用 hddtemp 或 sensord 之类的东西来获取信息,然后对其进行解析……但在 Windows 中:我该怎么做?而且,它可以用 C# 或 Java 或任何其他高级编程语言完成吗?
谢谢!

采纳答案by vadimus

The problem with temperature and other monitoring sensors is that there is no common protocol on the hardware level, nor drivers allowing to retrieve that information with common API.

温度和其他监测传感器的问题在于硬件级别没有通用协议,也没有允许使用通用 API 检索该信息的驱动程序。

Software like already mentioned SpeedFan and HWMonitor(from the makers of CPU-Z utility) work by painstakingly cataloging the various sensors and bus controllers, and implementing corresponding protocols, usually using kernel-mode driver to access SMBus devices.

像已经提到的 SpeedFan 和HWMonitor(来自 CPU-Z 实用程序的制造商)这样的软件通过精心编目各种传感器和总线控制器并实现相应的协议来工作,通常使用内核模式驱动程序来访问 SMBus 设备。

To embed this functionality in you own software, you can either develop this functionality yourself (possibly reducing the amount of work by tailoring it to your specific hardware, and using linux code from www.lm-sensors.org as reference) or purchasing commercial library that implements it. One, used by HWMonitor, is available here.

要将这个功能嵌入到你自己的软件中,你可以自己开发这个功能(可能通过根据你的特定硬件定制它来减少工作量,并使用来自 www.lm-sensors.org 的 linux 代码作为参考)或购买商业库实现它。一种由 HWMonitor 使用,可在此处获得

good luck

祝你好运

回答by Kent Fredric

I would argue that when the right configurations are in place, it can be superior to windows's one.

我会争辩说,当正确的配置到位时,它可以优于 Windows 的配置。

http://www.lm-sensors.org/is what does all the work. I had that plugged into RRDgraph & Munin and I was monitoring the temperature of my room over a period of almost a year and had nice pretty graphs. Also showed me my CPU fan was slowly wearing down, and I could see the line sloping down over a long period and know it was on the way out.

http://www.lm-sensors.org/ 负责所有工作。我把它连接到 RRDgraph & Munin 中,我在将近一年的时间里监测我房间的温度,并有漂亮的图表。还向我展示了我的 CPU 风扇正在慢慢磨损,我可以看到线在很长一段时间内向下倾斜,并且知道它正在退出。

http://www.lm-sensors.org/browser/lm-sensors/trunk/doc/developers/applicationsis what you want.

http://www.lm-sensors.org/browser/lm-sensors/trunk/doc/developers/applications就是你想要的。

(Oh wait, I fail. You're on *nix wanting to do it on Windows, my bad :( ..um.. well. Good luck. Maybe I'll leave this here in case somebody finds your post while searching for the contrary)

(哦等等,我失败了。你在 *nix 上想要在 Windows 上做这件事,我的坏:( ..um.. 好吧。祝你好运。也许我会把这个留在这里,以防有人在搜索相反)

Back when I did use windows, all I recall is Ye' Old Motherboard Monitor ( Discontinued ). Wiki article says there is speedfanand that looks like your best option. Programmatically, I guess you'll have to find the hardware specs and dig through Windows API and stackloads of arbitrary bus address offsets.

当我确实使用 windows 时,我记得的只是 Ye' Old Motherboard Monitor (Discontinued)。维基文章说有speedfan,这看起来是你最好的选择。以编程方式,我猜您必须找到硬件规格并挖掘 Windows API 和任意总线地址偏移的堆栈。

回答by AndrewJFord

This is going to vary quite a bit depending on your hardware. Once you figure out from your hardware vendor whether you have sensors on your motherboard, you might look into using SNMP and the HOST-RESOURCE MIB.

这将根据您的硬件而有所不同。一旦您从硬件供应商处确定您的主板上是否有传感器,您可能会考虑使用 SNMP 和 HOST-RESOURCE MIB。

Use the Add/Remove Windows Components Wizard under Management and Monitoring Tools to get SNMP installed. Then you should be able to ask your Windows box for lots of info using standard systems management software like OpenView or Nagios.

使用管理和监控工具下的添加/删除 Windows 组件向导来安装 SNMP。然后,您应该能够使用 OpenView 或 Nagios 等标准系统管理软件向 Windows 设备询问大量信息。

回答by Chopper3

As @AndrewJFord suggest these methods vary from vendor to vendor, indeed from part to part, but I'll make some generalisations if that's ok.

正如@AndrewJFord 所建议的那样,这些方法因供应商而异,确实因零件而异,但如果可以的话,我会进行一些概括。

  1. As far as I know all current mainstream processors by Intel, AMD and IBM have on-board thermal sensors with known exposed APIs for reading this data. I'm no expert in these APIs so don't know how similar they are but I'd be surprised if Intel's and AMDs API are that much different. If I were you I'd search for an open-source 'system management tool' (there are a few like this written as Apple Widgets by the way) and see how they do it.
  2. Motherboards vary a hell of a lot, some have extensive thermal senesoring, some none and all will have fairly different APIs. I'd start by contacting the support people at the company who makes your mobo-of-choice.
  3. In general I believe that only very high-end 15krpm SAS disks have built-in thermal sensors, I know that some mid-range systems have sensors taped to their case at the hub and report that back to the mobo. Really not sure on how to get at this info but again I'd start by speaking with the same people as the question above.
  1. 据我所知,英特尔、AMD 和 IBM 的所有当前主流处理器都具有板载热传感器,这些传感器具有已知的公开 API 来读取这些数据。我不是这些 API 的专家,所以不知道它们有多相似,但如果英特尔和 AMD 的 API 有如此大的不同,我会感到惊讶。如果我是你,我会搜索一个开源的“系统管理工具”(顺便说一下,有一些像这样写成 Apple Widgets),看看他们是如何做到的。
  2. 主板千差万别,有些具有广泛的热感应,有些则没有,而且所有的 API 都非常不同。我会首先联系公司的支持人员,他们为您选择主板。
  3. 一般来说,我相信只有非常高端的 15krpm SAS 磁盘具有内置的热传感器,我知道一些中档系统在集线器的外壳上贴有传感器,并将其报告给主板。真的不确定如何获取此信息,但我再次与上述问题的同一个人交谈。

Now I'm a big HP user and all of their kit is instrumented by something called Insight Management Agents, of which there are versions available for Windows and most Linux's. What they do is gather all the system information from all their sensors (proc, memory, mobo, fans, disks etc) and expose that via an SNMP-based polling API or via an alert-based SNMP/SMTP/MAPI interface. I dare say IBM/Dell etc will have their own equally good and functionally similar versions but I don't know them sorry. If your machines are 'off-brand'/made-from-kit or you have no control then I'm not aware of any single method of getting at all this information easily.

现在,我是 HP 的大用户,他们的所有工具包都由称为Insight Management Agents的东西检测,其中有适用于 Windows 和大多数 Linux 的版本。他们所做的是从所有传感器(进程、内存、主板、风扇、磁盘等)收集所有系统信息,并通过基于 SNMP 的轮询 API 或基于警报的 SNMP/SMTP/MAPI 接口公开这些信息。我敢说 IBM/Dell 等将拥有自己同样出色且功能相似的版本,但我不知道他们很抱歉。如果您的机器是“非品牌”/由套件制造的,或者您无法控制,那么我不知道有任何一种方法可以轻松获取所有这些信息。