From 8786cb518087f8db322878acec6c73f1f95e6e58 Mon Sep 17 00:00:00 2001 From: MacRimi Date: Sun, 19 Oct 2025 17:40:13 +0200 Subject: [PATCH] Update AppImage --- AppImage/components/virtual-machines.tsx | 26 ++++++++++++++---------- AppImage/scripts/flask_server.py | 23 ++++++++++++++++++++- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/AppImage/components/virtual-machines.tsx b/AppImage/components/virtual-machines.tsx index a1be30d..b706580 100644 --- a/AppImage/components/virtual-machines.tsx +++ b/AppImage/components/virtual-machines.tsx @@ -187,7 +187,6 @@ export function VirtualMachines() { const [vmConfigs, setVmConfigs] = useState>({}) const [currentView, setCurrentView] = useState<"main" | "metrics">("main") const [selectedMetric, setSelectedMetric] = useState<"cpu" | "memory" | "disk" | "network" | null>(null) - const [metricsDialogOpen, setMetricsDialogOpen] = useState(false) // Declare and initialize metricsDialogOpen useEffect(() => { const fetchLXCIPs = async () => { @@ -239,7 +238,6 @@ export function VirtualMachines() { const handleMetricClick = (metric: "cpu" | "memory" | "disk" | "network") => { setSelectedMetric(metric) setCurrentView("metrics") - setMetricsDialogOpen(true) // Open the metrics dialog } const handleBackToMain = () => { @@ -561,7 +559,6 @@ export function VirtualMachines() { className="cursor-pointer hover:opacity-80 transition-opacity" onClick={() => { setSelectedMetric("cpu") - setMetricsDialogOpen(true) }} >
{ setSelectedMetric("memory") - setMetricsDialogOpen(true) }} >
{ setSelectedMetric("disk") - setMetricsDialogOpen(true) }} >
@@ -770,7 +764,9 @@ export function VirtualMachines() {
CPU Usage
handleMetricClick("cpu")} + onClick={() => { + setSelectedMetric("cpu") + }} >
{(selectedVM.cpu * 100).toFixed(1)}% @@ -785,7 +781,9 @@ export function VirtualMachines() {
Memory
handleMetricClick("memory")} + onClick={() => { + setSelectedMetric("memory") + }} >
Disk
handleMetricClick("disk")} + onClick={() => { + setSelectedMetric("disk") + }} >
Disk I/O
handleMetricClick("disk")} + onClick={() => { + setSelectedMetric("disk") + }} >
@@ -841,7 +843,9 @@ export function VirtualMachines() {
Network I/O
handleMetricClick("network")} + onClick={() => { + setSelectedMetric("network") + }} >
diff --git a/AppImage/scripts/flask_server.py b/AppImage/scripts/flask_server.py index 9714503..f3ba731 100644 --- a/AppImage/scripts/flask_server.py +++ b/AppImage/scripts/flask_server.py @@ -3758,35 +3758,52 @@ def api_vm_metrics(vmid): try: timeframe = request.args.get('timeframe', 'week') # hour, day, week, month, year + print(f"[v0] ===== METRICS REQUEST =====") + print(f"[v0] VMID: {vmid}") + print(f"[v0] Timeframe: {timeframe}") + # Validate timeframe valid_timeframes = ['hour', 'day', 'week', 'month', 'year'] if timeframe not in valid_timeframes: + print(f"[v0] ERROR: Invalid timeframe: {timeframe}") return jsonify({'error': f'Invalid timeframe. Must be one of: {", ".join(valid_timeframes)}'}), 400 # Get local node name local_node = socket.gethostname() + print(f"[v0] Local node: {local_node}") # First, determine if it's a qemu VM or lxc container + print(f"[v0] Checking if VMID {vmid} is QEMU...") result = subprocess.run(['pvesh', 'get', f'/nodes/{local_node}/qemu/{vmid}/status/current', '--output-format', 'json'], capture_output=True, text=True, timeout=10) vm_type = 'qemu' if result.returncode != 0: + print(f"[v0] Not QEMU, checking if LXC...") # Try LXC result = subprocess.run(['pvesh', 'get', f'/nodes/{local_node}/lxc/{vmid}/status/current', '--output-format', 'json'], capture_output=True, text=True, timeout=10) if result.returncode == 0: vm_type = 'lxc' + print(f"[v0] Found as LXC") else: + print(f"[v0] ERROR: VM/LXC {vmid} not found") return jsonify({'error': f'VM/LXC {vmid} not found'}), 404 + else: + print(f"[v0] Found as QEMU") # Get RRD data + print(f"[v0] Fetching RRD data for {vm_type} {vmid} with timeframe {timeframe}...") rrd_result = subprocess.run(['pvesh', 'get', f'/nodes/{local_node}/{vm_type}/{vmid}/rrddata', '--timeframe', timeframe, '--output-format', 'json'], capture_output=True, text=True, timeout=10) if rrd_result.returncode == 0: + print(f"[v0] RRD data fetched successfully") + print(f"[v0] RRD output length: {len(rrd_result.stdout)} bytes") rrd_data = json.loads(rrd_result.stdout) + print(f"[v0] RRD data points: {len(rrd_data)}") + print(f"[v0] ===== METRICS REQUEST SUCCESS =====") return jsonify({ 'vmid': vmid, 'type': vm_type, @@ -3794,10 +3811,14 @@ def api_vm_metrics(vmid): 'data': rrd_data }) else: + print(f"[v0] ERROR: Failed to get RRD data") + print(f"[v0] stderr: {rrd_result.stderr}") + print(f"[v0] ===== METRICS REQUEST FAILED =====") return jsonify({'error': f'Failed to get RRD data: {rrd_result.stderr}'}), 500 except Exception as e: - print(f"Error getting VM metrics: {e}") + print(f"[v0] EXCEPTION in api_vm_metrics: {e}") + print(f"[v0] ===== METRICS REQUEST EXCEPTION =====") return jsonify({'error': str(e)}), 500 @app.route('/api/logs', methods=['GET'])