Search this site





Querying temperature in Windows

It occured to me tonight that I didn't have a good way to query temperatures from a Windows box. I'd used GUI tools to do it before, but that doesn't really lend itself to automation and monitoring.

The default SNMP configuration in XP doesn't export temperature (at least nothing I saw). I knew SMART had temperature information, but that wasn't CPU temperature or anything else outside the harddrive.

SMART data is accessible through a number of tools. I've used smartmontools before, but didn't know they had a build available for Windows until just now. Same tools as the Linux/FreeBSD/whatever versions. The device naming is the same as on the non-windows versions, and the smartctl manpage details the syntax. I wanted temperature information, and powershell helps make this pretty easy:

PS > .\smartctl.exe -a /dev/hda `
     | where {$_ -match "Temperature"} `
     | foreach { $_.split()[-1] }

After a bit of randomly permuting search queries, I found that some temperature information is available through WMI. The temperature values are in tenths of kelvin. We can query this from powershell:

PS > get-wmiobject MSAcpi_ThermalZoneTemperature -namespace "root/wmi" `
     | select CurrentTemperature,InstanceName

CurrentTemperature InstanceName
------------------ ------------
              3102 ACPI\ThermalZone\THRM_0
I found this particular WMI class by doing the following after getting some hints from search results:
PS > get-wmiobject -namespace "root/wmi" -list | findstr Temp
MSAcpi                                    MSAcpi_ThermalZoneTemperature