2025-09-28 23:09:31 +02:00
|
|
|
"use client"
|
|
|
|
|
2025-09-29 17:05:42 +02:00
|
|
|
import { useState, useEffect } from "react"
|
2025-09-28 23:09:31 +02:00
|
|
|
import { Card, CardContent, CardHeader, CardTitle } from "./ui/card"
|
|
|
|
import { Progress } from "./ui/progress"
|
|
|
|
import { Badge } from "./ui/badge"
|
2025-10-02 19:34:53 +02:00
|
|
|
import { Cpu, MemoryStick, Thermometer, Server, Zap, AlertCircle, HardDrive, Network } from "lucide-react"
|
2025-09-28 23:09:31 +02:00
|
|
|
|
2025-09-29 17:05:42 +02:00
|
|
|
interface SystemData {
|
|
|
|
cpu_usage: number
|
|
|
|
memory_usage: number
|
|
|
|
memory_total: number
|
|
|
|
memory_used: number
|
|
|
|
temperature: number
|
|
|
|
uptime: string
|
|
|
|
load_average: number[]
|
|
|
|
hostname: string
|
|
|
|
node_id: string
|
|
|
|
timestamp: string
|
2025-10-02 18:11:00 +02:00
|
|
|
cpu_cores?: number
|
2025-10-02 18:28:36 +02:00
|
|
|
proxmox_version?: string
|
|
|
|
kernel_version?: string
|
|
|
|
available_updates?: number
|
2025-09-29 17:05:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
interface VMData {
|
|
|
|
vmid: number
|
|
|
|
name: string
|
|
|
|
status: string
|
|
|
|
cpu: number
|
|
|
|
mem: number
|
|
|
|
maxmem: number
|
|
|
|
disk: number
|
|
|
|
maxdisk: number
|
|
|
|
uptime: number
|
2025-10-02 17:49:40 +02:00
|
|
|
type?: string
|
2025-09-29 17:05:42 +02:00
|
|
|
}
|
|
|
|
|
2025-10-02 19:34:53 +02:00
|
|
|
interface StorageData {
|
|
|
|
total: number
|
|
|
|
used: number
|
|
|
|
available: number
|
|
|
|
disks: Array<{
|
|
|
|
name: string
|
|
|
|
mountpoint: string
|
|
|
|
total: number
|
|
|
|
used: number
|
|
|
|
available: number
|
|
|
|
usage_percent: number
|
|
|
|
}>
|
2025-09-30 00:09:11 +02:00
|
|
|
}
|
|
|
|
|
2025-10-02 19:34:53 +02:00
|
|
|
interface NetworkData {
|
|
|
|
interfaces: Array<{
|
|
|
|
name: string
|
|
|
|
status: string
|
|
|
|
addresses: Array<{ ip: string; netmask: string }>
|
|
|
|
}>
|
|
|
|
traffic: {
|
|
|
|
bytes_sent: number
|
|
|
|
bytes_recv: number
|
|
|
|
packets_sent: number
|
|
|
|
packets_recv: number
|
|
|
|
}
|
|
|
|
}
|
2025-09-30 00:09:11 +02:00
|
|
|
|
|
|
|
const fetchSystemData = async (): Promise<SystemData | null> => {
|
2025-09-29 18:27:09 +02:00
|
|
|
try {
|
2025-10-01 18:08:31 +02:00
|
|
|
const baseUrl = typeof window !== "undefined" ? `${window.location.protocol}//${window.location.hostname}:8008` : ""
|
|
|
|
const apiUrl = `${baseUrl}/api/system`
|
2025-10-01 18:01:54 +02:00
|
|
|
|
|
|
|
const response = await fetch(apiUrl, {
|
2025-09-29 18:27:09 +02:00
|
|
|
method: "GET",
|
|
|
|
headers: {
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
},
|
2025-10-01 18:01:54 +02:00
|
|
|
cache: "no-store",
|
2025-09-29 18:27:09 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
if (!response.ok) {
|
|
|
|
throw new Error(`Flask server responded with status: ${response.status}`)
|
|
|
|
}
|
|
|
|
|
2025-10-02 19:34:53 +02:00
|
|
|
const data = await response.json()
|
2025-09-30 00:09:11 +02:00
|
|
|
return data
|
2025-09-29 18:27:09 +02:00
|
|
|
} catch (error) {
|
2025-10-02 19:34:53 +02:00
|
|
|
console.error("[v0] Failed to fetch system data:", error)
|
2025-09-30 00:09:11 +02:00
|
|
|
return null
|
2025-09-29 18:27:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-09-30 00:09:11 +02:00
|
|
|
const fetchVMData = async (): Promise<VMData[]> => {
|
2025-09-29 18:27:09 +02:00
|
|
|
try {
|
2025-10-01 18:08:31 +02:00
|
|
|
const baseUrl = typeof window !== "undefined" ? `${window.location.protocol}//${window.location.hostname}:8008` : ""
|
|
|
|
const apiUrl = `${baseUrl}/api/vms`
|
2025-10-01 18:01:54 +02:00
|
|
|
|
|
|
|
const response = await fetch(apiUrl, {
|
2025-09-29 18:27:09 +02:00
|
|
|
method: "GET",
|
|
|
|
headers: {
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
},
|
2025-10-01 18:01:54 +02:00
|
|
|
cache: "no-store",
|
2025-09-29 18:27:09 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
if (!response.ok) {
|
|
|
|
throw new Error(`Flask server responded with status: ${response.status}`)
|
|
|
|
}
|
|
|
|
|
|
|
|
const data = await response.json()
|
2025-09-30 00:09:11 +02:00
|
|
|
return Array.isArray(data) ? data : data.vms || []
|
2025-09-29 18:27:09 +02:00
|
|
|
} catch (error) {
|
2025-10-02 19:34:53 +02:00
|
|
|
console.error("[v0] Failed to fetch VM data:", error)
|
2025-09-30 00:09:11 +02:00
|
|
|
return []
|
2025-09-29 18:27:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-10-02 19:34:53 +02:00
|
|
|
const fetchStorageData = async (): Promise<StorageData | null> => {
|
|
|
|
try {
|
|
|
|
const baseUrl = typeof window !== "undefined" ? `${window.location.protocol}//${window.location.hostname}:8008` : ""
|
|
|
|
const apiUrl = `${baseUrl}/api/storage`
|
|
|
|
|
|
|
|
const response = await fetch(apiUrl, {
|
|
|
|
method: "GET",
|
|
|
|
headers: {
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
},
|
|
|
|
cache: "no-store",
|
|
|
|
})
|
|
|
|
|
|
|
|
if (!response.ok) {
|
|
|
|
throw new Error(`Flask server responded with status: ${response.status}`)
|
|
|
|
}
|
|
|
|
|
|
|
|
const data = await response.json()
|
|
|
|
return data
|
|
|
|
} catch (error) {
|
|
|
|
console.error("[v0] Failed to fetch storage data:", error)
|
|
|
|
return null
|
2025-09-29 17:05:42 +02:00
|
|
|
}
|
2025-10-02 19:34:53 +02:00
|
|
|
}
|
2025-09-29 17:05:42 +02:00
|
|
|
|
2025-10-02 19:34:53 +02:00
|
|
|
const fetchNetworkData = async (): Promise<NetworkData | null> => {
|
|
|
|
try {
|
|
|
|
const baseUrl = typeof window !== "undefined" ? `${window.location.protocol}//${window.location.hostname}:8008` : ""
|
|
|
|
const apiUrl = `${baseUrl}/api/network`
|
2025-09-30 00:09:11 +02:00
|
|
|
|
2025-10-02 19:34:53 +02:00
|
|
|
const response = await fetch(apiUrl, {
|
|
|
|
method: "GET",
|
|
|
|
headers: {
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
},
|
|
|
|
cache: "no-store",
|
|
|
|
})
|
|
|
|
|
|
|
|
if (!response.ok) {
|
|
|
|
throw new Error(`Flask server responded with status: ${response.status}`)
|
|
|
|
}
|
2025-09-30 00:09:11 +02:00
|
|
|
|
2025-10-02 19:34:53 +02:00
|
|
|
const data = await response.json()
|
|
|
|
return data
|
|
|
|
} catch (error) {
|
|
|
|
console.error("[v0] Failed to fetch network data:", error)
|
|
|
|
return null
|
|
|
|
}
|
2025-09-29 17:57:00 +02:00
|
|
|
}
|
2025-09-29 17:05:42 +02:00
|
|
|
|
2025-09-29 17:57:00 +02:00
|
|
|
export function SystemOverview() {
|
2025-09-29 18:27:09 +02:00
|
|
|
const [systemData, setSystemData] = useState<SystemData | null>(null)
|
|
|
|
const [vmData, setVmData] = useState<VMData[]>([])
|
2025-10-02 19:34:53 +02:00
|
|
|
const [storageData, setStorageData] = useState<StorageData | null>(null)
|
|
|
|
const [networkData, setNetworkData] = useState<NetworkData | null>(null)
|
2025-09-29 17:57:00 +02:00
|
|
|
const [loading, setLoading] = useState(true)
|
2025-09-30 00:09:11 +02:00
|
|
|
const [error, setError] = useState<string | null>(null)
|
2025-09-29 17:05:42 +02:00
|
|
|
|
2025-09-29 22:59:10 +02:00
|
|
|
useEffect(() => {
|
|
|
|
const fetchData = async () => {
|
|
|
|
try {
|
|
|
|
setLoading(true)
|
2025-09-30 00:09:11 +02:00
|
|
|
setError(null)
|
2025-09-29 22:59:10 +02:00
|
|
|
|
2025-10-02 19:51:53 +02:00
|
|
|
const systemResult = await fetchSystemData()
|
2025-09-29 22:59:10 +02:00
|
|
|
|
2025-09-30 00:09:11 +02:00
|
|
|
if (!systemResult) {
|
|
|
|
setError("Flask server not available. Please ensure the server is running.")
|
|
|
|
setLoading(false)
|
|
|
|
return
|
2025-09-29 22:59:10 +02:00
|
|
|
}
|
2025-09-30 00:09:11 +02:00
|
|
|
|
|
|
|
setSystemData(systemResult)
|
2025-09-29 22:59:10 +02:00
|
|
|
} catch (err) {
|
2025-10-02 19:51:53 +02:00
|
|
|
console.error("[v0] Error fetching system data:", err)
|
2025-09-30 00:09:11 +02:00
|
|
|
setError("Failed to connect to Flask server. Please check your connection.")
|
2025-09-29 22:59:10 +02:00
|
|
|
} finally {
|
|
|
|
setLoading(false)
|
2025-09-29 18:27:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fetchData()
|
2025-09-29 17:05:42 +02:00
|
|
|
|
2025-10-02 19:51:53 +02:00
|
|
|
const systemInterval = setInterval(() => {
|
|
|
|
fetchSystemData().then((data) => {
|
|
|
|
if (data) setSystemData(data)
|
|
|
|
})
|
|
|
|
}, 10000)
|
2025-09-29 17:05:42 +02:00
|
|
|
|
2025-09-29 17:57:00 +02:00
|
|
|
return () => {
|
2025-10-02 19:51:53 +02:00
|
|
|
clearInterval(systemInterval)
|
|
|
|
}
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
const fetchVMs = async () => {
|
|
|
|
const vmResult = await fetchVMData()
|
|
|
|
setVmData(vmResult)
|
|
|
|
}
|
|
|
|
|
|
|
|
fetchVMs()
|
|
|
|
const vmInterval = setInterval(fetchVMs, 15000)
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
clearInterval(vmInterval)
|
|
|
|
}
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
const fetchStorage = async () => {
|
|
|
|
const storageResult = await fetchStorageData()
|
|
|
|
setStorageData(storageResult)
|
|
|
|
}
|
|
|
|
|
|
|
|
fetchStorage()
|
|
|
|
const storageInterval = setInterval(fetchStorage, 15000)
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
clearInterval(storageInterval)
|
|
|
|
}
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
const fetchNetwork = async () => {
|
|
|
|
const networkResult = await fetchNetworkData()
|
|
|
|
setNetworkData(networkResult)
|
|
|
|
}
|
|
|
|
|
|
|
|
fetchNetwork()
|
|
|
|
const networkInterval = setInterval(fetchNetwork, 15000)
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
clearInterval(networkInterval)
|
2025-09-29 17:57:00 +02:00
|
|
|
}
|
2025-09-30 00:09:11 +02:00
|
|
|
}, [])
|
2025-09-29 17:05:42 +02:00
|
|
|
|
|
|
|
if (loading) {
|
|
|
|
return (
|
2025-09-29 22:59:10 +02:00
|
|
|
<div className="space-y-6">
|
|
|
|
<div className="text-center py-8">
|
|
|
|
<div className="text-lg font-medium text-foreground mb-2">Connecting to ProxMenux Monitor...</div>
|
|
|
|
<div className="text-sm text-muted-foreground">Fetching real-time system data</div>
|
|
|
|
</div>
|
|
|
|
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
|
|
|
|
{[...Array(4)].map((_, i) => (
|
|
|
|
<Card key={i} className="bg-card border-border animate-pulse">
|
|
|
|
<CardContent className="p-6">
|
|
|
|
<div className="h-4 bg-muted rounded w-1/2 mb-4"></div>
|
|
|
|
<div className="h-8 bg-muted rounded w-3/4 mb-2"></div>
|
|
|
|
<div className="h-2 bg-muted rounded w-full mb-2"></div>
|
|
|
|
<div className="h-3 bg-muted rounded w-2/3"></div>
|
|
|
|
</CardContent>
|
|
|
|
</Card>
|
|
|
|
))}
|
2025-09-29 17:05:42 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2025-09-30 00:09:11 +02:00
|
|
|
if (error || !systemData) {
|
|
|
|
return (
|
|
|
|
<div className="space-y-6">
|
|
|
|
<Card className="bg-red-500/10 border-red-500/20">
|
|
|
|
<CardContent className="p-6">
|
|
|
|
<div className="flex items-center gap-3 text-red-600">
|
|
|
|
<AlertCircle className="h-6 w-6" />
|
|
|
|
<div>
|
|
|
|
<div className="font-semibold text-lg mb-1">Flask Server Not Available</div>
|
|
|
|
<div className="text-sm">
|
|
|
|
{error || "Unable to connect to the Flask server. Please ensure the server is running and try again."}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</CardContent>
|
|
|
|
</Card>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
2025-09-29 18:27:09 +02:00
|
|
|
|
|
|
|
const vmStats = {
|
|
|
|
total: vmData.length,
|
|
|
|
running: vmData.filter((vm) => vm.status === "running").length,
|
|
|
|
stopped: vmData.filter((vm) => vm.status === "stopped").length,
|
2025-10-02 17:49:40 +02:00
|
|
|
lxc: vmData.filter((vm) => vm.type === "lxc").length,
|
|
|
|
vms: vmData.filter((vm) => vm.type === "qemu" || !vm.type).length,
|
2025-09-29 18:27:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const getTemperatureStatus = (temp: number) => {
|
2025-09-30 00:09:11 +02:00
|
|
|
if (temp === 0) return { status: "N/A", color: "bg-gray-500/10 text-gray-500 border-gray-500/20" }
|
2025-09-29 22:59:10 +02:00
|
|
|
if (temp < 60) return { status: "Normal", color: "bg-green-500/10 text-green-500 border-green-500/20" }
|
|
|
|
if (temp < 75) return { status: "Warm", color: "bg-yellow-500/10 text-yellow-500 border-yellow-500/20" }
|
|
|
|
return { status: "Hot", color: "bg-red-500/10 text-red-500 border-red-500/20" }
|
2025-09-29 18:27:09 +02:00
|
|
|
}
|
|
|
|
|
2025-09-29 17:05:42 +02:00
|
|
|
const tempStatus = getTemperatureStatus(systemData.temperature)
|
|
|
|
|
2025-09-28 23:09:31 +02:00
|
|
|
return (
|
2025-09-29 22:59:10 +02:00
|
|
|
<div className="space-y-6">
|
|
|
|
{/* Key Metrics Cards */}
|
|
|
|
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
|
2025-09-30 00:09:11 +02:00
|
|
|
<Card className="bg-card border-border">
|
2025-09-29 22:59:10 +02:00
|
|
|
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
|
|
|
<CardTitle className="text-sm font-medium text-muted-foreground">CPU Usage</CardTitle>
|
|
|
|
<Cpu className="h-4 w-4 text-muted-foreground" />
|
|
|
|
</CardHeader>
|
|
|
|
<CardContent>
|
2025-09-30 00:09:11 +02:00
|
|
|
<div className="text-2xl font-bold text-foreground">{systemData.cpu_usage}%</div>
|
2025-09-29 22:59:10 +02:00
|
|
|
<Progress value={systemData.cpu_usage} className="mt-2" />
|
2025-09-30 00:09:11 +02:00
|
|
|
<p className="text-xs text-muted-foreground mt-2">Real-time data from Flask server</p>
|
2025-09-29 22:59:10 +02:00
|
|
|
</CardContent>
|
|
|
|
</Card>
|
|
|
|
|
2025-09-30 00:09:11 +02:00
|
|
|
<Card className="bg-card border-border">
|
2025-09-29 22:59:10 +02:00
|
|
|
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
|
|
|
<CardTitle className="text-sm font-medium text-muted-foreground">Memory Usage</CardTitle>
|
|
|
|
<MemoryStick className="h-4 w-4 text-muted-foreground" />
|
|
|
|
</CardHeader>
|
|
|
|
<CardContent>
|
2025-09-30 00:09:11 +02:00
|
|
|
<div className="text-2xl font-bold text-foreground">{systemData.memory_used.toFixed(1)} GB</div>
|
2025-09-29 22:59:10 +02:00
|
|
|
<Progress value={systemData.memory_usage} className="mt-2" />
|
2025-09-30 00:09:11 +02:00
|
|
|
<p className="text-xs text-muted-foreground mt-2">
|
2025-09-29 22:59:10 +02:00
|
|
|
{systemData.memory_usage.toFixed(1)}% of {systemData.memory_total} GB
|
|
|
|
</p>
|
|
|
|
</CardContent>
|
|
|
|
</Card>
|
|
|
|
|
2025-09-30 00:09:11 +02:00
|
|
|
<Card className="bg-card border-border">
|
2025-09-29 22:59:10 +02:00
|
|
|
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
|
|
|
<CardTitle className="text-sm font-medium text-muted-foreground">Temperature</CardTitle>
|
|
|
|
<Thermometer className="h-4 w-4 text-muted-foreground" />
|
|
|
|
</CardHeader>
|
|
|
|
<CardContent>
|
2025-09-30 00:09:11 +02:00
|
|
|
<div className="text-2xl font-bold text-foreground">
|
|
|
|
{systemData.temperature === 0 ? "N/A" : `${systemData.temperature}°C`}
|
|
|
|
</div>
|
2025-09-29 22:59:10 +02:00
|
|
|
<div className="flex items-center mt-2">
|
|
|
|
<Badge variant="outline" className={tempStatus.color}>
|
|
|
|
{tempStatus.status}
|
|
|
|
</Badge>
|
|
|
|
</div>
|
2025-09-30 00:09:11 +02:00
|
|
|
<p className="text-xs text-muted-foreground mt-2">
|
|
|
|
{systemData.temperature === 0 ? "No sensor available" : "Live temperature reading"}
|
2025-09-29 22:59:10 +02:00
|
|
|
</p>
|
|
|
|
</CardContent>
|
|
|
|
</Card>
|
|
|
|
|
2025-09-30 00:09:11 +02:00
|
|
|
<Card className="bg-card border-border">
|
2025-09-29 22:59:10 +02:00
|
|
|
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
2025-10-02 17:49:40 +02:00
|
|
|
<CardTitle className="text-sm font-medium text-muted-foreground">Active VM & LXC</CardTitle>
|
2025-09-29 22:59:10 +02:00
|
|
|
<Server className="h-4 w-4 text-muted-foreground" />
|
|
|
|
</CardHeader>
|
|
|
|
<CardContent>
|
2025-09-30 00:09:11 +02:00
|
|
|
<div className="text-2xl font-bold text-foreground">{vmStats.running}</div>
|
|
|
|
<div className="mt-2 flex flex-wrap gap-1">
|
|
|
|
<Badge variant="outline" className="bg-green-500/10 text-green-500 border-green-500/20">
|
2025-09-29 22:59:10 +02:00
|
|
|
{vmStats.running} Running
|
|
|
|
</Badge>
|
|
|
|
{vmStats.stopped > 0 && (
|
2025-09-30 00:09:11 +02:00
|
|
|
<Badge variant="outline" className="bg-yellow-500/10 text-yellow-500 border-yellow-500/20">
|
2025-09-29 22:59:10 +02:00
|
|
|
{vmStats.stopped} Stopped
|
2025-09-29 22:38:25 +02:00
|
|
|
</Badge>
|
2025-09-29 22:59:10 +02:00
|
|
|
)}
|
|
|
|
</div>
|
2025-10-02 17:49:40 +02:00
|
|
|
<p className="text-xs text-muted-foreground mt-2">
|
|
|
|
Total: {vmStats.vms} VMs, {vmStats.lxc} LXC
|
|
|
|
</p>
|
2025-09-29 22:59:10 +02:00
|
|
|
</CardContent>
|
|
|
|
</Card>
|
|
|
|
</div>
|
2025-09-28 23:09:31 +02:00
|
|
|
|
2025-09-29 22:59:10 +02:00
|
|
|
<div className="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
2025-10-02 19:34:53 +02:00
|
|
|
{/* Storage Summary */}
|
2025-09-30 00:09:11 +02:00
|
|
|
<Card className="bg-card border-border">
|
2025-09-29 22:59:10 +02:00
|
|
|
<CardHeader>
|
|
|
|
<CardTitle className="text-foreground flex items-center">
|
2025-10-02 19:34:53 +02:00
|
|
|
<HardDrive className="h-5 w-5 mr-2" />
|
|
|
|
Storage Overview
|
2025-09-29 22:59:10 +02:00
|
|
|
</CardTitle>
|
|
|
|
</CardHeader>
|
|
|
|
<CardContent>
|
2025-10-02 19:34:53 +02:00
|
|
|
{storageData ? (
|
|
|
|
<div className="space-y-4">
|
|
|
|
<div className="flex justify-between items-center">
|
|
|
|
<span className="text-sm text-muted-foreground">Total Storage:</span>
|
|
|
|
<span className="text-lg font-semibold text-foreground">{storageData.total} GB</span>
|
|
|
|
</div>
|
|
|
|
<div className="flex justify-between items-center">
|
|
|
|
<span className="text-sm text-muted-foreground">Used:</span>
|
|
|
|
<span className="text-lg font-semibold text-foreground">{storageData.used} GB</span>
|
|
|
|
</div>
|
|
|
|
<div className="flex justify-between items-center">
|
|
|
|
<span className="text-sm text-muted-foreground">Available:</span>
|
|
|
|
<span className="text-lg font-semibold text-green-500">{storageData.available} GB</span>
|
|
|
|
</div>
|
|
|
|
<Progress value={(storageData.used / storageData.total) * 100} className="mt-2" />
|
|
|
|
<div className="pt-2 border-t border-border">
|
|
|
|
<p className="text-xs text-muted-foreground">
|
|
|
|
{storageData.disks.length} disk{storageData.disks.length !== 1 ? "s" : ""} configured
|
|
|
|
</p>
|
|
|
|
</div>
|
2025-09-30 00:09:11 +02:00
|
|
|
</div>
|
2025-10-02 19:34:53 +02:00
|
|
|
) : (
|
|
|
|
<div className="text-center py-8 text-muted-foreground">Storage data not available</div>
|
2025-09-30 00:09:11 +02:00
|
|
|
)}
|
2025-09-29 22:59:10 +02:00
|
|
|
</CardContent>
|
|
|
|
</Card>
|
|
|
|
|
2025-10-02 19:34:53 +02:00
|
|
|
{/* Network Summary */}
|
2025-09-30 00:09:11 +02:00
|
|
|
<Card className="bg-card border-border">
|
2025-09-29 22:59:10 +02:00
|
|
|
<CardHeader>
|
|
|
|
<CardTitle className="text-foreground flex items-center">
|
2025-10-02 19:34:53 +02:00
|
|
|
<Network className="h-5 w-5 mr-2" />
|
|
|
|
Network Overview
|
2025-09-29 22:59:10 +02:00
|
|
|
</CardTitle>
|
|
|
|
</CardHeader>
|
|
|
|
<CardContent>
|
2025-10-02 19:34:53 +02:00
|
|
|
{networkData ? (
|
|
|
|
<div className="space-y-4">
|
|
|
|
<div className="flex justify-between items-center">
|
|
|
|
<span className="text-sm text-muted-foreground">Active Interfaces:</span>
|
|
|
|
<span className="text-lg font-semibold text-foreground">
|
|
|
|
{networkData.interfaces.filter((i) => i.status === "up").length}
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
<div className="flex justify-between items-center">
|
|
|
|
<span className="text-sm text-muted-foreground">Data Sent:</span>
|
|
|
|
<span className="text-lg font-semibold text-foreground">
|
|
|
|
{(networkData.traffic.bytes_sent / 1024 ** 3).toFixed(2)} GB
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
<div className="flex justify-between items-center">
|
|
|
|
<span className="text-sm text-muted-foreground">Data Received:</span>
|
|
|
|
<span className="text-lg font-semibold text-foreground">
|
|
|
|
{(networkData.traffic.bytes_recv / 1024 ** 3).toFixed(2)} GB
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
<div className="pt-2 border-t border-border space-y-1">
|
|
|
|
{networkData.interfaces.slice(0, 3).map((iface) => (
|
|
|
|
<div key={iface.name} className="flex justify-between items-center">
|
|
|
|
<span className="text-xs text-muted-foreground">{iface.name}:</span>
|
|
|
|
<Badge
|
|
|
|
variant="outline"
|
|
|
|
className={
|
|
|
|
iface.status === "up"
|
|
|
|
? "bg-green-500/10 text-green-500 border-green-500/20"
|
|
|
|
: "bg-gray-500/10 text-gray-500 border-gray-500/20"
|
|
|
|
}
|
|
|
|
>
|
|
|
|
{iface.status}
|
|
|
|
</Badge>
|
|
|
|
</div>
|
|
|
|
))}
|
|
|
|
</div>
|
2025-09-30 00:09:11 +02:00
|
|
|
</div>
|
2025-10-02 19:34:53 +02:00
|
|
|
) : (
|
|
|
|
<div className="text-center py-8 text-muted-foreground">Network data not available</div>
|
2025-09-30 00:09:11 +02:00
|
|
|
)}
|
2025-09-29 22:59:10 +02:00
|
|
|
</CardContent>
|
|
|
|
</Card>
|
|
|
|
</div>
|
2025-09-28 23:09:31 +02:00
|
|
|
|
2025-09-29 22:59:10 +02:00
|
|
|
{/* System Information */}
|
2025-09-30 00:09:11 +02:00
|
|
|
<div className="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
|
|
|
<Card className="bg-card border-border">
|
2025-09-29 22:59:10 +02:00
|
|
|
<CardHeader>
|
|
|
|
<CardTitle className="text-foreground flex items-center">
|
|
|
|
<Server className="h-5 w-5 mr-2" />
|
|
|
|
System Information
|
|
|
|
</CardTitle>
|
|
|
|
</CardHeader>
|
|
|
|
<CardContent className="space-y-3">
|
|
|
|
<div className="flex justify-between">
|
2025-09-30 00:09:11 +02:00
|
|
|
<span className="text-muted-foreground">Uptime:</span>
|
|
|
|
<span className="text-foreground">{systemData.uptime}</span>
|
2025-09-29 22:59:10 +02:00
|
|
|
</div>
|
2025-10-02 18:11:00 +02:00
|
|
|
<div className="flex justify-between">
|
|
|
|
<span className="text-muted-foreground">Proxmox Version:</span>
|
2025-10-02 18:28:36 +02:00
|
|
|
<span className="text-foreground">{systemData.proxmox_version || "N/A"}</span>
|
2025-10-02 18:11:00 +02:00
|
|
|
</div>
|
|
|
|
<div className="flex justify-between">
|
|
|
|
<span className="text-muted-foreground">Kernel:</span>
|
2025-10-02 18:28:36 +02:00
|
|
|
<span className="text-foreground font-mono text-sm">{systemData.kernel_version || "Linux"}</span>
|
2025-10-02 18:11:00 +02:00
|
|
|
</div>
|
2025-10-02 18:28:36 +02:00
|
|
|
{systemData.available_updates !== undefined && systemData.available_updates > 0 && (
|
|
|
|
<div className="flex justify-between">
|
|
|
|
<span className="text-muted-foreground">Available Updates:</span>
|
|
|
|
<Badge variant="outline" className="bg-yellow-500/10 text-yellow-500 border-yellow-500/20">
|
|
|
|
{systemData.available_updates} packages
|
|
|
|
</Badge>
|
|
|
|
</div>
|
|
|
|
)}
|
2025-09-29 22:59:10 +02:00
|
|
|
</CardContent>
|
|
|
|
</Card>
|
|
|
|
|
2025-09-30 00:09:11 +02:00
|
|
|
<Card className="bg-card border-border">
|
2025-09-29 22:59:10 +02:00
|
|
|
<CardHeader>
|
|
|
|
<CardTitle className="text-foreground flex items-center">
|
2025-09-30 00:09:11 +02:00
|
|
|
<Zap className="h-5 w-5 mr-2" />
|
|
|
|
Performance Metrics
|
2025-09-29 22:59:10 +02:00
|
|
|
</CardTitle>
|
|
|
|
</CardHeader>
|
|
|
|
<CardContent className="space-y-3">
|
2025-10-02 18:11:00 +02:00
|
|
|
<div className="flex justify-between items-start">
|
|
|
|
<div className="flex flex-col">
|
|
|
|
<span className="text-muted-foreground">Load Average:</span>
|
|
|
|
<span className="text-xs text-muted-foreground">(1m, 5m, 15m)</span>
|
|
|
|
</div>
|
2025-09-30 00:09:11 +02:00
|
|
|
<span className="text-foreground font-mono">
|
|
|
|
{systemData.load_average.map((avg) => avg.toFixed(2)).join(", ")}
|
|
|
|
</span>
|
2025-09-29 22:59:10 +02:00
|
|
|
</div>
|
|
|
|
<div className="flex justify-between">
|
2025-09-30 00:09:11 +02:00
|
|
|
<span className="text-muted-foreground">Total Memory:</span>
|
|
|
|
<span className="text-foreground">{systemData.memory_total} GB</span>
|
2025-09-29 22:59:10 +02:00
|
|
|
</div>
|
|
|
|
<div className="flex justify-between">
|
2025-09-30 00:09:11 +02:00
|
|
|
<span className="text-muted-foreground">Available Memory:</span>
|
|
|
|
<span className="text-foreground">
|
|
|
|
{(systemData.memory_total - systemData.memory_used).toFixed(1)} GB
|
2025-09-29 22:59:10 +02:00
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
<div className="flex justify-between">
|
2025-09-30 00:09:11 +02:00
|
|
|
<span className="text-muted-foreground">CPU Cores:</span>
|
2025-10-02 18:11:00 +02:00
|
|
|
<span className="text-foreground">{systemData.cpu_cores || "N/A"}</span>
|
2025-09-29 22:59:10 +02:00
|
|
|
</div>
|
|
|
|
</CardContent>
|
|
|
|
</Card>
|
2025-09-28 23:09:31 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|