我目前正在研究 NMS Zabbix。经过一些研发,我能够通过 snmp 以及使用 LM-SENSORS 的终端在 Linux 上获取 CPU 温度信息。但是,同样的方法不适用于 Windows;我发现 Windows 没有 LM-SENSORS,也许这就是为什么 LM-SENSOR-MIB 没有为 Windows 提供任何输出的原因。有人能建议在 Windows 中可以使用哪些 mib 来获取 CPU 温度信息吗?此外,我如何在 cmd 终端中获取相同的信息?
答案1
如何在 cmd shell 中获取 CPU 温度?
请尝试以下操作。
批处理文件(GetCpuTmp.cmd)
@echo off for /f "skip=1 tokens=2 delims==" %%A in ('wmic /namespace:\\root\wmi PATH MSAcpi_ThermalZoneTemperature get CurrentTemperature /value') do set /a "HunDegCel=(%%~A*10)-27315" echo %HunDegCel:~0,-2%.%HunDegCel:~-2% Degrees Celsius
来源批处理文件获取 CPU 温度(以摄氏度为单位)并设置为变量,回答者大卫·鲁曼
示例输出:
> GetCpuTemp.cmd
73.05 Degrees Celsius
PowerShell 函数(get-temperature.psm1)
function Get-Temperature {
$t = Get-WmiObject MSAcpi_ThermalZoneTemperature -Namespace "root/wmi"
$currentTempKelvin = $t.CurrentTemperature / 10
$currentTempCelsius = $currentTempKelvin - 273.15
$currentTempFahrenheit = (9/5) * $currentTempCelsius + 32
return $currentTempCelsius.ToString() + " C : " + $currentTempFahrenheit.ToString() + " F : " + $currentTempKelvin + "K"
}
# Save in your c:\users\yourName\Documents\WindowsPowerShell\modules\ directory
# in sub directory get-temperature as get-temperature.psm1
# You **must** run as Administrator.
# It will only work if your system & BIOS support it. If it doesn't work, I can't help you.
# Just type get-temperature in PowerShell and it will spit back the temp in Celsius, Farenheit and Kelvin.
示例输出:
> get-temperature
73.05 C : 163.49 F : 346.2K
答案2
您可以使用 Open Hardware Monitor,它是一款开源软件 (MPL v2)。您可以在此处访问命令行版本:
输出示例部分:
PS C:\Users\myuser\OpenHardwareMonitorReport> .\OpenHardwareMonitorReport.exe
Open Hardware Monitor Report
--------------------------------------------------------------------------------
Version: 0.8.0.2
--------------------------------------------------------------------------------
Common Language Runtime: 4.0.30319.42000
Operating System: Microsoft Windows NT 6.2.9200.0
Process Type: 32-Bit
--------------------------------------------------------------------------------
Sensors
|
+- HP 00F52W (/mainboard)
|
+- Intel Core i7-3770 (/intelcpu/0)
| +- Bus Speed : 99.7734 99.7734 99.7784 (/intelcpu/0/clock/0)
| +- CPU Core #1 : 3691.62 3691.62 3791.58 (/intelcpu/0/clock/1)
| +- CPU Core #2 : 3691.62 3691.62 3791.58 (/intelcpu/0/clock/2)
| +- CPU Core #3 : 3791.39 3791.39 3891.36 (/intelcpu/0/clock/3)
| +- CPU Core #4 : 3691.62 3691.62 3891.36 (/intelcpu/0/clock/4)
| +- CPU Core #1 : 42 42 43 (/intelcpu/0/temperature/0)
| +- CPU Core #2 : 43 37 43 (/intelcpu/0/temperature/1)
| +- CPU Core #3 : 42 35 42 (/intelcpu/0/temperature/2)
| +- CPU Core #4 : 45 41 45 (/intelcpu/0/temperature/3)
| +- CPU Package : 45 43 45 (/intelcpu/0/temperature/4)
- 打开硬件监视器官方网站
- 链接到命令行版本所链接的问题:#776
- 较新版本正在等待审核拉取请求