Jump to content

CPU temperature


Recommended Posts

Hi,

My computer is starting to get hot again so to verify it I want to make a script that will take the CPU sensor data every 30 sec/1 min and put it in a CSV.

I know how to do everything except how to get the CPU temp. I did a search and the best I could find was CompInfo that didn't have temperature measurement in it.

Can someone point me to the direction where to look for?

Link to comment
Share on other sites

My motherboard is an ASUS P4S800 w/ a intel P4 (presscot based).

can this app export a log file? I need to check the CPU under long idles and extreme conditions to be able to check it w/ excel (graphs and co.)

Link to comment
Share on other sites

I can't seem to translate any VBS code to AU3.

Func CPUTemp($sComputer = ".")
    Local $Obj, $Item, $Items
    $Obj = ObjGet("winmgmts:\\" & $sComputer & "\root\WMI")
    $OEvent=ObjEvent("AutoIt.Error","nothing")
    If IsObj($Obj) Then
        ConsoleWrite("+> Item is object!")
        $Item = $Obj.ExecQuery("SELECT * FROM MSAcpi_ThermalZoneTemperature")
        For $Items in $Item
            ConsoleWrite("Current Temperature: " & $Items.CurrentTemperature)
            ConsoleWrite("Critical Trip Point: " & $Items.CriticalTripPoint)
        Next
    EndIf
EndFunc

#cs
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\WMI")
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM MSAcpi_ThermalZoneTemperature",,48)
For Each objItem in colItems
Wscript.Echo "-----------------------------------"
Wscript.Echo "MSAcpi_ThermalZoneTemperature instance"
Wscript.Echo "-----------------------------------"
Wscript.Echo "CurrentTemperature: " & objItem.CurrentTemperature
Wscript.Echo "CurrentTemperature: " & objItem.CriticalTripPoint
Wscript.Echo "CurrentTemperature: " & objItem.ThermalStamp
Next
#ce

The object never works though :hmm:

Link to comment
Share on other sites

I can't seem to translate any VBS code to AU3.

Func CPUTemp($sComputer = ".")
    Local $Obj, $Item, $Items
    $Obj = ObjGet("winmgmts:\\" & $sComputer & "\root\WMI")
    $OEvent=ObjEvent("AutoIt.Error","nothing")
    If IsObj($Obj) Then
        ConsoleWrite("+> Item is object!")
        $Item = $Obj.ExecQuery("SELECT * FROM MSAcpi_ThermalZoneTemperature")
        For $Items in $Item
            ConsoleWrite("Current Temperature: " & $Items.CurrentTemperature)
            ConsoleWrite("Critical Trip Point: " & $Items.CriticalTripPoint)
        Next
    EndIf
EndFunc

#cs
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\WMI")
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM MSAcpi_ThermalZoneTemperature",,48)
For Each objItem in colItems
Wscript.Echo "-----------------------------------"
Wscript.Echo "MSAcpi_ThermalZoneTemperature instance"
Wscript.Echo "-----------------------------------"
Wscript.Echo "CurrentTemperature: " & objItem.CurrentTemperature
Wscript.Echo "CurrentTemperature: " & objItem.CriticalTripPoint
Wscript.Echo "CurrentTemperature: " & objItem.ThermalStamp
Next
#ce

The object never works though :hmm:

Your mother board probably doesn't support the Acpi_ThermalZoneTemperature.

This code works for me

$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
 $strComputer = "."
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\wmi")
$Instances = $objWMIService.InstancesOf("MSAcpi_ThermalZoneTemperature")
For $Item in $Instances
  Msgbox(0,"",($Item.CurrentTemperature - 2732) / 10 & "c")
Next

But it is not the same reading as the previously mentioned application, however I don't think it is reffering to the CPU temp

Link to comment
Share on other sites

Or

$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$strComputer  = "."


$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\wmi")
$colItems = $objWMIService.ExecQuery( "SELECT * FROM MSAcpi_ThermalZoneTemperature", "WQL",$wbemFlagReturnImmediately + $wbemFlagForwardOnly)
$Instances = $objWMIService.InstancesOf("MSAcpi_ThermalZoneTemperature")
$Output=""

For $objItem in $colItems
    $Output&= "-----------------------------------" & @crlf
    $Output&= "MSAcpi_ThermalZoneTemperature instance" & @crlf 
    $Output&= "-----------------------------------" & @crlf
    $Output&= "Active: " & $objItem.Active & @crlf
    If ($objItem.ActiveTripPoint) = 0 Then
        $Output&= "ActiveTripPoint: " & @crlf
    Else
            $a = $objItem.ActiveTripPoint
            $Output&= "ActiveTripPoint: "; & Join($objItem.ActiveTripPoint, ",") & @crlf
                For $i = 0 to Ubound($a) -1
                    $Output&= $a[$i] & ","
                Next    
                If StringRight($Output,1) = "," then $Output = StringTrimRight($Output,1)
             $Output &= @crlf
    EndIf
    $Output&= "ActiveTripPointCount: " & $objItem.ActiveTripPointCount & @crlf
    $Output&= "CriticalTripPoint Raw: " & $objItem.CriticalTripPoint & @crlf
    $Output&= "CurrentTemperature Raw: " & $objItem.CurrentTemperature & @crlf
    $Output&= "InstanceName: " & $objItem.InstanceName & @crlf
    $Output&= "PassiveTripPoint: " & $objItem.PassiveTripPoint & @crlf
    $Output&= "Reserved: " & $objItem.Reserved & @crlf
    $Output&= "SamplingPeriod: " & $objItem.SamplingPeriod & @crlf
    $Output&= "ThermalConstant1: " & $objItem.ThermalConstant1 & @crlf
    $Output&= "ThermalConstant2: " & $objItem.ThermalConstant2 & @crlf
    $Output&= "ThermalStamp: " & $objItem.ThermalStamp & @crlf
    $CurrTemp=$objItem.CurrentTemperature
    
    $Critical = $objItem.CriticalTripPoint
    $Output&= "CriticalTemperature Centigrade: " & ($Critical - 2732) / 10 & @crlf
    $Output&= "CurrentTemperature Centigrade: " & ($CurrTemp - 2732) / 10 & @crlf
    
    $Output&= "CriticalTemperature Farenheit: " & ((9/5)*(($Critical - 2732)/10)) + 32 & @crlf
    $FarTemp=((9/5)*(($CurrTemp - 2732)/10)) + 32
    $Output&= "CurrentTemperature Farenheit: " & $FarTemp & @crlf

Next

If $output = "" then 
    Msgbox(0,"","No ACPI device found")
Else
    Msgbox(0,"",$Output)
EndIf
Link to comment
Share on other sites

Msgbox(0,"",_ACPI_Temp() & "c")

Func _ACPI_Temp()
    
    $wbemFlagReturnImmediately = 0x10
    $wbemFlagForwardOnly = 0x20
    $CurrTemp = -1
    $strComputer  = "."
    $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\wmi")
    $colItems = $objWMIService.ExecQuery( "SELECT * FROM MSAcpi_ThermalZoneTemperature", "WQL",$wbemFlagReturnImmediately + $wbemFlagForwardOnly)

    For $objItem in $colItems
        
        $CurrTemp =($objItem.CurrentTemperature - 2732) / 10
;$Critical = ($objItem.CriticalTripPoint - 2732) / 10

    Next

    Return $CurrTemp

EndFunc

Edited by ChrisL
Link to comment
Share on other sites

Thx, that's exactly what I was looking for. I'm gonna check it now.

edit: BUT... that doesn't work, it returns -1.

Your motherboard doesn't support the MSAcpi_ThermalZoneTemperature then or WMI doesn't get the info

Link to comment
Share on other sites

Thx, that's exactly what I was looking for. I'm gonna check it now.

edit: BUT... that doesn't work, it returns -1.

That indicates your motherboard drivers do not provide an interface to those values. Some just don't, especially older ones.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

There are many tools providing such info out there, some of them free (HWMonitor and other from cpuid.com, SpeedFan, Asus Probe since you have Asus mobo, etc...)

"be smart, drink your wine"

Link to comment
Share on other sites

it isn't an old mb. it's supposed to be something like 2-3 y/o, how new does it need to be to support APCI?

and I need a tool that is small and exports a log (over time), most of the apps just provide the current temp.

Link to comment
Share on other sites

WMI should get it as long as you are running Vista.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

  • 7 months later...

I realize that this thread is a bit old... That script returned -1 for me as well, and my machine specs are...

AMD Phenom Triple-Core processor 8400+ (2.0 GT/s Front-side Bus)

3GB PC2-6400 DDR2 (up-to 8 GB)

640GB 7200 rpm Serial ATA

NVIDA GeForce 6150 SE Graphics with TurboCache (128MB Dedicated GM)

ATI Radeon HD 4850 Dual-Head (512mb)

Brand-spankin new Asus... (Asus M2N68-LA)

Can't say mine is too old...

Survey says!

#RequireAdmin

Worked like a charm... Too bad that guy might never know that... >.<

P.S. I'm running Win7, so I'd assume this works on Vista as well, as the kernel is almost identical... :lmao:

Oh, and I will do my best to lay off the coffee... :)

SIGNATURE_0X800007D NOT FOUND

Link to comment
Share on other sites

  • 2 weeks later...
  • 10 years later...

"Late" is the understatement of the year ;) The last post is > 10 years old and most of the posters have long left the forum.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...