gad*_*hvi 2 windows cpu temperature snmp zabbix
我目前正在研究 NMS Zabbix。经过一些研发,我能够通过 snmp 以及使用 LM-SENSORS 的终端获取 Linux 上的 CPU 温度信息。但是,这不适用于 Windows;我看到 Windows 没有 LM-SENSORS,也许这就是 LM-SENSOR-MIB 没有为 Windows 提供任何输出的原因。任何人都可以建议可以在 Windows 中使用哪些 mib 来获取 CPU 温度信息,以及如何在 cmd 终端中获取相同的信息?
请尝试以下操作。
批处理文件 (GetCpuTmp.cmd)
Run Code Online (Sandbox Code Playgroud)@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
源批处理文件以°C 为单位获取 CPU 温度并设置为变量,由David Ruhmann回答
示例输出:
> GetCpuTemp.cmd
73.05 Degrees Celsius
Run Code Online (Sandbox Code Playgroud)
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.
Run Code Online (Sandbox Code Playgroud)
Source使用 PowerShell 获取 CPU 温度
示例输出:
> get-temperature
73.05 C : 163.49 F : 346.2K
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
82156 次 |
最近记录: |