Bitcoin Forum
June 20, 2024, 08:20:33 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
  Home Help Search Login Register More  
  Show Posts
Pages: [1]
1  Alternate cryptocurrencies / Mining (Altcoins) / Re: Antminer Z9 mini overclocked on: September 08, 2018, 04:42:03 AM
Since my batch 2 units came, and they seem to be quite a bit more finicky on overclocking, I've written a php script that keeps an eye on them and restarts them if they end up failing.

To configure, just change the miners IP's, user name, password, and threshold.

Requirements:
  • PHP webserver with sockets enabled and phpseclib library
  • Z9s need to be on your network or locally accessable

Other fun stuff included: There's a couple logging functions that will dump your hashrate stats into some CSV's.  I use them to make pretty charts.

Random notes... this restarts any machine with a 'failed' ASIC chain or one that has been powered on for more than 2 minutes and doesn't meet your threshold value, it will then restart it via SSH with the phpseclib library.  It pulls all stats with the default enabled CGMiner API, so you don't need to enable anything for that to work.  It actually pulls all the API info, so there's much more info available than what I'm using.  

And if you do it right, you'll end up with something like:


Code:
<?php
set_include_path
(get_include_path() . PATH_SEPARATOR 'phpseclib');
include(
'phpseclib/Net/SSH2.php');
header('refresh:600; url=index.php'); //change this to change the refresh in seconds (how often you want it to check on your machines)
date_default_timezone_set('America/Los_Angeles');
$machines = array
(
    
=> array(
'name' => 'Mini-1',
'ip' => '192.168.1.175',
'user' => 'root',
'password' => 'root',
'threshold' => 14,
),
=> array(
"name" => "Mini-2",
"ip" => "192.168.1.160",
'user' => 'root',
'password' => 'root',
"threshold" => 12,
),
=> array(
"name" => "Mini-3",
"ip" => "192.168.1.51",
'user' => 'root',
'password' => 'root',
"threshold" => 12,
),
=> array(
"name" => "Mini-4",
"ip" => "192.168.1.52",
'user' => 'root',
'password' => 'root',
"threshold" => 12,
)
);

foreach (
$machines as &$machine
{
createEmptyLogs($machine);
getstats($machine);
if(checkFails($machine)) restart($machine);
if(!file_exists"logs/overallhashrate.csv" )) file_put_contents("logs/overallhashrate.csv""time,total hashrate\r\n"FILE_APPEND);
}

printTotalHashrate($machines);
echo 
'<br />';

function 
createEmptyLogs($machine)
{
if(!file_exists'logs/'.$machine['name']."hashrate.csv" )) file_put_contents('logs/'.$machine['name']."hashrate.csv""time,".$machine['name']." hashrate\r\n"FILE_APPEND);
}

function 
logging($machine)
{
file_put_contents('logs/'.$machine['name']."hashrate.csv"date('j M H:i:s'time()).",".$machine['ghs5s']."\r\n"FILE_APPEND);
}

function 
restart($machine)
{
$ssh = new Net_SSH2($machine['ip']);
if (!$ssh->login($machine['user'], $machine['password'])) {
exit('Login Failed');
}

$ssh->exec('/etc/init.d/cgminer.sh restart >/dev/null 2>&1');
}

function 
checkFails(&$machine)
{
if (($machine['chain_acs1'] == 'xxxx' or $machine['chain_acs2'] == 'xxxx' or $machine['chain_acs3'] == 'xxxx' or intval($machine['ghs5s']) < intval($machine['threshold'])) and intval($machine['elapsed']) > 120)
return true//this restarts any machine with a 'failed' ASIC chain or one that has been powered on for more than 2 minutes and doesn't meet your threshold value
else return false;
}

function 
getstats(&$machine)
{
// create a socket
$socket socket_create(AF_INETSOCK_STREAMSOL_TCP);
$result socket_connect($socket$machine['ip'], 4028);
if ($socket === false || $result === false) {
echo $machine['name']. " appears to be offline!<br /><br />";
$machine['ghs5s'] = 0;
$machine['ghsav'] = 0;
$machine['chain_rate1'] = 0;
$machine['chain_rate2'] = 0;
$machine['chain_rate3'] = 0;
return;
}
else
{
// send a 'summary' command to antminer
$in '{"command":"stats"}';
$out '';
socket_write($socket$instrlen($in));

// read output from antminer
$output="";
while ($out socket_read($socket2048)) {
$output=$output.$out;
}
socket_close($socket);

$output strtolower($output);
$output str_replace(" """$output);
$output str_replace(","":"$output);
$output str_replace("\""""$output);
$output str_replace("}"""$output);
$output str_replace("]"""$output);
$output explode(":"substr($output,strpos($output,"elapsed"),strpos($output,"id:1")));

foreach($output as $i => $item//create the rest of the item entries
{
if ($i == 0)
$machine[$output[$i]] = $output[$i+1];
}
printmachinestats($machine); //Don't print stats or logs if they aren't online
logging($machine);
}

//print_r($machine);

/* old method of parsing string manually
$machine['totalhashrate']=substr($output,strpos($output,"GHS 5s")+9);

$machine['totalhashrate']=floatval(substr($machine['totalhashrate'],0, strpos($machine['totalhashrate'],"GHS av")));
$machine['uptime']=substr($output,strpos($output,"Elapsed")+9);
$machine['uptime']=floatval(substr($machine['uptime'],0, strpos($machine['uptime'],"GHS 5s")));
$machine['board1hash']=substr($output,strpos($output,"chain_rate1")+14);
$machine['board1hash']=floatval(substr($machine['board1hash'],0, strpos($machine['board1hash'],"chain_rate2")));
$machine['board2hash']=substr($output,strpos($output,"chain_rate2")+14);
$machine['board2hash']=floatval(substr($machine['board2hash'],0, strpos($machine['board2hash'],"chain_rate3")));
$machine['board3hash']=substr($output,strpos($output,"chain_rate3")+14);
$machine['board3hash']=floatval(substr($machine['board3hash'],0, strpos($machine['board3hash'],"}],")));
$machine['board1status']=substr($output,strpos($output,"chain_acs1")+13);
$machine['board1status']=substr($machine['board1status'],0, strpos($machine['board1status'],"chain_acs2")-3);
$machine['board2status']=substr($output,strpos($output,"chain_acs2")+13);
$machine['board2status']=substr($machine['board2status'],0, strpos($machine['board2status'],"chain_acs3")-3);
$machine['board3status']=substr($output,strpos($output,"chain_acs3")+13);
$machine['board3status']=substr($machine['board3status'],0, strpos($machine['board3status'],"chain_hw1")-3);
*/
}

function 
printmachinestats(&$machine)
{
print $machine['name'];
echo '<br />';
print "IP Address = ".$machine['ip'];
echo '<br />';
print "Hashrate = ".$machine['ghsav']. " KSol/S";
echo '<br />';
print "Uptime = ".secondsToTime($machine['elapsed']);
echo '<br />';
print "Board 1 Hash = ".$machine['chain_rate1']. " KSol/S";
echo '<br />';
print "Board 2 Hash = ".$machine['chain_rate2']. " KSol/S";
echo '<br />';
print "Board 3 Hash = ".$machine['chain_rate3']. " KSol/S";
echo '<br />';
print "Board 1 Status = ".$machine['chain_acs1'];
echo '<br />';
print "Board 2 Status = ".$machine['chain_acs2'];
echo '<br />';
print "Board 3 Status = ".$machine['chain_acs3'];
echo '<br />';

echo '<br />';
}

function 
printTotalHashrate($machines)
{
$total 0;
foreach ($machines as &$machine
{
$total += $machine['ghs5s'];
}
print "Total Hashrate = " . $total" KSol/S";
//['2004',  1000,      400]
file_put_contents("logs/overallhashrate.csv"date('j M H:i:s'time()).",".$total."\r\n"FILE_APPEND); //totals Hashrate

}

function 
secondsToTime($seconds
{
    
$dtF = new \DateTime('@0');
    
$dtT = new \DateTime("@$seconds");
    return 
$dtF->diff($dtT)->format('%a days, %h hours, %i minutes and %s seconds');
}
?>

I won't be providing any support for this, but I can answer any simple questions.

Donations:
LTC: MKKDJpk74UjUWXEPM2v7x7QfM2RFZxyQUa
ETH: 0xD3c330bdc5b5f964a45D20dBC3e71F6b15E442eb
2  Alternate cryptocurrencies / Mining (Altcoins) / Re: Bitmain launches the Z9 Equihash miner on: August 05, 2018, 06:25:13 PM
Has anyone done any research on reversing the airflow?  AND even putting the fan on the other end and pulling the air through?


https://bitcointalk.org/index.php?topic=4404847.msg43446447#msg43446447

Re: Z9 list of working pools/Fork updates
Today at 04:55:03 AM
Reply with quote  +Merit  #637
Quote from: greyday on Today at 03:42:17 AM
Quote from: acidrush on Today at 03:29:55 AM
Quote from: Sprucemoose78 on Today at 03:26:07 AM
Quote from: xxoanser on August 03, 2018, 09:06:20 AM




I only reversed the airflow


My temps at 750mhz:
Before: 67-71° at 80%
Now: 54-59 at 70%

Is it possible that your fan had been set the wrong way from the factory? Can you confirm which direction the air flows now after you switched? And how about sound, did it change in any way (especially the pitch)?

The fan used to suck air in, now its blowing out. Speed is about 1k rpm less.

To avoid confusion, it pushed air in, now it is pulling air out, correct?


correct

I actually just tried this out and now my fan is pulling air out (blowing out and not through the machine) and my PCB temps dropped 9-11 degrees per PCB and about 4-6 degrees per chip.  Fan on auto also it spinning about 1k RPM lower and doesn't do the constant up and down ramping when I had it the other way.  Seems strange they wouldn't try this configuration and ship it that way...
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!