Select Page

Required Files: SharedScriptRequiredFile 11


A small command line application that pulls temps of various hardware components using Open Hardware Monitor Lib, outputs info along with proper exit code, for use on RMM dashboards. Supports Windows based workstations and servers. This is directly from: https://github.com/MikeLierman/TempProber


 

Import-Module $env:SyncroModule
$warningTemp = 145
$alarmTemp = 155
 
 
$probeInstalled = Test-Path -Path "C:\temp\temp-probe"
If ($probeInstalled){ 
    Write-Host "Installed - running the probe"    
    Start-Process  -FilePath "C:\temp\temp-probe\TempProber.exe" -NoNewWindow -Wait -RedirectStandardOutput C:\temp\temp-probe\temperature.txt  -RedirectStandardError C:\temp\temp-probe\temperature_error.txt 
} ELSE { 
    Write-Host "Unzipping first.."
    Expand-Archive C:\temp\temp-probe.zip -DestinationPath C:\temp\temp-probe
    Write-Host "running the probe"
    Start-Process  -FilePath "C:\temp\temp-probe\TempProber.exe" -NoNewWindow -Wait -RedirectStandardOutput C:\temp\temp-probe\temperature.txt  -RedirectStandardError C:\temp\temp-probe\temperature_error.txt
}
 
$result = gc C:\temp\temp-probe\temperature.txt
$cpuLine = $result -match "CPU"
 
IF ($cpuLine) {
    $temperature = $cpuline | select-string -pattern '\d+' -allmatches  | % { $_.Matches } | % { $_.Value }
 
    IF ([int]$temperature -gt $alarmTemp){
        write-host "Host is HOT!"  
        Rmm-Alert -Category 'cpu_temp_alarm' -Body "CPU is over Alarm Temp with a value of $temperature. The Alarm temp is set to $alarmTemp"
    }
    ELSEIF ([int]$temperature -gt $warningTemp){
        write-host "Host is warming up..."    
    }
    ELSE {
        write-host "Just chilling at $temperature currently..."
    }
 
} ELSE {
    write-host "Could not find a CPU result from openhardwaremonitor"
}
 
#Clean up our temp file on the way out!
Remove-Item "C:\temp\temp-probe\temperature.txt"