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

Loading…
Cancel
Save