miner.php add display 'notify' command
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
diff --git a/miner.php b/miner.php
index 6e501ba..14b249e 100644
--- a/miner.php
+++ b/miner.php
@@ -1,7 +1,7 @@
<?php
session_start();
#
-global $miner, $port, $readonly;
+global $miner, $port, $readonly, $notify;
$miner = '127.0.0.1'; # hostname or IP address
$port = 4028;
#
@@ -9,6 +9,12 @@ $port = 4028;
# Set $readonly to false then it will check cgminer 'privileged'
$readonly = false;
#
+# Set $notify to false to NOT attempt to display the notify command
+# Set $notify to true to attempt to display the notify command
+# If your older version of cgminer returns an 'Invalid command'
+# coz it doesn't have notify - it just shows the error status table
+$notify = true;
+#
$here = $_SERVER['PHP_SELF'];
#
function htmlhead()
@@ -27,6 +33,8 @@ function htmlhead()
<style type='text/css'>
td { color:blue; font-family:verdana,arial,sans; font-size:13pt; }
td.h { color:blue; font-family:verdana,arial,sans; font-size:13pt; background:#d0ffff }
+td.err { color:black; font-family:verdana,arial,sans; font-size:13pt; background:#ff3050 }
+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; }
</style>
</head><body bgcolor=#ecffff>
@@ -177,55 +185,87 @@ function getparam($name, $both = false)
#
function fmt($section, $name, $value)
{
+ $errorclass = ' class=err';
+ $warnclass = ' class=warn';
$b = ' ';
+ $ret = $value;
+ $class = '';
+
switch ($section.'.'.$name)
{
case 'GPU.Last Share Time':
case 'PGA.Last Share Time':
- return date('H:i:s', $value);
+ $ret = date('H:i:s', $value);
break;
case 'SUMMARY.Elapsed':
$s = $value % 60;
$value -= $s;
$value /= 60;
if ($value == 0)
- {
- return $s.'s';
- }
+ $ret = $s.'s';
else
{
$m = $value % 60;
$value -= $m;
$value /= 60;
if ($value == 0)
- {
- return sprintf("%dm$b%02ds", $m, $s);
- }
+ $ret = sprintf("%dm$b%02ds", $m, $s);
else
{
$h = $value % 24;
$value -= $h;
$value /= 24;
if ($value == 0)
- return sprintf("%dh$b%02dm$b%02ds", $h, $m, $s);
+ $ret = sprintf("%dh$b%02dm$b%02ds", $h, $m, $s);
else
- return sprintf("%ddays$b%02dh$b%02dm$b%02ds", $value, $h, $m, $s);
+ $ret = sprintf("%ddays$b%02dh$b%02dm$b%02ds", $value, $h, $m, $s);
}
}
break;
+ case 'NOTIFY.Last Well':
+ if ($value == '0')
+ {
+ $ret = 'Never';
+ $class = $warnclass;
+ }
+ else
+ $ret = date('H:i:s', $value);
+ break;
+ case 'NOTIFY.Last Not Well':
+ if ($value == '0')
+ $ret = 'Never';
+ else
+ {
+ $ret = date('H:i:s', $value);
+ $class = $errorclass;
+ }
+ break;
+ case 'NOTIFY.Reason Not Well':
+ if ($value != 'None')
+ $class = $errorclass;
+ break;
case 'GPU.Utility':
case 'PGA.Utility':
case 'SUMMARY.Utility':
- return $value.'/m';
+ $ret = $value.'/m';
break;
case 'GPU.Temperature':
case 'PGA.Temperature':
- return $value.'°C';
+ $ret = $value.'°C';
break;
}
- return $value;
+ if ($section == 'NOTIFY')
+ {
+ $code = preg_split('/ /', $name);
+ if (count($code) > 1)
+ if ($code[0] == 'Thread' || $code[0] == 'Dev')
+ if ($value != '0')
+ $class = $errorclass;
+ }
+
+ return array($ret, $class);
}
#
global $poolcmd;
@@ -302,7 +342,10 @@ function details($cmd, $list)
echo '<tr>';
foreach ($values as $name => $value)
- echo '<td>'.fmt($section, $name, $value).'</td>';
+ {
+ list($showvalue, $class) = fmt($section, $name, $value);
+ echo "<td$class>$showvalue</td>";
+ }
if ($cmd == 'pools' && $readonly === false)
{
@@ -444,7 +487,7 @@ function process($cmds, $rd, $ro)
#
function display()
{
- global $error, $readonly;
+ global $error, $readonly, $notify;
$error = null;
@@ -464,8 +507,12 @@ function display()
$cmds = array( 'devs' => 'device list',
'summary' => 'summary information',
- 'pools' => 'pool list',
- 'config' => 'cgminer config');
+ 'pools' => 'pool list');
+
+ if ($notify)
+ $cmds['notify'] = 'device status';
+
+ $cmds['config'] = 'cgminer config';
process($cmds, $rd, $ro);