Bitcoin Forum
May 11, 2024, 10:13:18 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
  Home Help Search Login Register More  
  Show Posts
Pages: [1]
1  Bitcoin / Mining software (miners) / Cgminer Sentinel scrypt for windows on: February 08, 2014, 09:44:46 AM
Hi everyone.

Been fighting the dreaded cgminer crashes for weeks.
Sometimes it runs for a few days, sometimes just a couple of hours but eventually one or more cgminer instance craps out.

I've given up. I'm tired of trying configs, drivers and voodoo spells, so I've written a simple powershell scrypt to look after my miners. It checks if all my cgminer threads are alive and running. If one or more threads are killed or not responding, it sends a restart signal and the computer reboots. Obviously the miners need to be launched from the Startup menu in windows.

Code:
Set-ExecutionPolicy RemoteSigned

$numThreads =  @(Get-Process -Name cgminer*).length
echo "numThreads = $numThreads"

while($true) {
$cpu1 = @(Get-Process -Name cgminer* | ForEach-Object {$_.cpu})

if ( $numThreads -ne $cpu1.length ) {
echo "Some thread died, restarting........."
taskkill /im "cgminer.exe" /f
shutdown /r
}

echo "c u in a minute..."
sleep 60
echo ""

$cpu2 = @(Get-Process -Name cgminer* | ForEach-Object {$_.cpu})

if ( $numThreads -ne $cpu2.length ) {
echo "Some thread died, restarting........"
taskkill /im "cgminer.exe" /f
shutdown /r
}

for ($i=0; $i -lt $cpu1.length; $i++) {
$outS = "Checking thread #" + $i + " activity. Before: " + $cpu1[$i] + " --- After: " + $cpu2[$i]

if ( $cpu1[$i] -eq $cpu2[$i]) {
echo $outS
echo $("Thread #" + $i + " not running, restarting.............")
taskkill /im "cgminer.exe" /f
shutdown /r

} else {
$outS + "... RUNNING OK" | echo
}
}
}

Just save that code in a file with a ps1 extension, something like sentinel.ps1 for example.

Then launch your miners from a batch, using start so that they run on their own threads, then in the same batch, run the sentinel scrypt in it's own thread too.
Use sleeps to ensure Windows has time to load completely and all cgminer instances are running before the sentinel starts running.

Code:
sleep 30
del *.bin
start "HD7970" cmd /c "cgminer-startup-7970.bat"
sleep 15
start "HD7950" cmd /c "cgminer-startup-7950.bat"
sleep 15
start "Sentinel" cmd /c "powershell .\Sentinel.ps1"
2  Local / Hardware y Minería / Script centinela para vigilar tus mineros en Windows on: February 08, 2014, 08:05:10 AM
Buenas gente.

LLevo semanas peleándome con el cgminer que no para de dar por donde la espalda pierde su casto nombre.
A veces un par de días, otras veces un par de horas pero siempre acaba por pararse alguna instancia con el maldito "cgminer has stopped working" o algo así.

Me he dado por vencido al final y he optado por crear un sencillo script en powershell para velar por mis mineros. La idea es comprobar cada 60 segundos si los hilos de cgminer están todos vivos y corriendo. Si no es así, el ordenador se reinicia sólo. Obviamente hay que arrancar el/los cgminer(s) desde el menú Inicio para que tras reiniciar se pongan a funcionar de nuevo automáticamente.

Se podría hacer también para Linux, pero yo ahora mismo estoy minando sobre W7 así que he usado powershell

Code:
Set-ExecutionPolicy RemoteSigned

$numThreads =  @(Get-Process -Name cgminer*).length
echo "numThreads = $numThreads"

while($true) {
$cpu1 = @(Get-Process -Name cgminer* | ForEach-Object {$_.cpu})

if ( $numThreads -ne $cpu1.length ) {
echo "Some thread died, restarting........."
taskkill /im "cgminer.exe" /f
shutdown /r
}

echo "c u in a minute..."
sleep 60
echo ""

$cpu2 = @(Get-Process -Name cgminer* | ForEach-Object {$_.cpu})

if ( $numThreads -ne $cpu2.length ) {
echo "Some thread died, restarting........"
taskkill /im "cgminer.exe" /f
shutdown /r
}

for ($i=0; $i -lt $cpu1.length; $i++) {
$outS = "Checking thread #" + $i + " activity. Before: " + $cpu1[$i] + " --- After: " + $cpu2[$i]

if ( $cpu1[$i] -eq $cpu2[$i]) {
echo $outS
echo $("Thread #" + $i + " not running, restarting.............")
taskkill /im "cgminer.exe" /f
shutdown /r

} else {
$outS + "... RUNNING OK" | echo
}
}
}

La idea es guardar ese código en un archivo con extensión ps1, algo como centinela.ps1 por ejemplo.

Luego arrancar los mineros desde un batch, pero cada uno en su propio hilo usando start y desde el mismo batch, una vez arrancados los mineros, arrancar el centinela también en su propio hilo.
Un par de sleeps aquí y allá para dar tiempo al ordenador a reinciar y a los cgminers a arrancar y listos.

Code:
sleep 30
del *.bin
start "HD7970" cmd /c "cgminer-startup-7970.bat"
sleep 15
start "HD7950" cmd /c "cgminer-startup-7950.bat"
sleep 15
start "Sentinel" cmd /c "powershell .\Sentinel.ps1"
Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!