'local-sample.php', //'EPSYTOUR'=>'epsytour.php', /* copy local.php file and edit target IP:PORT */ ); // 3 seconds max. set_time_limit(3); error_reporting(0); function getdataFromPeers() { global $host, $configs; $data = array(); foreach ($configs as $name => $conf) { $json = file_get_contents($host.$conf); $data[$name] = json_decode($json, TRUE); } return $data; } function ignoreField($key) { $ignored = array( 'API','VER','GPU','BUS','POOLS', 'CARD','GPUS','CPU','TS', ); return in_array($key, $ignored); } function translateField($key) { $intl = array(); $intl['NAME'] = 'Software'; $intl['VER'] = 'Version'; $intl['ALGO'] = 'Algorithm'; $intl['GPUS'] = 'GPUs'; $intl['CPUS'] = 'Threads'; $intl['KHS'] = 'Hash rate'; $intl['ACC'] = 'Accepted shares'; $intl['ACCMN'] = 'Accepted / mn'; $intl['REJ'] = 'Rejected'; $intl['SOLV'] = 'Solved'; $intl['DIFF'] = 'Difficulty'; $intl['NETKHS'] = 'Net Rate'; $intl['UPTIME'] = 'Miner up time'; $intl['TS'] = 'Last update'; $intl['THR'] = 'Throughput'; $intl['WAIT'] = 'Wait time'; $intl['H'] = 'Bloc height'; $intl['I'] = 'Intensity'; $intl['HWF'] = 'Failures'; $intl['POOLS'] = 'Pools'; $intl['TEMP'] = 'T°c'; $intl['FAN'] = 'Fan %'; $intl['FREQ'] = 'Freq.'; $intl['POWER'] = 'Power'; $intl['PST'] = 'P-State'; // pool infos $intl['POOL'] = 'Pool'; $intl['PING'] = 'Ping (ms)'; $intl['DISCO'] = 'Disconnects'; $intl['USER'] = 'User'; if (isset($intl[$key])) return $intl[$key]; else return $key; } function translateValue($key,$val,$data=array()) { switch ($key) { case 'UPTIME': case 'WAIT': $min = floor(intval($val) / 60); $sec = intval($val) % 60; $val = "${min}mn${sec}s"; if ($min > 180) { $hrs = floor($min / 60); $min = $min % 60; $val = "${hrs}h${min}mn"; } break; case 'NAME': $val = $data['NAME'].' '.$data['VER']; break; case 'FREQ': $val = sprintf("%d MHz", round(floatval($val)/1000.0)); break; case 'POWER': $val = sprintf("%d W", round(floatval($val)/1000.0)); break; case 'TS': $val = strftime("%H:%M:%S", (int) $val); break; case 'KHS': case 'NETKHS': $val = ''.$val.' kH/s'; break; case 'NAME': case 'POOL'; case 'USER': // long fields $val = ''.$val.''; break; } return $val; } function filterPoolInfos($stats) { $keys = array('USER','H','PING','DISCO'); $data = array(); $pool = array_pop($stats); // simplify URL to host only $data['POOL'] = $pool['URL']; if (strstr($pool['URL'],'://')) { $parts = explode(':', $pool['URL']); $data['POOL'] = substr($parts[1],2); } foreach ($pool as $key=>$val) { if (in_array($key, $keys)) $data[$key] = $val; } return $data; } function displayData($data) { $htm = ''; $totals = array(); foreach ($data as $name => $stats) { if (!isset($stats['summary'])) continue; $htm .= '
'.$name." | |
---|---|
'.translateField($key).' | '. ''.translateValue($key, $val, $summary)." |
POOL | |
'.translateField($key).' | '. ''.translateValue($key, $val)." |
'.$g." $card | |
'.translateField($key).' | '. ''.translateValue($key, $val)." |