LOG

kod PHP
	define ('CATALOG',"logs_from_mining_software"); 	 
	$file_output = 'results.csv';	
	
	//phoenix - files named log20211110_225431.txt
	//wallet  - 2020.12.29:18:27:39.112: main Cmd line: -pool eth-eu1.nanopool.org:9999 -wal 0x[eth address] 
	//energy  - GPUs power: 206.4 W	
	//times   - 2020.12.29:18:34:40.658: eths Eth: Received:

	//claymore- files named  1605884405_log.txt
	//wallet  - 16:00:05:081	1e08	args: -epool eth-eu1.nanopool.org:9999 -ewal 0x[eth address].name_of_rig
	//energy  - 
	//times   - 16:00:32:483	de8	ETH: 11/20/20-16:00:32 - New job from eth-eu1.nanopool.org:9999

	  
	  
	  
	if (isset($_GET['idf']))   	$idf = $_GET['idf']; 	else $idf = 0;	
	  
	$folder = dir(CATALOG);
	unset($Files_Array);
	while($plik = $folder->read())  {
	   if (($plik != '.') and ($plik != '..')) 	$Files_Array[] = $plik;  
	}
	echo $idf."  -  ".$Files_Array[$idf]."
"; $filesize = filesize(CATALOG.'/'.$Files_Array[$idf]); $file = @fopen(CATALOG.'/'.$Files_Array[$idf], "r"); $power_value = 0; $power_counter = 0; $time_start = NULL; $time_stop = NULL; $power_text = ""; while(!feof($file)) { $line = fgets($file); if (substr($Files_Array[$idf],0,3) == 'log') { //phoenix if (strpos($line, " -wal 0x") > 0 ) { $adres = substr($line, strpos($line, " -wal 0x") + 6, 42);} elseif (strpos($line, "PUs power: ") > 0 ) { $power_value += substr($line, strpos($line, "GPUs power: ") + 12, -4); $power_counter++;} elseif (strpos($line, "Eth: Received: ") > 0 ) { if ($time_start == NULL) $time_start = substr($line, 0, 10)." ".substr($line, 11, 8); $time_stop = substr($line, 0, 10)." ".substr($line, 11, 8); } } if (substr($Files_Array[$idf],0,3) == 'log') { //claymore if (strpos($line, " -ewal 0x") > 0 ) { $adres = substr($line, strpos($line, " -ewal 0x") + 7, 42); } elseif (strpos($line, "New job from ") > 0 ) { if ($time_start == NULL) $time_start = date("Y-m-d", strtotime(substr($line, strpos($line, " - New job from ") -17, 8)))." ".substr($line, strpos($line, " - New job from ") -8, 8); $time_stop = date("Y-m-d", strtotime(substr($line, strpos($line, " - New job from ") -17, 8)))." ".substr($line, strpos($line, " - New job from ") -8, 8); } } } if ($Files_Array[$idf][0] == 'l') $power_text = round($power_value/$power_counter, 1); @fclose($file); if ($idf == 0) { $plik = fopen($file_output, "w"); fwrite($plik, "file;address;time_start;time_stop;energy;\r\n");} else $plik = fopen($file_output, "a"); $contents = $Files_Array[$idf].";".$adres.";".$time_start.";".$time_stop.";".$power_text.";"."\r\n"; fwrite($plik, $contents); fclose($plik); if (sizeof($Files_Array) > ($idf+1)) echo ""; else { $hours_total = 0; $hours_temp = 0; $power_total = 0; $power_count = 0; $file = fopen($file_output, "r"); while(!feof($file)) { $line = fgets($file); $parts = explode(";", $line); if ( strlen($line) > 50 ) { if (strlen($parts[2]) == 19) $data_start = mktime(substr($parts[2],11,2),substr($parts[2],14,2),substr($parts[2],17,2),substr($parts[2],5,2),substr($parts[2],8,2),substr($parts[2],0,4)); if (strlen($parts[3]) == 19) $data_stop = mktime(substr($parts[3],11,2),substr($parts[3],14,2),substr($parts[3],17,2),substr($parts[3],5,2),substr($parts[3],8,2),substr($parts[3],0,4)); $hours_temp = 0; if (strlen($parts[2]) == 19) $hours_temp = round (($data_stop - $data_start)/3600,2); $hours_total += $hours_temp; echo $parts[0].": ". $hours_temp ."
"; if ($parts[4]>0) { $power_total += $parts[4]; $power_count++; } } } if ($power_count > 0) $power_total = round($power_total/$power_count); echo "The time difference [h] :". $hours_total . "
"; echo "Energy avg. consumption [W]:". $power_total; fclose($file); rename($file_output, "results - ".round($hours_total)." [h] - ".$power_total."[W].csv"); }