Advertisement
Guest User

Untitled

a guest
Dec 24th, 2017
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.05 KB | None | 0 0
  1. Write-Host " "
  2. Write-Host " "
  3. write-host -foregroundcolor "magenta" "*****GPU Miner WatchDog*****"
  4. Write-Host " "
  5. Write-Host " "
  6.  
  7.  
  8. $Log = "LogFile.log"
  9. $Date = Get-Date
  10. $script:startTime = Get-Date
  11. $failtestcount = 0
  12. $minerrestartno = 0
  13.  
  14.  
  15. #set gpu min max threshold for restarting miner
  16. $temptrig = 37
  17. $tempmaxallow = 85
  18.  
  19. #enter total number of gpus currently connected to rig
  20. $totoalgpuno = 7
  21.  
  22. #Miner Software name in task manager. Can be any process you want
  23. $minername = "ccminer_cuda9*"
  24.  
  25.  
  26. #Enter miner path in start up folder
  27. $Minerpath = "C:\Users\****YourUser****\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\ZcoinMPH.lnk"
  28.  
  29. #Email information for notifications
  30. $credentials = new-object Management.Automation.PSCredential “****YourEmail****@gmail.com”, (“****YourPassword****” | ConvertTo-SecureString -AsPlainText -Force)
  31. $From = "****YourEmail****@gmail.com"
  32. $To = "****TheirEmail****@gmail.com"
  33. $Attachment = "C:\MinerMonitor_v2\LogFile.log"
  34. $Subject = "Miner Rebooted"
  35. $Body = "Your mining software was restarted 3 times and triggered the box to reboot"
  36. $SMTPServer = "smtp.gmail.com"
  37. $SMTPPort = "587"
  38.  
  39. #set time after which script will start
  40. Start-Sleep 15
  41.  
  42.  
  43.  
  44. function GetElapsedTime([datetime]$starttime)
  45. {
  46. $runtime = $(get-date) - $starttime
  47. $retStr = [string]::format("{0} sec(s)-", $runtime.TotalSeconds)
  48. $retStr
  49. }
  50.  
  51.  
  52. #Check if openhardwaremonitor is running or not
  53. $ProcessName = "openhardwaremonitor"
  54.  
  55. if((get-process $ProcessName -ErrorAction SilentlyContinue) -eq $Null)
  56. { Start-Process -FilePath ".\OpenHardwareMonitor\OpenHardwareMonitor.exe" -WindowStyle Minimized
  57. echo "--Starting Hardware Monitor--" }
  58. else
  59. { echo "--Hardware Monitor Running--" }
  60.  
  61. #to check for ccminer process running or not
  62. $ProcessName = "ccminer_cuda9"
  63.  
  64. if((Get-Process $ProcessName -ErrorAction SilentlyContinue) -eq $Null)
  65. { Start-Process -FilePath $Minerpath
  66. echo " "
  67. Write-Host -foregroundcolor "red" "****CCMiner Not Running****"
  68. echo " "
  69. Write-Host -ForegroundColor "DarkRed" "-----Starting CCMiner------"
  70. echo " " }
  71. else
  72. { echo "------CCminer Running-------" }
  73.  
  74. #Check GPU load
  75. while($true)
  76. {
  77.  
  78. $gputemp = Get-WmiObject -namespace root\openhardwaremonitor -class sensor | Where-Object {$_.SensorType -Match "temp" -and $_.Identifier -like "*gpu*"}
  79.  
  80.  
  81. ForEach($GPU In $gputemp)
  82. {if($GPU.value -lt $temptrig )
  83. {$mytest = $GPU.value
  84. Write-Host -foregroundcolor "red" $mytest"°C -- GPU Temp Low, May Not Be Mining --"
  85. "$Date - Low result obtained $mytest°C" >> $Log
  86. $failtestcount = $failtestcount + 1
  87. }
  88. else
  89. {$mytest = $GPU.value
  90. Write-Host "-- "$mytest"°C -- GPU Is Mining --"
  91. }
  92. }
  93.  
  94.  
  95. $elapsed = GetElapsedTime $script:startTime
  96. write-host "-Up Time: " $elapsed;
  97.  
  98.  
  99.  
  100.  
  101. #trigger restart
  102. if($failtestcount -ge 1 )
  103. {
  104. "$Date Miner Restart" >> $Log
  105. Write-Output " ****Restarting Miner****"
  106. Stop-Process -name $minername -force
  107. Start-Process -FilePath $Minerpath
  108. $minerrestartno = $minerrestartno + 1
  109. $failtestcount = 0
  110. $script:startTime = Get-Date
  111.  
  112.  
  113. if($minerrestartno -ge 3)
  114. {
  115. Write-Host -ForegroundColor "red" "****Updating Log File and Sending Notification Email****"
  116. Send-MailMessage -From $From -To $To -Subject $Subject -Body $Body -SmtpServer $SMTPServer -Port $SMTPPort -UseSsl -Credential $credentials -Attachments $Attachment
  117. Stop-Process -name $minername -force
  118. Start-Sleep 30
  119. "$Date Computer Restart" >> $Log
  120. Restart-Computer -force
  121. }
  122.  
  123. }
  124. else
  125. {
  126. Write-Host " "
  127. Write-Host -foregroundcolor "green" "!!!!Making Money Bitches!!!!"
  128. }
  129.  
  130.  
  131.  
  132.  
  133.  
  134. if($GPU.value -gt $tempmaxallow)
  135. {
  136. Stop-Process -name $minername -force
  137. Start-Sleep 300
  138. Start-Process -FilePath $Minerpath
  139. $minerrestartno = $minerrestartno + 1
  140. $failtestcount = 0
  141. $script:startTime = Get-Date
  142. "$Date GPU Running Too Hot" >> $Log
  143. }
  144.  
  145.  
  146.  
  147. Write-Host " "
  148. Write-Host " "
  149. Write-Host " "
  150. Write-Host "------Rechecking GPUs------"
  151. Write-Host " "
  152. Write-Host " "
  153. Write-Host " "
  154. Start-Sleep 30
  155. }
  156.  
  157. ####################################################################
  158. # _______ _________ _______ ______ _________ _______ #
  159. # ( ____ \\__ __/( ____ )/ ___ \\__ __/( ____ \|\ /| #
  160. # | ( \/ ) ( | ( )|\/ \ \ ) ( | ( \/| ) ( | #
  161. # | (_____ | | | (____)| ___) / | | | | | (___) | #
  162. # (_____ ) | | | __) (___ ( | | | | | ___ | #
  163. # ) | | | | (\ ( ) \ | | | | | ( ) | #
  164. # /\____) | | | | ) \ \__/\___/ / | | | (____/\| ) ( | #
  165. # \_______) )_( |/ \__/\______/ )_( (_______/|/ \| #
  166. # #
  167. ####################################################################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement