macos 如何在 OS X 上获取 CPU 温度和风扇速度?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2216888/
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-10-21 06:44:36  来源:igfitidea点击:

How to get CPU temperature and fan speed on OS X?

macosiokittemperature

提问by Lajcik

How do I get CPU temperature and fan speeds in OS X?

如何在 OS X 中获取 CPU 温度和风扇速度?

I understand that information is obtained from IOHWSensorin IOKit, but I'm unable to find any reliable information on how to exactly do that.

我知道信息是从IOHWSensorin获得的IOKit,但我无法找到任何关于如何准确做到这一点的可靠信息。

I've found an article with a sample program - http://www.booktou.com/node/148/0321278542/ch10lev1sec7.html, but all I get with it is the GPU temperature. I'm sure there are CPU temperature sensors on the unibody Macs, so that means I'm doing something wrong.

我找到了一篇带有示例程序的文章 - http://www.booktou.com/node/148/0321278542/ch10lev1sec7.html,但我得到的只是 GPU 温度。我确定一体式 Mac 上有 CPU 温度传感器,所以这意味着我做错了什么。

采纳答案by markratledge

The source code for this Prefpane that's called FanControl is avilable; it shows temperatures and fan speeds: http://www.lobotomo.com/products/FanControl/index.html

这个名为 FanControl 的 Prefpane 的源代码是可用的;它显示温度和风扇速度:http: //www.lobotomo.com/products/FanControl/index.html

回答by Jan Kuri

If you have npm installed, there is also cli tool called macstats. You can install it using:

如果您安装了 npm,还有一个名为macstats 的cli 工具。您可以使用以下方法安装它:

[sudo] npm install macstats -g

[sudo] npm install macstats -g

Then just run the command and it will give you output like:

然后只需运行该命令,它将为您提供如下输出:

--- CPU Stats ---
CPU Temp:        33.75°C

--- Fans Stats ---
Fan 0 speed:     1996 RPM
Fan 1 speed:     2003 RPM

--- Battery Stats ---
Charged:         82%
Capacity:        92%
Cycle Count:     692 (69%)
Max Cycle Count: 1000
Current Charge:  5189 mAh
Maximum Charge:  6316 mAh
Design Capacity: 6900 mAh
Time Remaining:  6.54 h
Temperature:     30.06°C

The tools also exposes API that you can use in a custom application.
See https://github.com/jkuri/macstatsfor more information.

这些工具还公开了您可以在自定义应用程序中使用的 API。
有关更多信息,请参阅https://github.com/jkuri/macstats