7

I am currently working on NMS Zabbix. After some R&D, I am able to get the CPU temperature info on Linux via snmp as well as terminal using LM-SENSORS. However, the same doesn't work for Windows; I see windows doesn't have LM-SENSORS, and maybe that's why LM-SENSOR-MIB is not giving any output for Windows. Can any one suggest which mibs can be used in Windows to get CPU temperature info, and also, how can I get same information in a cmd terminal?

gadhvi
  • 137
  • 1
  • 3
  • 12

2 Answers2

12

How can I get the CPU temperature in a cmd shell?

Try the following.

Batch file (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

Source Batch-file get CPU temperature in °C and set as variable, answer by David Ruhmann

Example output:

> GetCpuTemp.cmd
73.05 Degrees Celsius

PowerShell function (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.

Source Get CPU Temperature With PowerShell

Example output:

> get-temperature
73.05 C : 163.49 F : 346.2K
DavidPostill
  • 153,128
  • 77
  • 353
  • 394
  • thankyou I tried but it didn't work, I tried searching for some 3rd party application which can give me cmd output but I couldn't find any, do you have any idea about any app that can give temperature output in txt file or command prompt. I tried installing coretemp, realtemp, HWMonitor but all of them are GUI based and don't give output at terminal level or in txt file. – gadhvi Sep 05 '17 at 14:10
  • Did you run the scripts as administrator? – DavidPostill Sep 05 '17 at 14:12
  • >Yes , here is my cmd output >C:\paras> GetCpuTmp.cmd >Node - PUNSHI-WINDOWS >ERROR: >Description = Not supported >~0,-2HunDegCel:~-2 Degrees Celsius – gadhvi Sep 06 '17 at 11:32
  • 3
    This is not CPU temp, but rather mb temp https://stackoverflow.com/questions/9101295/msacpi-thermalzonetemperature-class-not-showing-actual-temperature/17083409#17083409 – fab2s Dec 20 '19 at 09:34
  • To run this you need to run the command here: https://stackoverflow.com/a/4038991 However, as stated in the comment above, it does not give you the CPU temperature. – alfreema May 06 '21 at 15:33
  • `Get-WmiObject` has since this answer been superseded by `Get-CimInstance`, see [MSDN](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-wmiobject?view=powershell-5.1#description). The return object is an array of thermal zones; see the comments in the source-link above for a fix. – Reyhn Jul 24 '23 at 08:54
1

You can use Open Hardware Monitor it's an open source software (MPL v2). You can access the command line version here:

OpenHardwareMonitorReport.zip

Example part of the output:

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)
uak
  • 49
  • 3
  • OpenHardwareMonitor doesn't work properly on my PC. No temperatures are shown. The only other program I have found is HWiNFO64 Pro which isn't free. Is there really no other software? – Aenfa Aug 03 '22 at 14:05
  • @Aenfa did you check the recent version https://github.com/openhardwaremonitor/openhardwaremonitor/pull/1115#issuecomment-1189362017 – uak Aug 04 '22 at 03:52
  • Still no temperature information when trying the recent version. – Aenfa Aug 04 '22 at 15:25
  • @Aenfa found this fork of the application with more recent updates https://github.com/hexagon-oss/openhardwaremonitor – uak Aug 06 '22 at 03:45
  • Also found this @Aenfa https://github.com/LibreHardwareMonitor/LibreHardwareMonitor – uak Aug 08 '22 at 06:30
  • LibreHardwareMonitor works but how can I use it from the command line? – Aenfa Aug 09 '22 at 10:45
  • Aenfa, not sure if it supports CMD, if no please open an issue in LibreHardwareMonitor github and mention the PR that offered to add it to the original software. – uak Aug 09 '22 at 14:34