mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-10-02 08:06:17 +00:00
update AppImage
This commit is contained in:
@@ -46,12 +46,13 @@ export function ProxmoxDashboard() {
|
|||||||
const fetchSystemData = useCallback(async () => {
|
const fetchSystemData = useCallback(async () => {
|
||||||
console.log("[v0] Fetching system data from Flask server...")
|
console.log("[v0] Fetching system data from Flask server...")
|
||||||
console.log("[v0] Current window location:", window.location.href)
|
console.log("[v0] Current window location:", window.location.href)
|
||||||
|
console.log("[v0] Window host:", window.location.host)
|
||||||
|
console.log("[v0] Window hostname:", window.location.hostname)
|
||||||
|
console.log("[v0] Window port:", window.location.port)
|
||||||
|
|
||||||
// Usar ruta relativa si estamos en el mismo servidor, sino usar localhost:8008
|
// Esto permite que los clientes se conecten usando la IP del servidor (ej: 192.168.0.52:8008)
|
||||||
const apiUrl =
|
// en lugar de localhost
|
||||||
window.location.hostname === "localhost" && window.location.port === "8008"
|
const apiUrl = `/api/system` // Siempre usar ruta relativa
|
||||||
? "/api/system" // Ruta relativa cuando estamos en el servidor Flask
|
|
||||||
: "http://localhost:8008/api/system" // URL completa para desarrollo
|
|
||||||
|
|
||||||
console.log("[v0] API URL:", apiUrl)
|
console.log("[v0] API URL:", apiUrl)
|
||||||
|
|
||||||
@@ -152,12 +153,12 @@ export function ProxmoxDashboard() {
|
|||||||
<p>
|
<p>
|
||||||
• Try accessing:{" "}
|
• Try accessing:{" "}
|
||||||
<a
|
<a
|
||||||
href="http://localhost:8008/api/health"
|
href={`http://${typeof window !== "undefined" ? window.location.host : "localhost:8008"}/api/health`}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
className="underline"
|
className="underline"
|
||||||
>
|
>
|
||||||
http://localhost:8008/api/health
|
http://{typeof window !== "undefined" ? window.location.host : "localhost:8008"}/api/health
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -170,7 +171,7 @@ export function ProxmoxDashboard() {
|
|||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<div className="flex items-center space-x-4">
|
<div className="flex items-center space-x-4">
|
||||||
<div className="flex items-center space-x-3">
|
<div className="flex items-center space-x-3">
|
||||||
<div className="w-10 h-10 relative flex items-center justify-center bg-primary/10 rounded-lg overflow-hidden">
|
<div className="w-10 h-10 relative flex items-center justify-center bg-primary/10 overflow-hidden">
|
||||||
<Image
|
<Image
|
||||||
src="/images/proxmenux-logo.png"
|
src="/images/proxmenux-logo.png"
|
||||||
alt="ProxMenux Logo"
|
alt="ProxMenux Logo"
|
||||||
|
@@ -289,25 +289,8 @@ def get_system_info():
|
|||||||
}
|
}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Critical error getting system info: {e}")
|
print(f"Critical error getting system info: {e}")
|
||||||
try:
|
|
||||||
# Try to get at least basic info
|
|
||||||
memory = psutil.virtual_memory()
|
|
||||||
return {
|
return {
|
||||||
'cpu_usage': 0,
|
'error': f'Unable to access system information: {str(e)}',
|
||||||
'memory_usage': round(memory.percent, 1),
|
|
||||||
'memory_total': round(memory.total / (1024**3), 1),
|
|
||||||
'memory_used': round(memory.used / (1024**3), 1),
|
|
||||||
'temperature': 0,
|
|
||||||
'uptime': 'unknown',
|
|
||||||
'load_average': [0, 0, 0],
|
|
||||||
'hostname': socket.gethostname(),
|
|
||||||
'node_id': 'unknown',
|
|
||||||
'timestamp': datetime.now().isoformat(),
|
|
||||||
'error': 'Partial system information only'
|
|
||||||
}
|
|
||||||
except:
|
|
||||||
return {
|
|
||||||
'error': 'Unable to access system information',
|
|
||||||
'timestamp': datetime.now().isoformat()
|
'timestamp': datetime.now().isoformat()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -333,7 +316,7 @@ def get_storage_info():
|
|||||||
try:
|
try:
|
||||||
partition_usage = psutil.disk_usage(partition.mountpoint)
|
partition_usage = psutil.disk_usage(partition.mountpoint)
|
||||||
|
|
||||||
disk_temp = 42 # Default fallback
|
disk_temp = 0
|
||||||
try:
|
try:
|
||||||
# Try to get disk temperature from sensors
|
# Try to get disk temperature from sensors
|
||||||
if hasattr(psutil, "sensors_temperatures"):
|
if hasattr(psutil, "sensors_temperatures"):
|
||||||
@@ -355,7 +338,7 @@ def get_storage_info():
|
|||||||
'used': round(partition_usage.used / (1024**3), 1),
|
'used': round(partition_usage.used / (1024**3), 1),
|
||||||
'available': round(partition_usage.free / (1024**3), 1),
|
'available': round(partition_usage.free / (1024**3), 1),
|
||||||
'usage_percent': round((partition_usage.used / partition_usage.total) * 100, 1),
|
'usage_percent': round((partition_usage.used / partition_usage.total) * 100, 1),
|
||||||
'health': 'healthy', # Would need SMART data for real health
|
'health': 'unknown', # Would need SMART data for real health
|
||||||
'temperature': disk_temp
|
'temperature': disk_temp
|
||||||
}
|
}
|
||||||
storage_data['disks'].append(disk_info)
|
storage_data['disks'].append(disk_info)
|
||||||
@@ -367,58 +350,24 @@ def get_storage_info():
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
if not storage_data['disks'] and storage_data['total'] == 0:
|
if not storage_data['disks'] and storage_data['total'] == 0:
|
||||||
print("Warning: No storage data available, using fallback values")
|
|
||||||
return {
|
return {
|
||||||
'total': 24.5,
|
'error': 'No storage data available - unable to access disk information',
|
||||||
'used': 4.8,
|
'total': 0,
|
||||||
'available': 18.4,
|
'used': 0,
|
||||||
'disks': [
|
'available': 0,
|
||||||
{
|
'disks': []
|
||||||
'name': '/dev/mapper/pve-root',
|
|
||||||
'mountpoint': '/',
|
|
||||||
'fstype': 'ext4',
|
|
||||||
'total': 24.5,
|
|
||||||
'used': 4.8,
|
|
||||||
'available': 18.4,
|
|
||||||
'usage_percent': 19.8,
|
|
||||||
'health': 'healthy',
|
|
||||||
'temperature': 42
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return storage_data
|
return storage_data
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error getting storage info: {e}")
|
print(f"Error getting storage info: {e}")
|
||||||
try:
|
|
||||||
disk_usage = psutil.disk_usage('/')
|
|
||||||
return {
|
|
||||||
'total': round(disk_usage.total / (1024**3), 1),
|
|
||||||
'used': round(disk_usage.used / (1024**3), 1),
|
|
||||||
'available': round(disk_usage.free / (1024**3), 1),
|
|
||||||
'disks': [
|
|
||||||
{
|
|
||||||
'name': 'root',
|
|
||||||
'mountpoint': '/',
|
|
||||||
'fstype': 'unknown',
|
|
||||||
'total': round(disk_usage.total / (1024**3), 1),
|
|
||||||
'used': round(disk_usage.used / (1024**3), 1),
|
|
||||||
'available': round(disk_usage.free / (1024**3), 1),
|
|
||||||
'usage_percent': round((disk_usage.used / disk_usage.total) * 100, 1),
|
|
||||||
'health': 'unknown',
|
|
||||||
'temperature': 0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
except:
|
|
||||||
print("Critical: Cannot access any storage information, using mock data")
|
|
||||||
return {
|
return {
|
||||||
|
'error': f'Unable to access storage information: {str(e)}',
|
||||||
'total': 0,
|
'total': 0,
|
||||||
'used': 0,
|
'used': 0,
|
||||||
'available': 0,
|
'available': 0,
|
||||||
'disks': [],
|
'disks': []
|
||||||
'error': 'Unable to access storage information'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_network_info():
|
def get_network_info():
|
||||||
@@ -465,10 +414,9 @@ def get_network_info():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error getting network info: {e}")
|
print(f"Error getting network info: {e}")
|
||||||
return {
|
return {
|
||||||
'interfaces': [
|
'error': f'Unable to access network information: {str(e)}',
|
||||||
{'name': 'eth0', 'status': 'up', 'addresses': [{'ip': '192.168.1.100', 'netmask': '255.255.255.0'}]}
|
'interfaces': [],
|
||||||
],
|
'traffic': {'bytes_sent': 0, 'bytes_recv': 0, 'packets_sent': 0, 'packets_recv': 0}
|
||||||
'traffic': {'bytes_sent': 1000000, 'bytes_recv': 2000000}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_proxmox_vms():
|
def get_proxmox_vms():
|
||||||
@@ -482,23 +430,16 @@ def get_proxmox_vms():
|
|||||||
vms = json.loads(result.stdout)
|
vms = json.loads(result.stdout)
|
||||||
return vms
|
return vms
|
||||||
else:
|
else:
|
||||||
# Fallback to mock data if pvesh is not available
|
return {
|
||||||
return [
|
'error': 'pvesh command not available or failed - Proxmox API not accessible',
|
||||||
{
|
'vms': []
|
||||||
'vmid': 100,
|
|
||||||
'name': 'web-server-01',
|
|
||||||
'status': 'running',
|
|
||||||
'cpu': 0.45,
|
|
||||||
'mem': 8589934592, # 8GB in bytes
|
|
||||||
'maxmem': 17179869184, # 16GB in bytes
|
|
||||||
'disk': 53687091200, # 50GB in bytes
|
|
||||||
'maxdisk': 107374182400, # 100GB in bytes
|
|
||||||
'uptime': 1324800 # seconds
|
|
||||||
}
|
}
|
||||||
]
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error getting VM info: {e}")
|
print(f"Error getting VM info: {e}")
|
||||||
return []
|
return {
|
||||||
|
'error': f'Unable to access VM information: {str(e)}',
|
||||||
|
'vms': []
|
||||||
|
}
|
||||||
|
|
||||||
@app.route('/api/system', methods=['GET'])
|
@app.route('/api/system', methods=['GET'])
|
||||||
def api_system():
|
def api_system():
|
||||||
@@ -545,19 +486,16 @@ def api_logs():
|
|||||||
continue
|
continue
|
||||||
return jsonify(logs)
|
return jsonify(logs)
|
||||||
else:
|
else:
|
||||||
# Fallback mock logs
|
return jsonify({
|
||||||
return jsonify([
|
'error': 'journalctl not available or failed',
|
||||||
{
|
'logs': []
|
||||||
'timestamp': datetime.now().isoformat(),
|
})
|
||||||
'level': 'info',
|
|
||||||
'service': 'pveproxy',
|
|
||||||
'message': 'User root@pam authenticated successfully',
|
|
||||||
'source': 'auth.log'
|
|
||||||
}
|
|
||||||
])
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error getting logs: {e}")
|
print(f"Error getting logs: {e}")
|
||||||
return jsonify([])
|
return jsonify({
|
||||||
|
'error': f'Unable to access system logs: {str(e)}',
|
||||||
|
'logs': []
|
||||||
|
})
|
||||||
|
|
||||||
@app.route('/api/health', methods=['GET'])
|
@app.route('/api/health', methods=['GET'])
|
||||||
def api_health():
|
def api_health():
|
||||||
@@ -574,9 +512,9 @@ def api_system_info():
|
|||||||
try:
|
try:
|
||||||
hostname = socket.gethostname()
|
hostname = socket.gethostname()
|
||||||
node_id = f"pve-{hostname}"
|
node_id = f"pve-{hostname}"
|
||||||
|
pve_version = None
|
||||||
|
|
||||||
# Try to get Proxmox version and node info
|
# Try to get Proxmox version
|
||||||
pve_version = "PVE 8.1.3"
|
|
||||||
try:
|
try:
|
||||||
result = subprocess.run(['pveversion'], capture_output=True, text=True, timeout=5)
|
result = subprocess.run(['pveversion'], capture_output=True, text=True, timeout=5)
|
||||||
if result.returncode == 0:
|
if result.returncode == 0:
|
||||||
@@ -597,20 +535,25 @@ def api_system_info():
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return jsonify({
|
response = {
|
||||||
'hostname': hostname,
|
'hostname': hostname,
|
||||||
'node_id': node_id,
|
'node_id': node_id,
|
||||||
'pve_version': pve_version,
|
|
||||||
'status': 'online',
|
'status': 'online',
|
||||||
'timestamp': datetime.now().isoformat()
|
'timestamp': datetime.now().isoformat()
|
||||||
})
|
}
|
||||||
|
|
||||||
|
if pve_version:
|
||||||
|
response['pve_version'] = pve_version
|
||||||
|
else:
|
||||||
|
response['error'] = 'Proxmox version not available - pveversion command not found'
|
||||||
|
|
||||||
|
return jsonify(response)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error getting system info: {e}")
|
print(f"Error getting system info: {e}")
|
||||||
return jsonify({
|
return jsonify({
|
||||||
'hostname': 'proxmox-01',
|
'error': f'Unable to access system information: {str(e)}',
|
||||||
'node_id': 'pve-node-01',
|
'hostname': socket.gethostname(),
|
||||||
'pve_version': 'PVE 8.1.3',
|
'status': 'error',
|
||||||
'status': 'online',
|
|
||||||
'timestamp': datetime.now().isoformat()
|
'timestamp': datetime.now().isoformat()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -632,15 +575,8 @@ def api_info():
|
|||||||
})
|
})
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print("🚀 Starting ProxMenux Flask Server on port 8008...")
|
print("Starting ProxMenux Flask Server on port 8008...")
|
||||||
print("📊 Dashboard: http://localhost:8008")
|
print("Server will be accessible on all network interfaces (0.0.0.0:8008)")
|
||||||
print("🔌 API endpoints:")
|
print("API endpoints available at: /api/system, /api/storage, /api/network, /api/vms, /api/logs, /api/health")
|
||||||
print(" http://localhost:8008/api/system")
|
|
||||||
print(" http://localhost:8008/api/system-info")
|
|
||||||
print(" http://localhost:8008/api/storage")
|
|
||||||
print(" http://localhost:8008/api/network")
|
|
||||||
print(" http://localhost:8008/api/vms")
|
|
||||||
print(" http://localhost:8008/api/logs")
|
|
||||||
print(" http://localhost:8008/api/health")
|
|
||||||
|
|
||||||
app.run(host='0.0.0.0', port=8008, debug=False)
|
app.run(host='0.0.0.0', port=8008, debug=False)
|
||||||
|
Reference in New Issue
Block a user