From 46bc73185dc5ab620c40c47362a83dd715e7aabd Mon Sep 17 00:00:00 2001 From: Tristan Smith Date: Tue, 28 May 2024 11:04:22 -0400 Subject: [PATCH] oops --- 2024/May/27/results.csv | 34 --------------------- finder.py | 50 +++++++++++-------------------- ips.txt | 21 ++++++++++++- readme.md | 2 +- results.csv | 66 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 104 insertions(+), 69 deletions(-) delete mode 100644 2024/May/27/results.csv create mode 100644 results.csv diff --git a/2024/May/27/results.csv b/2024/May/27/results.csv deleted file mode 100644 index 3ec3692..0000000 --- a/2024/May/27/results.csv +++ /dev/null @@ -1,34 +0,0 @@ -Date,Worker ID,IP Address,Log File,Error Type,Error Message -2024-05-27,mw3446,192.168.1.171,/var/log/domokun,ASIC Error,Chain 2 has failed with 0 ASICs found and will power off hash board 2 -2024-05-27,mw3446,192.168.1.171,/var/log/new2.log,ASIC Error,Chain 0 has failed with 0 ASICs found and will power off hash board 0 -2024-05-27,mw3446,192.168.1.171,/var/log/Miner_7426394.log,EEPROM Error,Data load fail for chain 1 -2024-05-27,mw3446,192.168.1.171,/var/log/Miner_7426394.log,Chip Bin Error,No chip bin for chain 0 -2024-05-27,mw3446,192.168.1.171,/var/log/Miner_7426394.log,Chip Bin Error,No chip bin for chain 1 -2024-05-27,mw3446,192.168.1.171,/var/log/Miner_7426394.log,Chip Bin Error,No chip bin for chain 2 -2024-05-27,mw3446,192.168.1.171,/var/log/Miner_6974116.log,ASIC Error,Chain 1 has failed with 0 ASICs found and will power off hash board 1 -2024-05-27,mw3446,192.168.1.171,/var/log/Miner_7426352.log,EEPROM Error,Data load fail for chain 1 -2024-05-27,mw3446,192.168.1.171,/var/log/Miner_7426352.log,EEPROM Error,Data load fail for chain 2 -2024-05-27,mw3446,192.168.1.171,/var/log/new1.log,ASIC Error,Chain 0 has failed with 96 ASICs found and will power off hash board 0 -2024-05-27,mw3446,192.168.1.171,/var/log/failures,ASIC Error,Chain 0 has failed with 0 ASICs found and will power off hash board 0 -2024-05-27,mw3446,192.168.1.171,/var/log/failures,ASIC Error,Chain 1 has failed with 104 ASICs found and will power off hash board 1 -2024-05-27,mw3446,192.168.1.171,/var/log/new2.log,SoC failure,ERROR_SOC_INIT: soc init failed -2024-05-27,mw3446,192.168.1.171,/var/log/Miner_3174359.log,SoC failure,ERROR_SOC_INIT: soc init failed -2024-05-27,mw3446,192.168.1.171,/var/log/Miner_3174359.log,PSU,bitmain_get_power_status failed -2024-05-27,mw3446,192.168.1.171,/var/log/Miner_3174359.log,PSU,power voltage can not meet the target -2024-05-27,mw3446,192.168.1.171,/var/log/Miner_4594191.log,voltage drop,ERROR_POWER_LOST: power voltage rise or drop -2024-05-27,mw3446,192.168.1.171,/var/log/Miner_4594191.log,black hole,reg crc error -2024-05-27,mw3446,192.168.1.171,/var/log/Miner_7426394.log,Temperature Error,ERROR_TEMP_TOO_HIGH -2024-05-27,mw3446,192.168.1.171,/var/log/Miner_7426394.log,PIC Error,_pic_write_iic failed! -2024-05-27,mw3446,192.168.1.171,/var/log/2024-03/06/cglog_init_2024-03-06_19-00-57/miner.log,SoC failure,ERROR_SOC_INIT: soc init failed -2024-05-27,mw3446,192.168.1.171,/var/log/2024-03/06/cglog_init_2024-03-06_19-00-57/messages,SoC failure,ERROR_SOC_INIT: soc init failed -2024-05-27,mw3446,192.168.1.171,/var/log/2024-03/06/cglog_init_2024-03-06_18-53-25/miner.log,SoC failure,ERROR_SOC_INIT: soc init failed -2024-05-27,mw3446,192.168.1.171,/var/log/2024-03/06/cglog_init_2024-03-06_18-53-25/messages,SoC failure,ERROR_SOC_INIT: soc init failed -2024-05-27,mw3446,192.168.1.171,/var/log/2024-03/06/cglog_init_2024-03-06_19-07-47/miner.log,SoC failure,ERROR_SOC_INIT: soc init failed -2024-05-27,mw3446,192.168.1.171,/var/log/2024-03/06/cglog_init_2024-03-06_19-07-47/messages,SoC failure,ERROR_SOC_INIT: soc init failed -2024-05-27,mw3446,192.168.1.171,/var/log/2024-03/06/cglog_init_2024-03-06_20-51-43/miner.log,SoC failure,ERROR_SOC_INIT: soc init failed -2024-05-27,mw3446,192.168.1.171,/var/log/2024-03/06/cglog_init_2024-03-06_20-51-43/messages,SoC failure,ERROR_SOC_INIT: soc init failed -2024-05-27,mw3446,192.168.1.171,/var/log/2024-03/06/cglog_init_2024-03-06_18-01-31/miner.log,SoC failure,ERROR_SOC_INIT: soc init failed -2024-05-27,mw3446,192.168.1.171,/var/log/2024-03/06/cglog_init_2024-03-06_18-01-31/messages,SoC failure,ERROR_SOC_INIT: soc init failed -2024-05-27,mw3446,192.168.1.171,/var/log/Miner_6024072.log,voltage drop,ERROR_POWER_LOST: pic check voltage drop -2024-05-27,mw3446,192.168.1.171,/var/log/test,voltage drop,ERROR_POWER_LOST: power voltage rise or drop -2024-05-27,mw3446,192.168.1.171,/var/log/new1.log,SoC failure,ERROR_SOC_INIT: soc init failed diff --git a/finder.py b/finder.py index 204ea13..5464f73 100644 --- a/finder.py +++ b/finder.py @@ -1,9 +1,8 @@ import paramiko import re import json -import os +import csv from datetime import datetime -import pandas as pd # Load credentials from a JSON file def load_credentials(file_path): @@ -15,14 +14,6 @@ def load_error_keywords(file_path): with open(file_path, 'r') as file: return json.load(file)['error_keywords'] -# Define paths to the configuration files -CREDENTIALS_FILE = 'credentials.json' -ERRORS_FILE = 'errors.json' - -# Load credentials and error keywords -credentials = load_credentials(CREDENTIALS_FILE) -error_keywords = load_error_keywords(ERRORS_FILE) - # Regex patterns for ASIC chip errors and power-off messages asic_pattern = re.compile(r"Chain\[(\d+)\]: find (\d+) asic, times \d+") power_off_pattern = re.compile(r"Chain (\d+) only find (\d+) asic, will power off hash board (\d+)") @@ -47,16 +38,8 @@ def check_logs(ip, ssh_client, worker_id, current_date): for log_file in log_files: log_file = log_file.strip() print(f"Checking file: {log_file}") # Debug statement - # Check if file should be ignored - if log_file.endswith(('tmp', 'utmp', 'btmp', 'wtmp')): - continue - - # Check if file is a binary file - stdin, stdout, stderr = ssh_client.exec_command(f"file {log_file}") - file_type = stdout.read().decode('utf-8') - if 'text' not in file_type: - continue + # Read the log file content directly stdin, stdout, stderr = ssh_client.exec_command(f"cat {log_file}") log_content = stdout.read().decode('utf-8', errors='ignore') print(f"Content of {log_file}: {log_content[:500]}") # Debug statement to show part of the log content @@ -65,6 +48,7 @@ def check_logs(ip, ssh_client, worker_id, current_date): seen_errors = set() for keyword, error_type in error_keywords.items(): if keyword in log_content and (log_file, error_type, keyword) not in seen_errors: + print(f"Found keyword '{keyword}' in {log_file}") # Debug statement logs.append((log_file, error_type, keyword)) seen_errors.add((log_file, error_type, keyword)) @@ -125,9 +109,6 @@ def main(): ips = read_ips('ips.txt') results = [] # Using a list to collect results current_date = datetime.now().strftime('%Y-%m-%d') - current_year = datetime.now().strftime('%Y') - current_month = datetime.now().strftime('%B') - current_day = datetime.now().strftime('%d') for ip in ips: print(f"Processing IP: {ip}") @@ -161,18 +142,21 @@ def main(): print(f"Connection failed for {ip} with {username}:{password} - {e}") ssh_client.close() - # Create the directory structure - directory = os.path.join(current_year, current_month, current_day) - if not os.path.exists(directory): - os.makedirs(directory) - - # Convert results to a DataFrame - results_df = pd.DataFrame(results, columns=["Date", "Worker ID", "IP Address", "Log File", "Error Type", "Error Message"]) - - # Save the results to a CSV file - print("Writing results to CSV") - results_df.to_csv(os.path.join(directory, 'results.csv'), index=False) + # Write results to CSV + csv_file = 'results.csv' + print(f"Writing results to {csv_file}") + with open(csv_file, 'w', newline='') as file: + writer = csv.writer(file) + writer.writerow(["Date", "Worker ID", "IP Address", "Log File", "Error Type", "Error Message"]) + for result in results: + writer.writerow(result) print("Done") if __name__ == "__main__": + # Load credentials and error keywords + CREDENTIALS_FILE = 'credentials.json' + ERRORS_FILE = 'errors.json' + credentials = load_credentials(CREDENTIALS_FILE) + error_keywords = load_error_keywords(ERRORS_FILE) + main() diff --git a/ips.txt b/ips.txt index 6fadc16..7a959db 100644 --- a/ips.txt +++ b/ips.txt @@ -1 +1,20 @@ -192.168.1.171 +10.0.90.105 +10.0.80.243 +10.0.60.194 +10.0.60.189 +10.0.50.164 +10.0.50.28 +10.0.50.156 +10.0.40.191 +10.0.40.118 +10.0.40.189 +10.0.40.155 +10.0.40.244 +10.0.40.203 +10.0.30.178 +10.0.20.163 +10.0.20.59 +10.0.20.210 +10.0.20.131 +10.0.10.169 +10.0.100.54 diff --git a/readme.md b/readme.md index f712a37..2ee805a 100644 --- a/readme.md +++ b/readme.md @@ -1,5 +1,5 @@ # Antminer error finder -Checks for specific strings in log files of Antminer machines. Currently works with stock firmware (and barely at that). Expand to Braiins & LuxOS. This now outputs a csv file to a folder structure of `year/month/day/`. +Checks for specific strings in log files of Antminer machines. Currently works with stock firmware (and barely at that). Expand to Braiins & LuxOS. Started using pandas for writing the csv and for grouping of errors based on machine. diff --git a/results.csv b/results.csv new file mode 100644 index 0000000..5eda4bd --- /dev/null +++ b/results.csv @@ -0,0 +1,66 @@ +Date,Worker ID,IP Address,Log File,Error Type,Error Message +2024-05-28,mw9875,10.0.90.105,/var/log/miner.log,EEPROM Error,Data load fail for chain 1 +2024-05-28,mw9875,10.0.90.105,/var/log/miner.log,EEPROM Error,Data load fail for chain 2 +2024-05-28,mw9875,10.0.90.105,/var/log/messages,EEPROM Error,Data load fail for chain 1 +2024-05-28,mw9875,10.0.90.105,/var/log/messages,EEPROM Error,Data load fail for chain 2 +2024-05-28,mw8576,10.0.80.243,/var/log/miner.log,black hole,reg crc error +2024-05-28,mw6643,10.0.60.194,/var/log/miner.log,ASIC Error,Chain 0 has failed with 0 ASICs found and will power off hash board 0 +2024-05-28,mw6643,10.0.60.194,/var/log/miner/miner.log,ASIC Error,Chain 0 has failed with 0 ASICs found and will power off hash board 0 +2024-05-28,mw6643,10.0.60.194,/var/log/miner/miner.log.0,ASIC Error,Chain 0 has failed with 0 ASICs found and will power off hash board 0 +2024-05-28,mw6643,10.0.60.194,/var/log/miner/miner.log.1,ASIC Error,Chain 0 has failed with 0 ASICs found and will power off hash board 0 +2024-05-28,mw6643,10.0.60.194,/var/log/messages,ASIC Error,Chain 0 has failed with 0 ASICs found and will power off hash board 0 +2024-05-28,mw6643,10.0.60.194,/var/log/miner.log,SoC failure,ERROR_SOC_INIT: soc init failed +2024-05-28,mw6643,10.0.60.194,/var/log/miner/miner.log,SoC failure,ERROR_SOC_INIT: soc init failed +2024-05-28,mw6643,10.0.60.194,/var/log/miner/miner.log.0,SoC failure,ERROR_SOC_INIT: soc init failed +2024-05-28,mw6643,10.0.60.194,/var/log/miner/miner.log.1,SoC failure,ERROR_SOC_INIT: soc init failed +2024-05-28,mw6643,10.0.60.194,/var/log/messages,SoC failure,ERROR_SOC_INIT: soc init failed +2024-05-28,mw5513,10.0.50.164,/var/log/miner.log,ASIC Error,Chain 1 has failed with 0 ASICs found and will power off hash board 1 +2024-05-28,mw5513,10.0.50.164,/var/log/messages,ASIC Error,Chain 1 has failed with 0 ASICs found and will power off hash board 1 +2024-05-28,mw5513,10.0.50.164,/var/log/miner.log,SoC failure,ERROR_SOC_INIT: soc init failed +2024-05-28,mw5513,10.0.50.164,/var/log/messages,SoC failure,ERROR_SOC_INIT: soc init failed +2024-05-28,mw5423,10.0.50.28,/var/log/miner.log,ASIC Error,Chain 0 has failed with 0 ASICs found and will power off hash board 0 +2024-05-28,mw5423,10.0.50.28,/var/log/messages,ASIC Error,Chain 0 has failed with 0 ASICs found and will power off hash board 0 +2024-05-28,mw5383,10.0.50.156,/var/log/miner.log,black hole,reg crc error +2024-05-28,mw5383,10.0.50.156,/var/log/messages,black hole,reg crc error +2024-05-28,mw4184,10.0.40.244,/var/log/miner.log,ASIC Error,Chain 0 has failed with 96 ASICs found and will power off hash board 0 +2024-05-28,mw4184,10.0.40.244,/var/log/messages,ASIC Error,Chain 0 has failed with 96 ASICs found and will power off hash board 0 +2024-05-28,mw4184,10.0.40.244,/var/log/miner.log,SoC failure,ERROR_SOC_INIT: soc init failed +2024-05-28,mw4184,10.0.40.244,/var/log/messages,SoC failure,ERROR_SOC_INIT: soc init failed +2024-05-28,mw4122,10.0.40.203,/var/log/miner.log,ASIC Error,Chain 2 has failed with 0 ASICs found and will power off hash board 2 +2024-05-28,mw4122,10.0.40.203,/var/log/messages,ASIC Error,Chain 2 has failed with 0 ASICs found and will power off hash board 2 +2024-05-28,mw4122,10.0.40.203,/var/log/miner.log,SoC failure,ERROR_SOC_INIT: soc init failed +2024-05-28,mw4122,10.0.40.203,/var/log/messages,SoC failure,ERROR_SOC_INIT: soc init failed +2024-05-28,mw3514,10.0.30.178,/var/log/miner.log,SoC failure,ERROR_SOC_INIT: soc init failed +2024-05-28,mw3514,10.0.30.178,/var/log/miner.log,PSU,bitmain_get_power_status failed +2024-05-28,mw3514,10.0.30.178,/var/log/miner.log,PSU,power voltage can not meet the target +2024-05-28,mw3514,10.0.30.178,/var/log/messages,SoC failure,ERROR_SOC_INIT: soc init failed +2024-05-28,mw3514,10.0.30.178,/var/log/messages,PSU,bitmain_get_power_status failed +2024-05-28,mw3514,10.0.30.178,/var/log/messages,PSU,power voltage can not meet the target +2024-05-28,mw2564,10.0.20.163,/var/log/messages,ASIC Error,Chain 0 has failed with 0 ASICs found and will power off hash board 0 +2024-05-28,mw2564,10.0.20.163,/var/log/messages,ASIC Error,Chain 1 has failed with 0 ASICs found and will power off hash board 1 +2024-05-28,mw2564,10.0.20.163,/var/log/messages,ASIC Error,Chain 2 has failed with 0 ASICs found and will power off hash board 2 +2024-05-28,mw2564,10.0.20.163,/var/log/messages,EEPROM Error,Data load fail for chain 1 +2024-05-28,mw2564,10.0.20.163,/var/log/messages,Chip Bin Error,No chip bin for chain 0 +2024-05-28,mw2564,10.0.20.163,/var/log/messages,Chip Bin Error,No chip bin for chain 1 +2024-05-28,mw2564,10.0.20.163,/var/log/messages,Chip Bin Error,No chip bin for chain 2 +2024-05-28,mw2564,10.0.20.163,/var/log/messages,Temperature Error,ERROR_TEMP_TOO_HIGH +2024-05-28,mw2564,10.0.20.163,/var/log/messages,PIC Error,_pic_write_iic failed! +2024-05-28,mw2564,10.0.20.163,/var/log/messages,SoC failure,ERROR_SOC_INIT: soc init failed +2024-05-28,mw2481,10.0.20.59,/var/log/messages,SoC failure,ERROR_SOC_INIT: soc init failed +2024-05-28,mw2184,10.0.20.210,/var/log/messages,ASIC Error,Chain 0 has failed with 0 ASICs found and will power off hash board 0 +2024-05-28,mw2144,10.0.20.131,/var/log/messages,ASIC Error,Chain 0 has failed with 0 ASICs found and will power off hash board 0 +2024-05-28,mw2144,10.0.20.131,/var/log/messages,ASIC Error,Chain 1 has failed with 0 ASICs found and will power off hash board 1 +2024-05-28,mw2144,10.0.20.131,/var/log/messages,ASIC Error,Chain 2 has failed with 0 ASICs found and will power off hash board 2 +2024-05-28,mw2144,10.0.20.131,/var/log/messages,EEPROM Error,Data load fail for chain 0 +2024-05-28,mw2144,10.0.20.131,/var/log/messages,Chip Bin Error,No chip bin for chain 0 +2024-05-28,mw2144,10.0.20.131,/var/log/messages,Chip Bin Error,No chip bin for chain 1 +2024-05-28,mw2144,10.0.20.131,/var/log/messages,Chip Bin Error,No chip bin for chain 2 +2024-05-28,mw2144,10.0.20.131,/var/log/messages,Temperature Error,ERROR_TEMP_TOO_HIGH +2024-05-28,mw2144,10.0.20.131,/var/log/messages,PIC Error,_pic_write_iic failed! +2024-05-28,mw2144,10.0.20.131,/var/log/messages,SoC failure,ERROR_SOC_INIT: soc init failed +2024-05-28,mw1132,10.0.10.169,/var/log/miner.log,SoC failure,ERROR_SOC_INIT: soc init failed +2024-05-28,mw1132,10.0.10.169,/var/log/messages,SoC failure,ERROR_SOC_INIT: soc init failed +2024-05-28,mwxxx2,10.0.100.54,/var/log/miner.log,ASIC Error,Chain 1 has failed with 0 ASICs found and will power off hash board 1 +2024-05-28,mwxxx2,10.0.100.54,/var/log/miner.log,ASIC Error,Chain 2 has failed with 0 ASICs found and will power off hash board 2 +2024-05-28,mwxxx2,10.0.100.54,/var/log/messages,ASIC Error,Chain 1 has failed with 0 ASICs found and will power off hash board 1 +2024-05-28,mwxxx2,10.0.100.54,/var/log/messages,ASIC Error,Chain 2 has failed with 0 ASICs found and will power off hash board 2