Skip to content

Commit

Permalink
watchdog automatic disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
tutulino committed Mar 7, 2018
1 parent 6c3778a commit f85fc87
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 24 deletions.
31 changes: 30 additions & 1 deletion Include.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ function get_gpu_information ($Types) {
$counter++
}


$cards
}

Expand Down Expand Up @@ -481,6 +482,7 @@ Function Get_Mining_Types () {
Type = "NVIDIA"
Gpus = (get_comma_separated_string 0 $NumberNvidiaGPU)
Powerlimits="0"

}
}

Expand All @@ -490,6 +492,7 @@ Function Get_Mining_Types () {
Type = "AMD"
Gpus = (get_comma_separated_string 0 $NumberAmdGPU)
Powerlimits="0"

}
}

Expand All @@ -514,6 +517,7 @@ Function Get_Mining_Types () {
$_ | Add-Member GpusNsgMode ("-d "+$_.gpus -replace ',',' -d ')
$_ | Add-Member GpuPlatform (Get_Gpu_Platform $_.Type)
$_ | Add-Member GpusArray ($_.gpus -split ",")
$_ | Add-Member GpuCount ($_.gpus -split ",").count
$Pl=@()
($_.PowerLimits -split ',') |foreach-object {$Pl+=[int]$_}
$_.PowerLimits = $Pl |Sort-Object -Descending
Expand Down Expand Up @@ -1594,4 +1598,29 @@ function clear_files{
#************************************************************************************************************************************************************************************
#************************************************************************************************************************************************************************************


function Check_GpuGroups_Config ($types) {


$cards=get_gpu_information $Types


$types | ForEach-Object {

$detectedcards=@()
$detectedcards+=$Cards | Where-Object gpugroup -eq $_.GroupName

if ($detectedcards.count -eq 0) {
writelog ("No gpus for group "+$type.GroupName+" was detected, activity based watchdog will be disabled for that group, this can happens if AMD beta blockchain drivers are installed or incorrect @@gpugroups config") $logfile $false
write-warning ("No gpus for group "+$type.GroupName+" was detected, activity based watchdog will be disabled for that group, this can happens if AMD beta blockchain drivers are installed or incorrect @@gpugroups config")
start-sleep 10
}
elseif ($detectedcards.count -ne $_.gpucount) {
writelog ("Mismatching gpus for group "+$type.GroupName+" was detected, check @@gpugroups config and gpulist.bat") $logfile $false
write-warning ("Mismatching gpus for group "+$type.GroupName+" was detected, check @@gpugroups config and gpulist.bat")
start-sleep 10
}

}


}
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,7 @@ This release changes next config variables: @@ALGORITHMS_NVIDIA,@@ALGORITHMS_AMD
*Rest Api available
*Farm monitoring (fill config.txt fields and run start.bat)
*Added menu option to quit (close all windows)
*Activity based watchdog disabled if no gpu detected (https://github.com/tutulino/Megaminer/issues/351)


---POOLS CHANGES:
Expand Down
62 changes: 39 additions & 23 deletions core.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,6 @@ Get-ChildItem . -Recurse | Unblock-File
writelog ("Release $Release") $logfile $false


#get mining types
$Types=Get_Mining_Types -filter $Groupnames

writelog ( get_gpu_information $Types |ConvertTo-Json) $logfile $false
Writelog ( $Types |ConvertTo-Json) $logfile $false


$ActiveMiners = @()
$Activeminers=@()
$ShowBestMinersOnly=$true
Expand Down Expand Up @@ -180,6 +173,21 @@ $Msg+=" //PercentToSwitch: "+$PercentToSwitch

WriteLog $msg $LogFile $False



#get mining types
$Types=Get_Mining_Types -filter $Groupnames

writelog ( get_gpu_information $Types |ConvertTo-Json) $logfile $false
Writelog ( $Types |ConvertTo-Json) $logfile $false


$NumberTypesGroups=($Types | Measure-Object).count
if ($NumberTypesGroups -gt 0) {$InitialProfitsScreenLimit=[Math]::Floor( 25 /$NumberTypesGroups)} #screen adjust to number of groups
$ProfitsScreenLimit=$InitialProfitsScreenLimit

Check_GpuGroups_Config $types


#Enable api

Expand All @@ -206,6 +214,9 @@ if ($config.ApiPort -gt 0) {

$Quit=$false




#----------------------------------------------------------------------------------------------------------------------------
#----------------------------------------------------------------------------------------------------------------------------
#----------------------------------------------------------------------------------------------------------------------------
Expand All @@ -230,11 +241,7 @@ while ($Quit -eq $false) {
if ($PercentToSwitch -eq "") {$PercentToSwitch2 = [int]($config.PERCENTTOSWITCH)} else {$PercentToSwitch2=[int]$PercentToSwitch}
$DelayCloseMiners=$config.DELAYCLOSEMINERS

$Types=Get_Mining_Types -filter $Groupnames

$NumberTypesGroups=($Types | Measure-Object).count
if ($NumberTypesGroups -gt 0) {$InitialProfitsScreenLimit=[Math]::Floor( 25 /$NumberTypesGroups)} #screen adjust to number of groups
if ($FirstTotalExecution) {$ProfitsScreenLimit=$InitialProfitsScreenLimit}



#$Currency= $config.CURRENCY
Expand Down Expand Up @@ -1031,19 +1038,26 @@ while ($Quit -eq $false) {
}

#WATCHDOG
$groupcards=@()
$groupcards+=$Cards | Where-Object gpugroup -eq $ActiveMiners[$_.IdF].GpuGroup.GroupName

$GpuActivityAverages += [pscustomobject]@{Average= ($Cards | Where-Object gpugroup -eq ($ActiveMiners[$_.IdF].GpuGroup.GroupName) | Measure-Object -property utilization_gpu -average).average}
$GpuActivityAverages += [pscustomobject]@{
gpugroup = $ActiveMiners[$_.IdF].GpuGroup.GroupName
Average = ($groupcards | Measure-Object -property utilization_gpu -average).average
NumberOfGpus = $groupcards.count
}

if ($GpuActivityAverages.count -gt 20) {
$GpuActivityAverages = $GpuActivityAverages[($GpuActivityAverages.count-20)..($GpuActivityAverages.count-1)]
$GpuActivityAverage = ($GpuActivityAverages | Measure-Object -property average -maximum).maximum
$GpuActivityAverage = ($GpuActivityAverages | Where-Object gpugroup -eq $ActiveMiners[$_.IdF].GpuGroup.GroupName | Measure-Object -property average -maximum).maximum
$GpuActivityGpuCount = ($GpuActivityAverages | Where-Object gpugroup -eq $ActiveMiners[$_.IdF].GpuGroup.GroupName | Measure-Object -property NumberOfGpus -maximum).maximum
if ($DetailedLog) {writelog ("Last 20 reads maximum GPU activity is "+[string]$GpuActivityAverage+" for Gpugroup "+$ActiveMiners[$_.IdF].GpuGroup.GroupName) $logfile $false}
}
else
{$GpuActivityAverage = 100} #only want watchdog works with at least 5 reads
{$GpuActivityAverage = 100} #only want watchdog works with at least 20 reads


if ($ActiveMiners[$_.IdF].Process -eq $null -or $ActiveMiners[$_.IdF].Process.HasExited -or ($GpuActivityAverage -le 40 -and $TimeSinceStartInterval -gt 100) ) {
if ($ActiveMiners[$_.IdF].Process -eq $null -or $ActiveMiners[$_.IdF].Process.HasExited -or ($GpuActivityAverage -le 40 -and $TimeSinceStartInterval -gt 100 -and $GpuActivityGpuCount -gt 0) ) {
$ExitLoop = $true
$_.Status = "PendingCancellation"
$_.Stats.FailedTimes++
Expand All @@ -1052,6 +1066,9 @@ while ($Quit -eq $false) {
writelog ([string]$ActiveMiners[$_.IdF].Process+','+[string]$ActiveMiners[$_.IdF].Process.HasExited+','+$GpuActivityAverage+','+$TimeSinceStartInterval) $logfile $false
}




} #End For each


Expand Down Expand Up @@ -1539,12 +1556,11 @@ while ($Quit -eq $false) {



Writelog "Program end" $logfile
Writelog "Exiting MM...." $logfile $true
$LogFile.close()
clear_files
$ActiveMiners | ForEach-Object { Kill_Process $_.Process}

$ActiveMiners | ForEach-Object {stop-process -Id $_.Process.Id}
try{Invoke-WebRequest ("http://localhost:"+[string]$config.ApiPort+"?command=exit") -timeoutsec 1 -UseDefaultCredentials} catch {}

$LogFile.close()
stop-process -Id $PID



0 comments on commit f85fc87

Please sign in to comment.