Sign in to follow this  
Followers 0
z999

CPU temperature

18 posts in this topic

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?

Share this post


Link to post
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.)

Share this post


Link to post
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:

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

How do I use this code? I don't get it... I need a function that I can call and will return an intenger w/ the current CPU temperature.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

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

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

Edited by z999

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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"

Share this post


Link to post
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.

Share this post


Link to post
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!"

Share this post


Link to post
Share on other sites

most of the apps just provide the current temp.

So? Auto It.

"be smart, drink your wine"

Share this post


Link to post
Share on other sites

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... :)

1 person likes this

Share this post


Link to post
Share on other sites

I tried that with all the code posted, but for me it doesn't work at all. :)

I am on 64 bit Win7 at the moment and my Motherboard is an MSI K9N Neo-F V3, was released about 2 years ago I believe.


[font="Courier New"]http://RomanK.hondadesigns.com[/font]

Share this post


Link to post
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
Sign in to follow this  
Followers 0