Merge pull request #104 from kanoi/master Return last accepted share pool/time for devices
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
diff --git a/README b/README
index 3fab82d..47e0c78 100644
--- a/README
+++ b/README
@@ -595,6 +595,9 @@ The list of requests and replies are:
devs DEVS Each available CPU and GPU with their details
e.g. GPU=0,Accepted=NN,MHS av=NNN,...,Intensity=D|
+ Last Share Time=NNN, <- standand long time in seconds
+ (or 0 if none) of last accepted share
+ Last Share Pool=N, <- pool number (or -1 if none)
Will not report CPUs if CPU mining is disabled
gpu|N GPU The details of a single GPU number N in the same
diff --git a/api.c b/api.c
index 85f0649..a65c906 100644
--- a/api.c
+++ b/api.c
@@ -146,7 +146,7 @@ static const char *COMMA = ",";
static const char SEPARATOR = '|';
static const char GPUSEP = ',';
-static const char *APIVERSION = "1.0";
+static const char *APIVERSION = "1.1";
static const char *DEAD = "Dead";
static const char *SICK = "Sick";
static const char *NOSTART = "NoStart";
@@ -526,20 +526,24 @@ static void gpustatus(int gpu, bool isjson)
if (cgpu->dynamic)
strcpy(intensity, DYNAMIC);
else
- sprintf(intensity, "%d", gpus->intensity);
+ sprintf(intensity, "%d", cgpu->intensity);
if (isjson)
- sprintf(buf, "{\"GPU\":%d,\"Enabled\":\"%s\",\"Status\":\"%s\",\"Temperature\":%.2f,\"Fan Speed\":%d,\"Fan Percent\":%d,\"GPU Clock\":%d,\"Memory Clock\":%d,\"GPU Voltage\":%.3f,\"GPU Activity\":%d,\"Powertune\":%d,\"MHS av\":%.2f,\"MHS %ds\":%.2f,\"Accepted\":%d,\"Rejected\":%d,\"Hardware Errors\":%d,\"Utility\":%.2f,\"Intensity\":\"%s\"}",
+ sprintf(buf, "{\"GPU\":%d,\"Enabled\":\"%s\",\"Status\":\"%s\",\"Temperature\":%.2f,\"Fan Speed\":%d,\"Fan Percent\":%d,\"GPU Clock\":%d,\"Memory Clock\":%d,\"GPU Voltage\":%.3f,\"GPU Activity\":%d,\"Powertune\":%d,\"MHS av\":%.2f,\"MHS %ds\":%.2f,\"Accepted\":%d,\"Rejected\":%d,\"Hardware Errors\":%d,\"Utility\":%.2f,\"Intensity\":\"%s\",\"Last Share Pool\":%d,\"Last Share Time\":%lu}",
gpu, enabled, status, gt, gf, gp, gc, gm, gv, ga, pt,
cgpu->total_mhashes / total_secs, opt_log_interval, cgpu->rolling,
cgpu->accepted, cgpu->rejected, cgpu->hw_errors,
- cgpu->utility, intensity);
+ cgpu->utility, intensity,
+ ((unsigned long)(cgpu->last_share_pool_time) > 0) ? cgpu->last_share_pool : -1,
+ (unsigned long)(cgpu->last_share_pool_time));
else
- sprintf(buf, "GPU=%d,Enabled=%s,Status=%s,Temperature=%.2f,Fan Speed=%d,Fan Percent=%d,GPU Clock=%d,Memory Clock=%d,GPU Voltage=%.3f,GPU Activity=%d,Powertune=%d,MHS av=%.2f,MHS %ds=%.2f,Accepted=%d,Rejected=%d,Hardware Errors=%d,Utility=%.2f,Intensity=%s%c",
+ sprintf(buf, "GPU=%d,Enabled=%s,Status=%s,Temperature=%.2f,Fan Speed=%d,Fan Percent=%d,GPU Clock=%d,Memory Clock=%d,GPU Voltage=%.3f,GPU Activity=%d,Powertune=%d,MHS av=%.2f,MHS %ds=%.2f,Accepted=%d,Rejected=%d,Hardware Errors=%d,Utility=%.2f,Intensity=%s,Last Share Pool=%d,Last Share Time=%lu%c",
gpu, enabled, status, gt, gf, gp, gc, gm, gv, ga, pt,
cgpu->total_mhashes / total_secs, opt_log_interval, cgpu->rolling,
cgpu->accepted, cgpu->rejected, cgpu->hw_errors,
- cgpu->utility, intensity, SEPARATOR);
+ cgpu->utility, intensity,
+ ((unsigned long)(cgpu->last_share_pool_time) > 0) ? cgpu->last_share_pool : -1,
+ (unsigned long)(cgpu->last_share_pool_time), SEPARATOR);
strcat(io_buffer, buf);
}
@@ -556,17 +560,21 @@ static void cpustatus(int cpu, bool isjson)
cgpu->utility = cgpu->accepted / ( total_secs ? total_secs : 1 ) * 60;
if (isjson)
- sprintf(buf, "{\"CPU\":%d,\"MHS av\":%.2f,\"MHS %ds\":%.2f,\"Accepted\":%d,\"Rejected\":%d,\"Utility\":%.2f}",
+ sprintf(buf, "{\"CPU\":%d,\"MHS av\":%.2f,\"MHS %ds\":%.2f,\"Accepted\":%d,\"Rejected\":%d,\"Utility\":%.2f,\"Last Share Pool\":%d,\"Last Share Time\":%lu}",
cpu, cgpu->total_mhashes / total_secs,
opt_log_interval, cgpu->rolling,
cgpu->accepted, cgpu->rejected,
- cgpu->utility);
+ cgpu->utility,
+ ((unsigned long)(cgpu->last_share_pool_time) > 0) ? cgpu->last_share_pool : -1,
+ (unsigned long)(cgpu->last_share_pool_time));
else
- sprintf(buf, "CPU=%d,MHS av=%.2f,MHS %ds=%.2f,Accepted=%d,Rejected=%d,Utility=%.2f%c",
+ sprintf(buf, "CPU=%d,MHS av=%.2f,MHS %ds=%.2f,Accepted=%d,Rejected=%d,Utility=%.2f,Last Share Pool=%d,Last Share Time=%lu%c",
cpu, cgpu->total_mhashes / total_secs,
opt_log_interval, cgpu->rolling,
cgpu->accepted, cgpu->rejected,
- cgpu->utility, SEPARATOR);
+ cgpu->utility,
+ ((unsigned long)(cgpu->last_share_pool_time) > 0) ? cgpu->last_share_pool : -1,
+ (unsigned long)(cgpu->last_share_pool_time), SEPARATOR);
strcat(io_buffer, buf);
}
diff --git a/miner.php b/miner.php
index 763c022..8ba2b4e 100644
--- a/miner.php
+++ b/miner.php
@@ -18,6 +18,7 @@ td.sta { color:green; font-family:verdana,arial,sans; font-size:14pt; }
<script type='text/javascript'>
function pr(a,m){if(m!=null){if(!confirm(m+'?'))return}window.location="<? echo $here ?>"+a}
function prs(a){var c=a.substr(3);var z=c.split('|',2);var m=z[0].substr(0,1).toUpperCase()+z[0].substr(1)+' GPU '+z[1];pr('?arg='+a,m)}
+function prs2(a,n){var v=document.getElementById('gi'+n).value;var c=a.substr(3);var z=c.split('|',2);var m='Set GPU '+z[1]+' '+z[0].substr(0,1).toUpperCase()+z[0].substr(1)+' to '+v;pr('?arg='+a+','+v,m)}
</script>
<table width=100% height=100% border=0 cellpadding=0 cellspacing=0 summary='Mine'>
<tr><td align=center valign=top>
@@ -156,6 +157,9 @@ function fmt($section, $name, $value)
switch ($section.'.'.$name)
{
+ case 'GPU0.Last Share Time':
+ return date('H:i:s', $value);
+ break;
case 'SUMMARY.Elapsed':
$s = $value % 60;
$value -= $s;
@@ -258,33 +262,69 @@ function details($list)
echo $te;
}
#
-function gpubuttons($count)
+global $devs;
+$devs = null;
+#
+function gpubuttons($count, $info)
{
+ global $devs;
+
+ $basic = array( 'GPU', 'Enable', 'Disable', 'Restart' );
+
+ $options = array( 'intensity' => 'Intensity',
+ 'fan' => 'Fan Percent',
+ 'engine' => 'GPU Clock',
+ 'mem' => 'Memory Clock',
+ 'vddc' => 'GPU Voltage' );
+
$tb = '<tr><td><table border=1 cellpadding=5 cellspacing=0>';
$te = '</table></td></tr>';
echo $tb.'<tr>';
- for ($i = 0; $i < 4; $i++)
- {
- echo '<td>';
+ foreach ($basic as $head)
+ echo "<td>$head</td>";
- if ($i == 0)
- echo 'GPU';
- else
- echo ' ';
-
- echo '</td>';
- }
+ foreach ($options as $name => $des)
+ echo "<td nowrap>$des</td>";
+ $n = 0;
for ($c = 0; $c < $count; $c++)
{
echo '</tr><tr>';
- echo "<td>$c</td>";
- echo "<td><input type=button value='Enable $c' onclick='prs(\"gpuenable|$c\")'></td>";
- echo "<td><input type=button value='Disable $c' onclick='prs(\"gpudisable|$c\")'></td>";
- echo "<td><input type=button value='Restart $c' onclick='prs(\"gpurestart|$c\")'></td>";
+ foreach ($basic as $name)
+ {
+ echo '<td>';
+
+ if ($name == 'GPU')
+ echo $c;
+ else
+ {
+ echo "<input type=button value='$name $c' onclick='prs(\"gpu";
+ echo strtolower($name);
+ echo "|$c\")'>";
+ }
+
+ echo '</td>';
+ }
+
+ foreach ($options as $name => $des)
+ {
+ echo '<td>';
+ if (!isset($devs["GPU$c"][$des]))
+ echo ' ';
+ else
+ {
+ $value = $devs["GPU$c"][$des];
+ echo "<input type=button value='Set $c:' onclick='prs2(\"gpu$name|$c\",$n)'>";
+ echo "<input size=7 type=text name=gi$n value='$value' id=gi$n>";
+ $n++;
+ }
+
+ echo '</td>';
+ }
+
}
echo '</tr>'.$te;
@@ -315,7 +355,7 @@ function processgpus($rd, $ro)
#
function process($cmds, $rd, $ro)
{
- global $error;
+ global $error, $devs;
foreach ($cmds as $cmd => $des)
{
@@ -331,6 +371,8 @@ function process($cmds, $rd, $ro)
{
details($process);
echo '<tr><td><br><br></td></tr>';
+ if ($cmd == 'devs')
+ $devs = $process;
}
}
}
@@ -356,7 +398,8 @@ function display()
$cmds = array( 'devs' => 'device list',
'summary' => 'summary information',
- 'pools' => 'pool list');
+ 'pools' => 'pool list',
+ 'config' => 'cgminer config');
process($cmds, $rd, $ro);