mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-11-17 19:16:25 +00:00
Update AppImage
This commit is contained in:
@@ -51,6 +51,13 @@ interface FlaskSystemData {
|
|||||||
load_average: number[]
|
load_average: number[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface FlaskSystemInfo {
|
||||||
|
hostname: string
|
||||||
|
node_id: string
|
||||||
|
uptime: string
|
||||||
|
health_status: "healthy" | "warning" | "critical"
|
||||||
|
}
|
||||||
|
|
||||||
export function ProxmoxDashboard() {
|
export function ProxmoxDashboard() {
|
||||||
const [systemStatus, setSystemStatus] = useState<SystemStatus>({
|
const [systemStatus, setSystemStatus] = useState<SystemStatus>({
|
||||||
status: "healthy",
|
status: "healthy",
|
||||||
@@ -69,12 +76,7 @@ export function ProxmoxDashboard() {
|
|||||||
const [showHealthModal, setShowHealthModal] = useState(false)
|
const [showHealthModal, setShowHealthModal] = useState(false)
|
||||||
|
|
||||||
const fetchSystemData = useCallback(async () => {
|
const fetchSystemData = useCallback(async () => {
|
||||||
console.log("[v0] Fetching system data from Flask server...")
|
const apiUrl = getApiUrl("/api/system-info")
|
||||||
console.log("[v0] Current window location:", window.location.href)
|
|
||||||
|
|
||||||
const apiUrl = getApiUrl("/api/system")
|
|
||||||
|
|
||||||
console.log("[v0] API URL:", apiUrl)
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(apiUrl, {
|
const response = await fetch(apiUrl, {
|
||||||
@@ -84,27 +86,18 @@ export function ProxmoxDashboard() {
|
|||||||
},
|
},
|
||||||
cache: "no-store",
|
cache: "no-store",
|
||||||
})
|
})
|
||||||
console.log("[v0] Response status:", response.status)
|
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(`Server responded with status: ${response.status}`)
|
throw new Error(`Server responded with status: ${response.status}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
const data: FlaskSystemData = await response.json()
|
const data: FlaskSystemInfo = await response.json()
|
||||||
console.log("[v0] System data received:", data)
|
|
||||||
|
|
||||||
let status: "healthy" | "warning" | "critical" = "healthy"
|
|
||||||
if (data.cpu_usage > 90 || data.memory_usage > 90) {
|
|
||||||
status = "critical"
|
|
||||||
} else if (data.cpu_usage > 75 || data.memory_usage > 75) {
|
|
||||||
status = "warning"
|
|
||||||
}
|
|
||||||
|
|
||||||
const uptimeValue =
|
const uptimeValue =
|
||||||
data.uptime && typeof data.uptime === "string" && data.uptime.trim() !== "" ? data.uptime : "N/A"
|
data.uptime && typeof data.uptime === "string" && data.uptime.trim() !== "" ? data.uptime : "N/A"
|
||||||
|
|
||||||
setSystemStatus({
|
setSystemStatus({
|
||||||
status,
|
status: data.health_status || "healthy",
|
||||||
uptime: uptimeValue,
|
uptime: uptimeValue,
|
||||||
lastUpdate: new Date().toLocaleTimeString("en-US", { hour12: false }),
|
lastUpdate: new Date().toLocaleTimeString("en-US", { hour12: false }),
|
||||||
serverName: data.hostname || "Unknown",
|
serverName: data.hostname || "Unknown",
|
||||||
@@ -113,11 +106,6 @@ export function ProxmoxDashboard() {
|
|||||||
setIsServerConnected(true)
|
setIsServerConnected(true)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("[v0] Failed to fetch system data from Flask server:", error)
|
console.error("[v0] Failed to fetch system data from Flask server:", error)
|
||||||
console.error("[v0] Error details:", {
|
|
||||||
message: error instanceof Error ? error.message : "Unknown error",
|
|
||||||
apiUrl,
|
|
||||||
windowLocation: window.location.href,
|
|
||||||
})
|
|
||||||
|
|
||||||
setIsServerConnected(false)
|
setIsServerConnected(false)
|
||||||
setSystemStatus((prev) => ({
|
setSystemStatus((prev) => ({
|
||||||
|
|||||||
@@ -24,3 +24,16 @@ def get_health_details():
|
|||||||
return jsonify(details)
|
return jsonify(details)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return jsonify({'error': str(e)}), 500
|
return jsonify({'error': str(e)}), 500
|
||||||
|
|
||||||
|
@health_bp.route('/api/system-info', methods=['GET'])
|
||||||
|
def get_system_info():
|
||||||
|
"""
|
||||||
|
Get lightweight system info for header display.
|
||||||
|
Returns: hostname, uptime, and cached health status.
|
||||||
|
This is optimized for minimal server impact.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
info = health_monitor.get_system_info()
|
||||||
|
return jsonify(info)
|
||||||
|
except Exception as e:
|
||||||
|
return jsonify({'error': str(e)}), 500
|
||||||
|
|||||||
@@ -5655,57 +5655,6 @@ def api_prometheus():
|
|||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
return f'# Error generating metrics: {str(e)}\n', 500, {'Content-Type': 'text/plain; charset=utf-8'}
|
return f'# Error generating metrics: {str(e)}\n', 500, {'Content-Type': 'text/plain; charset=utf-8'}
|
||||||
|
|
||||||
@app.route('/api/system-info', methods=['GET'])
|
|
||||||
def api_system_info():
|
|
||||||
"""Get system and node information for dashboard header"""
|
|
||||||
try:
|
|
||||||
hostname = socket.gethostname()
|
|
||||||
node_id = f"pve-{hostname}"
|
|
||||||
pve_version = None
|
|
||||||
|
|
||||||
# Try to get Proxmox version
|
|
||||||
try:
|
|
||||||
result = subprocess.run(['pveversion'], capture_output=True, text=True, timeout=5)
|
|
||||||
if result.returncode == 0:
|
|
||||||
pve_version = result.stdout.strip().split('\n')[0]
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# Try to get node info from Proxmox API
|
|
||||||
try:
|
|
||||||
result = subprocess.run(['pvesh', 'get', '/nodes', '--output-format', 'json'],
|
|
||||||
capture_output=True, text=True, timeout=5)
|
|
||||||
if result.returncode == 0:
|
|
||||||
nodes = json.loads(result.stdout)
|
|
||||||
if nodes and len(nodes) > 0:
|
|
||||||
node_info = nodes[0]
|
|
||||||
node_id = node_info.get('node', node_id)
|
|
||||||
hostname = node_info.get('node', hostname)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
response = {
|
|
||||||
'hostname': hostname,
|
|
||||||
'node_id': node_id,
|
|
||||||
'status': 'online',
|
|
||||||
'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:
|
|
||||||
# print(f"Error getting system info: {e}")
|
|
||||||
pass
|
|
||||||
return jsonify({
|
|
||||||
'error': f'Unable to access system information: {str(e)}',
|
|
||||||
'hostname': socket.gethostname(),
|
|
||||||
'status': 'error',
|
|
||||||
'timestamp': datetime.now().isoformat()
|
|
||||||
})
|
|
||||||
|
|
||||||
@app.route('/api/info', methods=['GET'])
|
@app.route('/api/info', methods=['GET'])
|
||||||
def api_info():
|
def api_info():
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user