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?

2 Answers 2

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
6
  • 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 5, 2017 at 14:10
  • Did you run the scripts as administrator?
    – DavidPostill
    Sep 5, 2017 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 6, 2017 at 11:32
  • 3
    This is not CPU temp, but rather mb temp stackoverflow.com/questions/9101295/…
    – fab2s
    Dec 20, 2019 at 9:34
  • To run this you need to run the command here: stackoverflow.com/a/4038991 However, as stated in the comment above, it does not give you the CPU temperature.
    – alfreema
    May 6, 2021 at 15:33
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)
7

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .