Jump to content

Search the Community

Showing results for tags 'temperature'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 3 results

  1. Edit: I found out from looking into the post from coffeeturtle that not all motherboards support WMI temperature reading. You have to explore the WMI namespaces for your system! I (stupidly) fried a computer. It was an old Zotac small form factor device that was junked at work, so I turned it into a home theater PC. But I had put it in my "audio rack", which has glass doors and not very good ventilation. Normally I would open the doors while it was running and I use a media remote which would hibernate the system. At some point, it woke up by itself (probably Windows Update) and did not go to sleep again. Unfortunately this happened during the summer months while I was away on a small holiday and of course the glass doors were closed. When I finally noticed the system was on, it was super hot and the fan was at full blast. Dead. No POST, no green light on the mainboard even with a new power supply, old mechanical laptop hard drive gives errors when connected to another device. My next home project will be to make some appropriate ventilation in the audio cabinet. For the replacement I bought a used HP ultra small form factor machine and decided to start working on an app to monitor the ambient temperature sensor on the motherboard and shutdown the system if needed. I used some code for smooth label updates from here (needed updating to work with latest AutoIT) and temperature conversion from here (not really needed, only if you want temperatures in something other than C). Maybe I will work on this some more and make it configurable with an .INI file or even storing the settings in registry, but since I probably won't I thought I'd put it up as an example of what a non-expert can do with an afternoon of coding and ideas from the community here. This uses an ambient temperature sensor populated on HP machines in HP-specific WMI extensions but the WMI query can easily be changed to any available sensor including CPU or GPU. The watchdog monitors temperature, warns with S.O.S beeping if the set point is exceeded, and either shuts down if a timeout is reached while the temperatures are high or goes back to monitoring if the temperature goes lower then the set point, and logs events to the Windows application event logs. The GUI it puts up is very small at the top center of the screen (very small on a 4k display anyway). #requireadmin because of the WMI query. A timer for the WMI query because of prior experience using similar functions in WinPE to get model infos from HP WMI bios extensions. If you play around with this, please post your fixes/improvements/changes back to this thread. Have fun! Edit: Updated to show "Unable to query temperature" if the WMI query returns a null #AutoIt3Wrapper_Icon=temperature-2-multi-size.ico #RequireAdmin #NoTrayIcon #include <Temperature.au3> #include <FFLabels.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $winLogger = "C:\WINDOWS\system32\eventcreate.exe" ; application to use for event logging Global $MessageSource = "HP TempMon" Global $width = 185 Global $height = 15 Global $FontSize = 8 Global $FontFamily = 'Microsoft Sans Serif' Global $normClr = 0xFF000000 Global $warnClr = 0xFF0000 Global $WMInameSpace = "HP_BIOSNumericSensor" ;~ Global $WMIReadSensor = "Chassis Thermal Index" ; HP 8300 Global $WMIReadSensor = "System Ambient Temperature" ; HP Z400 Global $warnTmp = 46.1111111111 ; degrees C ;~ Global $warnTmp = 24 ; degrees C for testing Global $ovrtmpTime = 5 ; in minutes Global $hGUI = GUICreate("Board Temperature", $width, $height, -1, 0, BitOR($WS_SYSMENU, $WS_POPUP), BitOR($WS_EX_TOPMOST, $WS_EX_WINDOWEDGE, $WS_EX_TOOLWINDOW)) Global $lb1 = _GUICtrlFFLabel_Create($hGUI, "", -1, -1, $width, $height, 8, -1, 0, 1, $normClr) GUISetState(@SW_SHOW) _TempSenseLoop() Func _TempSenseLoop() While 1 Sleep(250) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete($hGUI) Return Case Else $s_ambTempC = _doQueryHPNumSens(5, $WMInameSpace, $WMIReadSensor, "100") ; + 100 Select Case $s_ambTempC = "" _GUICtrlFFLabel_SetTextColor($lb1, $normClr) _GUICtrlFFLabel_SetData($lb1, "Unable to query temperature") Case $s_ambTempC < $warnTmp _GUICtrlFFLabel_SetTextColor($lb1, $normClr) _GUICtrlFFLabel_SetData($lb1, "Board temperature: " & $s_ambTempC & "C" & "/" & Round(_CelsiusToFahrenheit($s_ambTempC), 0) & "F") Case Else _GUICtrlFFLabel_SetTextColor($lb1, $warnClr) _GUICtrlFFLabel_SetData($lb1, "Board temperature: " & $s_ambTempC & "C" & "/" & Round(_CelsiusToFahrenheit($s_ambTempC), 0) & "F") _doLog("System ambient temperature has exceeded " & $warnTmp & "C.", "WARN", $MessageSource) _AlarmMonitor($ovrtmpTime, $warnTmp) EndSelect EndSwitch WEnd EndFunc ;==>_TempSenseLoop Func _AlarmMonitor($min, $tmp) Local $Shutdown = 1 Local $s_ambTemp Local $freq = 3500 Local $shrt = 200 Local $long = 500 Local $timer = TimerInit() Local $wait = 1000 * ($min * 60) While TimerDiff($timer) < $wait $s_ambTemp = _doQueryHPNumSens(5, $WMInameSpace, $WMIReadSensor, "100") ; + 100 If $s_ambTemp >= $tmp Then _GUICtrlFFLabel_SetData($lb1, "WARNING! OVERTEMP!") Beep($freq, $shrt) Beep($freq, $shrt) Beep($freq, $shrt) Sleep(250) Beep($freq, $long) Beep($freq, $long) Beep($freq, $long) Sleep(250) Beep($freq, $shrt) Beep($freq, $shrt) Beep($freq, $shrt) _GUICtrlFFLabel_SetData($lb1, "Board temperature: " & $s_ambTemp & "C" & "/" & _CelsiusToFahrenheit($s_ambTemp) & "F") Sleep(2000) ElseIf $s_ambTemp < $tmp Then $Shutdown = 0 ExitLoop EndIf WEnd If $Shutdown = 1 Then _doLog("The system is shutting down due to overtemperature conditions. The temperature at the time of shutdown was " & $s_ambTemp & "C" & "/" & _CelsiusToFahrenheit($s_ambTemp) & "F", "ERRR", $MessageSource) Shutdown(24) ElseIf $Shutdown = 0 Then _doLog("System ambient temperature has been reduced below " & $warnTmp & "C.", "INFO", $MessageSource) EndIf EndFunc ;==>_AlarmMonitor Func _doQueryHPNumSens($min, $class, $name, $sleep) ; $sleep = milliseconds Local $s_tempReading = "" Local $s_HPBiosWMIService = "winmgmts:\\" & @ComputerName & "\Root\HP\InstrumentedBIOS" Local $objHPBiosWMIService = ObjGet($s_HPBiosWMIService) Local $s_biosQuery = $objHPBiosWMIService.ExecQuery("select * from " & $class & " where Name='" & $name & "'") $timer = TimerInit() ; we may need to wait for the HP WMI extensions to enumerate in WMI, in WinPE this takes some minutes. $wait = 1000 * ($min * 60) If Not IsObj($s_biosQuery) Then ; we do need to wait, put up a splash screen $s_WMISplash = 1 SplashTextOn("WMI", "Probing WMI (up to 10 minutes)...", 300, 50, -1, -1, 1) Sleep(1000) While TimerDiff($timer) < $wait Sleep(500) $objHPBiosWMIService = ObjGet($s_HPBiosWMIService) If IsObj($objHPBiosWMIService) Then Sleep(500) $colProdName = $s_biosQuery If IsObj($colProdName) Then For $oItem In $colProdName $s_tempReading = $oItem.CurrentReading Next EndIf EndIf WEnd ElseIf IsObj($s_biosQuery) Then ConsoleWrite($s_biosQuery & @CRLF) For $oItem In $s_biosQuery $s_tempReading = $oItem.CurrentReading Next Else $s_tempReading = 0 EndIf Sleep($sleep) Return $s_tempReading EndFunc ;==>_doQueryHPNumSens Func _doLog($message, $type, $msgsrc) Select Case $type = "INFO" $logTyp = "INFORMATION" Case $type = "WARN" $logTyp = "WARNING" Case $type = "ERRR" $logTyp = "ERROR" EndSelect If FileExists($winLogger) Then RunWait(@ComSpec & " /c " & $winLogger & " /L Application /T " & $logTyp & " /SO " & Chr(34) & $msgsrc & Chr(34) & " /ID 1000 /D " & Chr(34) & $message & Chr(34), "", @SW_HIDE) EndIf EndFunc ;==>_doLog Temperature.au3 FFLabels.au3 HP_Temp.au3
  2. I couldn't resist making a S.M.A.R.T. script using WMIC. It gave me something to do over the holidays. 1) This will only give SMART data for the main drive. (ie: C:\) 2) It will most likely Not give data on Raided or USB drives. 3) It only shows pertinent data columns and ignores all others. 4) It should be good enough for a quick glance and an example how to parse WMIC output. Download: _MiniSmart v0.2.au3
  3. ;RemoteDriveInfo ;v0.0.0.1 ;Ressource ;Smart Temp : https://www.autoitscript.com/forum/topic/91067-drive-temperature/?do=findComment&comment=1091961 ;GetPNPDeviceID From DriveLetter : https://www.autoitscript.com/forum/topic/57202-need-help-get-pnp-device-id-for-usb-drive/?do=findComment&comment=433346 ;Get Disk Space Info : https://www.autoitscript.com/forum/topic/148390-wmi-query-how-to-get-data-from-object/?do=findComment&comment=1055088 ;For A to Z : https://www.autoitscript.com/forum/topic/4804-fornext-loop-with-letters/?do=findComment&comment=30417 ;Include #include <Array.au3> #include <String.au3> ;Sample 1 ;$sComputerName $sComputerName = "PC1" ;$sComputerName = "PC2" ;$sComputerName = @ComputerName ;$sDrive ;$sDrive = "system" ;$sDrive = "D:" $sDrive = "" $DriveInfo = _GetDriveInfo($sComputerName, $sDrive) _ArrayDisplay($DriveInfo) ;Sample 2 $DriveInfo = _GetDriveInfo($sComputerName, "system") If $DriveInfo[0][0] = "DriveLeter" Then If $DriveInfo[1][6] <> "" Then MsgBox(0, "", $DriveInfo[1][6] & "° - " & $DriveInfo[1][4] & "% ( " & Round($DriveInfo[1][2]/1024^3) & "Go / " & Round($DriveInfo[1][3]/1024^3) & "Go )" & @CRLF) Else MsgBox(0, "", $DriveInfo[1][4] & "% ( " & Round($DriveInfo[1][2]/1024^3) & "Go / " & Round($DriveInfo[1][3]/1024^3) & "Go )" & @CRLF) EndIf Else MsgBox(0, "", $DriveInfo[0][0] & @CRLF) EndIf ;Function Func _GetSystemDriveLtr($sComputerName) $objWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $sComputerName & "\root\cimv2") $colTemp = $objWMI.ExecQuery("SELECT SystemDrive FROM Win32_OperatingSystem") If IsObj($colTemp) then For $objItem In $colTemp $sSystemDriveLtr = $objItem.systemdrive Next EndIf Return $sSystemDriveLtr EndFunc ;==> _GetSystemDriveLtr Func _GetPNPDeviceID($drive_letter, $sComputerName) Local $drive_letter_found, $drive_letter_found $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $objWMIService = ObjGet("winmgmts:\\" & $sComputerName & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_LogicalDiskToPartition", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems $LogicalDiskToPartitionAntecedent = _StringBetween($objItem.Antecedent, '"', '"') $LogicalDiskToPartitionDependent = _StringBetween($objItem.Dependent, '"', '"') ;ConsoleWrite(@CR & $LogicalDiskToPartitionAntecedent[0] & " - " & $LogicalDiskToPartitionDependent[0]) $drive_statistics = $LogicalDiskToPartitionAntecedent[0] $drive_letter_found = $LogicalDiskToPartitionDependent[0] If $drive_letter = $drive_letter_found Then ExitLoop EndIf Next Else MsgBox(0, "WMI Output", "No WMI Objects Found for class: " & "Win32_LogicalDiskToPartition") EndIf If $drive_letter <> $drive_letter_found Then Return 0 ; If drive letter isn't function returns 0 $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_DiskDriveToDiskPartition", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems $DiskDriveToDiskPartitionAntecedent = _StringBetween($objItem.Antecedent, '"', '"') $DiskDriveToDiskPartitionDependent = _StringBetween($objItem.Dependent, '"', '"') ;ConsoleWrite(@CR & $DiskDriveToDiskPartitionAntecedent[0] & " - " & $DiskDriveToDiskPartitionDependent[0]) $drive_statistics_found = $DiskDriveToDiskPartitionDependent[0] $drive_physical = StringTrimLeft($DiskDriveToDiskPartitionAntecedent[0], StringInStr($DiskDriveToDiskPartitionAntecedent[0], "\", 1, -1)) ;MsgBox(0,"TEST", $drive_physical) If $drive_statistics = $drive_statistics_found Then ExitLoop EndIf Next Else MsgBox(0, "WMI Output", "No WMI Objects Found for class: " & "Win32_DiskDriveToDiskPartition") EndIf $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems ;MsgBox(0,324234, $objItem.DeviceID) $DeviceID = StringTrimLeft($objItem.DeviceID, StringInStr($objItem.DeviceID, "\", 1, -1)) $PNPDeviceID = $objItem.PNPDeviceID ;MsgBox(0,122, $DeviceID) If $drive_physical = $DeviceID Then Return $PNPDeviceID EndIf Next Else MsgBox(0, "WMI Output", "No WMI Objects Found for class: " & "Win32_DiskDrive") EndIf EndFunc ;==> _GetPNPDeviceID Func _GetSmartTemp($InstanceName, $sComputerName) $objWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $sComputerName & "\root\WMI") $colTemp = $objWMI.ExecQuery("SELECT * FROM MSStorageDriver_ATAPISmartData") $s = "" If IsObj($colTemp) and $InstanceName <> "" then For $objItem In $colTemp If StringInStr(StringUpper($objItem.InstanceName), StringUpper($InstanceName)) <> 0 Then $strVendorSpecific = $objItem.VendorSpecific For $i = 2 To UBound($strVendorSpecific) - 1 Step 12 If $strVendorSpecific[$i] = 0xC2 Then; find Vendor Parameter #194 - Temperatur $s &= " " & $strVendorSpecific[$i + 5]; Raw/Value celsuis ContinueLoop 2 EndIf Next For $i = 2 To UBound($strVendorSpecific) - 1 Step 12 If $strVendorSpecific[$i] = 0xBE Then; find Vendor Parameter #190 - Airflow Temperatur (if no tempetature is found) $s &= " " & $strVendorSpecific[$i + 5]; Raw/Value celsuis ContinueLoop 2 EndIf Next EndIf Next $s = StringTrimLeft($s, 1) Else $s = "" EndIf Return $s EndFunc ;==> _GetSmartTemp ;MainFunction Func _GetDriveInfo($sComputerName, $sDrive = "") Local $DriveArray[1][7] = [["DriveLeter", "FreespaceByte", "UsedspaceByte", "SizeByte", "UsedPercent", "IsSystem", "Temp"]] If Ping($sComputerName) = 0 Then Local $DriveArray[1][1] $DriveArray[0][0] = $sComputerName & " seems not online" Return $DriveArray EndIf If $sDrive = "" Then For $i = 65 To 90;For A to Z $sDriveLtr = Chr($i)&":" $DriveArray = _GetOneDriveInfo($sComputerName, $sDriveLtr, $DriveArray) Next ElseIf $sDrive = "system" Then $DriveArray = _GetOneDriveInfo($sComputerName, _GetSystemDriveLtr($sComputerName), $DriveArray) Else $DriveArray = _GetOneDriveInfo($sComputerName, $sDrive, $DriveArray) EndIf Return $DriveArray EndFunc ;==> _GetDriveInfo Func _GetOneDriveInfo($sComputerName, $sDriveLtr, $DriveArray) $objWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $sComputerName & '\root\cimv2:Win32_LogicalDisk="' & $sDriveLtr & '"') If IsObj($objWMI) Then $UsedPercent = Round(100 / $objWMI.Size * ($objWMI.Size - $objWMI.FreeSpace)) If $UsedPercent <> -9223372036854775807 then $current_line = Ubound($DriveArray)+1 ReDim $DriveArray[$current_line][7] $DriveArray[$current_line-1][0] = $sDriveLtr $FreespaceByte = $objWMI.FreeSpace $DriveArray[$current_line-1][1] = $FreespaceByte $SizeByte = $objWMI.Size $DriveArray[$current_line-1][3] = $SizeByte $UsedspaceByte = $objWMI.Size - $objWMI.FreeSpace $DriveArray[$current_line-1][2] = $UsedspaceByte $UsedPercent = Round(100 / $objWMI.Size * ($objWMI.Size - $objWMI.FreeSpace)) $DriveArray[$current_line-1][4] = $UsedPercent If _GetSystemDriveLtr($sComputerName) = $sDriveLtr Then $IsSystem = 1 Else $IsSystem = 0 EndIf $DriveArray[$current_line-1][5] = $IsSystem $InstanceName = _GetPNPDeviceID($sDriveLtr, $sComputerName) $Temp = _GetSmartTemp($InstanceName, $sComputerName) $DriveArray[$current_line-1][6] = $Temp EndIf EndIf Return $DriveArray EndFunc Ressource Smart Temp : GetPNPDeviceID From DriveLetter : Get Disk Space Info : For A to Z :
×
×
  • Create New...