Browse Source

Merge pull request #211 from kanoi/minerphp

miner.php highlight devs too slow finding shares (possibly failing)
nfactor-troky
Con Kolivas 13 years ago
parent
commit
dfd3517388
  1. 129
      miner.php

129
miner.php

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
session_start();
#
global $miner, $port, $readonly, $notify, $rigs, $socktimeoutsec;
global $checklastshare;
#
# Don't touch these 2 - see $rigs below
$miner = null;
@ -17,6 +18,13 @@ $readonly = false; @@ -17,6 +18,13 @@ $readonly = false;
# coz it doesn't have notify - it just shows the error status table
$notify = true;
#
# set $checklastshare to true to do the following checks:
# If a device's last share is 12x expected ago then display as an error
# If a device's last share is 8x expected ago then display as a warning
# If either of the above is true, also display the whole line highlighted
# This assumes shares are 1 difficulty shares
$checklastshare = true;
#
# Set $rigs to an array of your cgminer rigs that are running
# format: 'IP:Port' or 'Host:Port'
# If you only have one rig, it will just show the detail of that rig
@ -70,6 +78,7 @@ td.err { color:black; font-family:verdana,arial,sans; font-size:13pt; background @@ -70,6 +78,7 @@ td.err { color:black; font-family:verdana,arial,sans; font-size:13pt; background
td.warn { color:black; font-family:verdana,arial,sans; font-size:13pt; background:#ffb050 }
td.sta { color:green; font-family:verdana,arial,sans; font-size:13pt; }
td.tot { color:blue; font-family:verdana,arial,sans; font-size:13pt; background:#fff8f2 }
td.lst { color:blue; font-family:verdana,arial,sans; font-size:13pt; background:#ffffdd }
</style>
</head><body bgcolor=#ecffff>
<script type='text/javascript'>
@ -222,22 +231,83 @@ function getparam($name, $both = false) @@ -222,22 +231,83 @@ function getparam($name, $both = false)
return substr($a, 0, 1024);
}
#
function fmt($section, $name, $value)
function classlastshare($when, $alldata, $warnclass, $errorclass)
{
global $checklastshare;
if ($checklastshare === false)
return '';
if ($when == 0)
return '';
if (!isset($alldata['MHS av']))
return '';
if (!isset($alldata['Last Share Time']))
return '';
$expected = pow(2, 32) / ($alldata['MHS av'] * pow(10, 6));
$howlong = $when - $alldata['Last Share Time'];
if ($howlong < 1)
$howlong = 1;
if ($howlong > ($expected * 12))
return $errorclass;
if ($howlong > ($expected * 8))
return $warnclass;
return '';
}
#
function fmt($section, $name, $value, $when, $alldata)
{
global $dfmt;
if ($alldata == null)
$alldata = array();
$errorclass = ' class=err';
$warnclass = ' class=warn';
$lstclass = ' class=lst';
$b = '&nbsp;';
$ret = $value;
$class = '';
if ($value === null)
$ret = $b;
else
switch ($section.'.'.$name)
{
case 'GPU.Last Share Time':
case 'PGA.Last Share Time':
if ($value == 0
|| (isset($alldata['Last Share Pool']) && $alldata['Last Share Pool'] == -1))
{
$ret = 'Never';
$class = $warnclass;
}
else
{
$ret = date('H:i:s', $value);
$class = classlastshare($when, $alldata, $warnclass, $errorclass);
}
break;
case 'POOL.Last Share Time':
if ($value == 0)
$ret = 'Never';
else
$ret = date('H:i:s d-M', $value);
break;
case 'GPU.Last Share Pool':
case 'PGA.Last Share Pool':
if ($value == -1)
{
$ret = 'None';
$class = $warnclass;
}
break;
case 'SUMMARY.Elapsed':
$s = $value % 60;
@ -297,14 +367,14 @@ function fmt($section, $name, $value) @@ -297,14 +367,14 @@ function fmt($section, $name, $value)
case 'PGA.Utility':
case 'SUMMARY.Utility':
$ret = $value.'/m';
if ($value == 0)
$class = $warnclass;
break;
case 'PGA.Temperature':
$ret = $value.'&deg;C';
break;
case 'GPU.Temperature':
$ret = $value.'&deg;C';
case 'GPU.Fan Speed':
case 'GPU.Fan Percent':
case 'GPU.GPU Clock':
case 'GPU.Memory Clock':
case 'GPU.GPU Voltage':
@ -312,6 +382,32 @@ function fmt($section, $name, $value) @@ -312,6 +382,32 @@ function fmt($section, $name, $value)
if ($value == 0)
$class = $warnclass;
break;
case 'GPU.Fan Percent':
if ($value == 0)
$class = $warnclass;
else
{
if ($value == 100)
$class = $errorclass;
else
if ($value > 85)
$class = $warnclass;
}
break;
case 'GPU.Fan Speed':
if ($value == 0)
$class = $warnclass;
else
if (isset($alldata['Fan Percent']))
{
$test = $alldata['Fan Percent'];
if ($test == 100)
$class = $errorclass;
else
if ($test > 85)
$class = $warnclass;
}
break;
case 'GPU.MHS av':
case 'PGA.MHS av':
case 'SUMMARY.MHS av':
@ -356,6 +452,9 @@ function fmt($section, $name, $value) @@ -356,6 +452,9 @@ function fmt($section, $name, $value)
if ($section == 'NOTIFY' && substr($name, 0, 1) == '*' && $value != '0')
$class = $errorclass;
if ($class == '' && $section != 'POOL')
$class = classlastshare($when, $alldata, $lstclass, $lstclass);
return array($ret, $class);
}
#
@ -390,6 +489,8 @@ function details($cmd, $list, $rig) @@ -390,6 +489,8 @@ function details($cmd, $list, $rig)
global $poolcmd, $readonly;
global $showndate;
$when = 0;
$stas = array('S' => 'Success', 'W' => 'Warning', 'I' => 'Informational', 'E' => 'Error', 'F' => 'Fatal');
echo $tablebegin;
@ -408,7 +509,10 @@ function details($cmd, $list, $rig) @@ -408,7 +509,10 @@ function details($cmd, $list, $rig)
echo '<tr>';
echo '<td>Computer: '.$list['STATUS']['Description'].'</td>';
if (isset($list['STATUS']['When']))
{
echo '<td>When: '.date($dfmt, $list['STATUS']['When']).'</td>';
$when = $list['STATUS']['When'];
}
$sta = $list['STATUS']['STATUS'];
echo '<td>Status: '.$stas[$sta].'</td>';
echo '<td>Message: '.$list['STATUS']['Msg'].'</td>';
@ -436,7 +540,7 @@ function details($cmd, $list, $rig) @@ -436,7 +540,7 @@ function details($cmd, $list, $rig)
foreach ($values as $name => $value)
{
list($showvalue, $class) = fmt($section, $name, $value);
list($showvalue, $class) = fmt($section, $name, $value, $when, $values);
echo "<td$class>$showvalue</td>";
}
@ -587,6 +691,8 @@ function doforeach($cmd, $des, $sum, $head, $datetime) @@ -587,6 +691,8 @@ function doforeach($cmd, $des, $sum, $head, $datetime)
global $tablebegin, $tableend, $warnfont, $warnoff, $dfmt;
global $rigerror;
$when = 0;
$header = $head;
$anss = array();
@ -652,7 +758,7 @@ function doforeach($cmd, $des, $sum, $head, $datetime) @@ -652,7 +758,7 @@ function doforeach($cmd, $des, $sum, $head, $datetime)
else
{
if (isset($row[$name]))
list($showvalue, $class) = fmt('STATUS', $name, $row[$name]);
list($showvalue, $class) = fmt('STATUS', $name, $row[$name], $when, null);
else
{
$class = '';
@ -710,6 +816,10 @@ function doforeach($cmd, $des, $sum, $head, $datetime) @@ -710,6 +816,10 @@ function doforeach($cmd, $des, $sum, $head, $datetime)
foreach ($anss as $rig => $ans)
{
$when = 0;
if (isset($ans['STATUS']['When']))
$when = $ans['STATUS']['When'];
foreach ($ans as $item => $row)
{
if ($item == 'STATUS')
@ -733,12 +843,11 @@ function doforeach($cmd, $des, $sum, $head, $datetime) @@ -733,12 +843,11 @@ function doforeach($cmd, $des, $sum, $head, $datetime)
else
{
if (isset($row[$name]))
list($showvalue, $class) = fmt($section, $name, $row[$name]);
$value = $row[$name];
else
{
$class = '';
$showvalue = '&nbsp;';
}
$value = null;
list($showvalue, $class) = fmt($section, $name, $value, $when, $row);
if ($rig === 'total' and $class == '')
$class = ' class=tot';

Loading…
Cancel
Save