From 05093a9d495cafd81777bd8f541bb621fca99ac3 Mon Sep 17 00:00:00 2001 From: MacRimi Date: Sun, 26 Oct 2025 22:53:13 +0100 Subject: [PATCH] Update AppImage --- AppImage/components/system-overview.tsx | 2 +- AppImage/scripts/flask_server.py | 85 ++++++++++++++++++++++++- 2 files changed, 83 insertions(+), 4 deletions(-) diff --git a/AppImage/components/system-overview.tsx b/AppImage/components/system-overview.tsx index ce08a9f..468799f 100644 --- a/AppImage/components/system-overview.tsx +++ b/AppImage/components/system-overview.tsx @@ -174,7 +174,7 @@ const fetchStorageData = async (): Promise => { const fetchNetworkData = async (): Promise => { try { const baseUrl = typeof window !== "undefined" ? `${window.location.protocol}//${window.location.hostname}:8008` : "" - const apiUrl = `${baseUrl}/api/network` + const apiUrl = `${baseUrl}/api/network/summary` const response = await fetch(apiUrl, { method: "GET", diff --git a/AppImage/scripts/flask_server.py b/AppImage/scripts/flask_server.py index 2428869..fc5e1ee 100644 --- a/AppImage/scripts/flask_server.py +++ b/AppImage/scripts/flask_server.py @@ -1375,7 +1375,7 @@ def get_interface_type(interface_name): return 'vlan' # Check if it's a physical interface - if interface_name.startswith(('enp', 'eth', 'wlan', 'wlp', 'eno', 'ens')): + if interface_name.startswith(('enp', 'eth', 'eno', 'ens', 'wlan', 'wlp')): return 'physical' # Default to skip for unknown types @@ -3493,6 +3493,7 @@ def get_hardware_info(): except Exception as e: print(f"[v0] Error getting graphics cards: {e}") + # PCI Devices try: print("[v0] Getting PCI devices with driver information...") # First get basic device info with lspci -vmm @@ -3807,6 +3808,83 @@ def api_network(): """Get network information""" return jsonify(get_network_info()) +@app.route('/api/network/summary', methods=['GET']) +def api_network_summary(): + """Optimized network summary endpoint - returns basic network info without detailed analysis""" + try: + net_io = psutil.net_io_counters() + net_if_stats = psutil.net_if_stats() + net_if_addrs = psutil.net_if_addrs() + + # Count active interfaces by type + physical_active = 0 + physical_total = 0 + bridge_active = 0 + bridge_total = 0 + + physical_interfaces = [] + bridge_interfaces = [] + + for interface_name, stats in net_if_stats.items(): + # Skip loopback and special interfaces + if interface_name in ['lo', 'docker0'] or interface_name.startswith(('veth', 'tap', 'fw')): + continue + + is_up = stats.isup + + # Classify interface type + if interface_name.startswith(('enp', 'eth', 'eno', 'ens', 'wlan', 'wlp')): + physical_total += 1 + if is_up: + physical_active += 1 + # Get IP addresses + addresses = [] + if interface_name in net_if_addrs: + for addr in net_if_addrs[interface_name]: + if addr.family == socket.AF_INET: + addresses.append({'ip': addr.address, 'netmask': addr.netmask}) + + physical_interfaces.append({ + 'name': interface_name, + 'status': 'up' if is_up else 'down', + 'addresses': addresses + }) + + elif interface_name.startswith(('vmbr', 'br')): + bridge_total += 1 + if is_up: + bridge_active += 1 + # Get IP addresses + addresses = [] + if interface_name in net_if_addrs: + for addr in net_if_addrs[interface_name]: + if addr.family == socket.AF_INET: + addresses.append({'ip': addr.address, 'netmask': addr.netmask}) + + bridge_interfaces.append({ + 'name': interface_name, + 'status': 'up' if is_up else 'down', + 'addresses': addresses + }) + + return jsonify({ + 'physical_active_count': physical_active, + 'physical_total_count': physical_total, + 'bridge_active_count': bridge_active, + 'bridge_total_count': bridge_total, + 'physical_interfaces': physical_interfaces, + 'bridge_interfaces': bridge_interfaces, + 'traffic': { + 'bytes_sent': net_io.bytes_sent, + 'bytes_recv': net_io.bytes_recv, + 'packets_sent': net_io.packets_sent, + 'packets_recv': net_io.packets_recv + } + }) + except Exception as e: + print(f"[v0] Error in api_network_summary: {e}") + return jsonify({'error': str(e)}), 500 + @app.route('/api/network//metrics', methods=['GET']) def api_network_interface_metrics(interface_name): """Get historical metrics (RRD data) for a specific network interface""" @@ -4882,6 +4960,7 @@ def api_info(): '/api/storage', '/api/proxmox-storage', '/api/network', + '/api/network/summary', # Added network summary '/api/vms', '/api/vms//metrics', # Added endpoint for RRD data '/api/node/metrics', # Added node metrics endpoint @@ -5210,8 +5289,8 @@ def api_vm_config_update(vmid): 'error': config_result.stderr }), 500 else: - return jsonify({'error': 'Failed to get VM details'}), 500 - except Exception as e: + return jsonify({'error': 'Failed to get VM + except Exception as e: print(f"Error updating VM configuration: {e}") return jsonify({'error': str(e)}), 500