diff --git a/logs/mesh_network_analyzer.py b/logs/mesh_network_analyzer.py index ba809de..4dc098c 100644 --- a/logs/mesh_network_analyzer.py +++ b/logs/mesh_network_analyzer.py @@ -2,6 +2,7 @@ import os import re from datetime import datetime from collections import Counter, defaultdict +from string import Template import json import platform import subprocess @@ -23,13 +24,9 @@ def parse_log_file(file_path): log_files.sort() for logFile in log_files: - if logFile.startswith('messages'): + if logFile.startswith('meshbot'): with open(os.path.join(file_path, logFile), 'r') as file: - lines = file.readlines() - if len(lines) > 1: - file_path = os.path.join(file_path, logFile) - break - + lines += file.readlines() else: # read the file for the day with open(file_path, 'r') as file: @@ -101,6 +98,7 @@ def get_system_info(): except subprocess.CalledProcessError: return "N/A" + if platform.system() == "Linux": uptime = get_command_output("uptime -p") memory_total = get_command_output("free -m | awk '/Mem:/ {print $2}'") @@ -246,7 +244,7 @@ def generate_main_html(log_data, system_info):
@@ -443,8 +441,6 @@ def generate_main_html(log_data, system_info): """ - - from string import Template template = Template(html_template) return template.safe_substitute( date=datetime.now().strftime('%Y_%m_%d'), @@ -501,18 +497,17 @@ def generate_network_map_html(log_data): """ - from string import Template template = Template(html_template) return template.safe_substitute(gps_coordinates=json.dumps(log_data['gps_coordinates'])) -def generate_hosts_html(system_info): +def generate_sys_hosts_html(system_info): html_template = """ - Host Information + System Host Information -

Host Information

+

System Host Information - ${os_name}

- + + + + + + + +
MetricValue
OS MetricValue
Uptime${uptime}
Total Memory${memory_total}
Available Memory${memory_available}
Total Disk Space${disk_total}
Free Disk Space${disk_free}
Meshtastic CLI/APIValue
CLI Version${cli_version}
Latest Version${latest_version}
Meshbot Node ID${node_id}
Meshbot Name${node_name}
Meshbot Firmware${firmware_version}
Meshbot Up Time${node_uptime}
""" - from string import Template template = Template(html_template) return template.safe_substitute(system_info) @@ -555,7 +556,7 @@ def main(): main_html = generate_main_html(log_data, system_info) network_map_html = generate_network_map_html(log_data) - hosts_html = generate_hosts_html(system_info) + hosts_html = generate_sys_hosts_html(system_info) output_dir = W3_PATH index_path = os.path.join(output_dir, 'index.html')