Spaces:
Sleeping
Sleeping
Download frontend/index.html from xunwei/linux_monitor: direct link, hf CLI and curl.
- Browser
- Download file 15.8 kB
-
https://huggingface.co/spaces/xunwei/linux_monitor/resolve/main/frontend/index.html
- Command line
-
hf download hf://spaces/xunwei/linux_monitor/frontend/index.html
-
curl -L -o index.html https://huggingface.co/spaces/xunwei/linux_monitor/resolve/main/frontend/index.html
15.8 kB
| <html lang="zh-TW"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Linux Monitor | System Intelligence</title> | |
| <!-- Tailwind CSS, Vue 3 & ECharts via CDN --> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> | |
| <script src="https://cdn.jsdelivr.net/npm/echarts@5.4.3/dist/echarts.min.js"></script> | |
| <!-- Fonts --> | |
| <link rel="preconnect" href="https://fonts.googleapis.com"> | |
| <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> | |
| <link href="https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;600&family=Fira+Sans:wght@300;400;600&display=swap" rel="stylesheet"> | |
| <script> | |
| tailwind.config = { | |
| theme: { | |
| extend: { | |
| colors: { | |
| dark: '#0D0D0D', | |
| glass: 'rgba(255, 255, 255, 0.05)', | |
| 'glass-border': 'rgba(255, 255, 255, 0.1)', | |
| primary: '#1E40AF', | |
| secondary: '#3B82F6', | |
| accent: '#F59E0B', | |
| success: '#22C55E', | |
| danger: '#EF4444', | |
| warning: '#F59E0B', | |
| }, | |
| fontFamily: { | |
| sans: ['Fira Sans', 'sans-serif'], | |
| mono: ['Fira Code', 'monospace'], | |
| }, | |
| animation: { | |
| 'pulse-slow': 'pulse 3s cubic-bezier(0.4, 0, 0.6, 1) infinite', | |
| } | |
| } | |
| } | |
| } | |
| </script> | |
| <style> | |
| body { | |
| background-color: #0D0D0D; | |
| color: #E0E0E0; | |
| font-family: 'Fira Sans', sans-serif; | |
| background-image: | |
| radial-gradient(at 0% 0%, rgba(30, 64, 175, 0.15) 0px, transparent 50%), | |
| radial-gradient(at 100% 100%, rgba(245, 158, 11, 0.1) 0px, transparent 50%); | |
| min-height: 100vh; | |
| } | |
| .glass-card { | |
| background: rgba(255, 255, 255, 0.03); | |
| backdrop-filter: blur(12px); | |
| -webkit-backdrop-filter: blur(12px); | |
| border: 1px solid rgba(255, 255, 255, 0.08); | |
| box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37); | |
| transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); | |
| } | |
| .glass-card:hover { | |
| background: rgba(255, 255, 255, 0.06); | |
| border-color: rgba(255, 255, 255, 0.15); | |
| transform: translateY(-2px); | |
| } | |
| .status-pulse { | |
| box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); | |
| animation: pulse-green 2s infinite; | |
| } | |
| @keyframes pulse-green { | |
| 0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); } | |
| 70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); } | |
| 100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); } | |
| } | |
| .status-pulse-red { | |
| animation: pulse-red 2s infinite; | |
| } | |
| @keyframes pulse-red { | |
| 0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); } | |
| 70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); } | |
| 100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); } | |
| } | |
| /* ECharts responsiveness */ | |
| .chart-container { width: 100% ; } | |
| </style> | |
| </head> | |
| <body class="p-4 md:p-8"> | |
| <div id="app" v-cloak> | |
| <!-- Header --> | |
| <header class="flex flex-col md:flex-row justify-between items-start md:items-center mb-8 gap-4"> | |
| <div> | |
| <h1 class="text-3xl font-bold font-mono tracking-tight text-white flex items-center gap-3"> | |
| <svg class="size-8 text-secondary" fill="none" stroke="currentColor" viewBox="0 0 24 24"> | |
| <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 3v2m6-2v2M9 19v2m6-2v2M5 9H3m2 6H3m18-6h-2m2 6h-2M7 19h10a2 2 0 002-2V7a2 2 0 00-2-2H7a2 2 0 00-2 2v10a2 2 0 002 2zM9 9h6v6H9V9z" /> | |
| </svg> | |
| LINUX_MONITOR | |
| <span class="text-xs font-normal px-2 py-0.5 rounded border border-glass-border bg-glass text-gray-400">v1.0.0-PRO</span> | |
| </h1> | |
| <p class="text-gray-500 text-sm mt-1 font-sans">Real-time system intelligence and resource analytics</p> | |
| </div> | |
| <div class="flex items-center gap-4"> | |
| <div class="flex flex-col items-end"> | |
| <span class="text-[10px] uppercase tracking-widest text-gray-500 font-bold mb-1">System Status</span> | |
| <div :class="['flex items-center gap-2 px-3 py-1.5 rounded-full border transition-all duration-500', | |
| isConnected ? 'bg-success/10 border-success/30 text-success' : 'bg-danger/10 border-danger/30 text-danger']"> | |
| <span :class="['size-2 rounded-full', isConnected ? 'status-pulse bg-success' : 'status-pulse-red bg-danger']"></span> | |
| <span class="text-xs font-bold font-mono uppercase tracking-tighter">{{ isConnected ? 'Live' : 'Offline' }}</span> | |
| </div> | |
| </div> | |
| </div> | |
| </header> | |
| <!-- Bento Grid Dashboard --> | |
| <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6"> | |
| <!-- CPU Card --> | |
| <div class="glass-card rounded-2xl p-5 lg:col-span-2"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <div class="flex items-center gap-3"> | |
| <div class="p-2 rounded-lg bg-primary/20 text-secondary"> | |
| <svg class="size-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"> | |
| <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z" /> | |
| </svg> | |
| </div> | |
| <h2 class="font-bold text-white tracking-wide uppercase text-sm font-mono">CPU Utilization</h2> | |
| </div> | |
| <div class="text-xs font-mono text-gray-500 bg-black/30 px-2 py-1 rounded">60s WINDOW</div> | |
| </div> | |
| <div id="cpu-chart" class="chart-container h-[280px]"></div> | |
| </div> | |
| <!-- Memory Card --> | |
| <div class="glass-card rounded-2xl p-5 lg:col-span-2"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <div class="flex items-center gap-3"> | |
| <div class="p-2 rounded-lg bg-purple-500/20 text-purple-400"> | |
| <svg class="size-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"> | |
| <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 17V7m0 10a2 2 0 01-2 2H5a2 2 0 01-2-2V7a2 2 0 012-2h2a2 2 0 012 2m0 10a2 2 0 002 2h2a2 2 0 002-2V7a2 2 0 00-2-2h-2a2 2 0 00-2 2" /> | |
| </svg> | |
| </div> | |
| <h2 class="font-bold text-white tracking-wide uppercase text-sm font-mono">Memory Load</h2> | |
| </div> | |
| <div class="text-xs font-mono text-gray-500 bg-black/30 px-2 py-1 rounded">ECC ENABLED</div> | |
| </div> | |
| <div id="mem-chart" class="chart-container h-[280px]"></div> | |
| </div> | |
| <!-- Network Card --> | |
| <div class="glass-card rounded-2xl p-5 lg:col-span-2"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <div class="flex items-center gap-3"> | |
| <div class="p-2 rounded-lg bg-success/20 text-success"> | |
| <svg class="size-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"> | |
| <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4" /> | |
| </svg> | |
| </div> | |
| <h2 class="font-bold text-white tracking-wide uppercase text-sm font-mono">Network Throughput</h2> | |
| </div> | |
| <div class="text-xs font-mono text-gray-500 bg-black/30 px-2 py-1 rounded">eth0</div> | |
| </div> | |
| <div id="net-chart" class="chart-container h-[280px]"></div> | |
| </div> | |
| <!-- Disk Card --> | |
| <div class="glass-card rounded-2xl p-5 lg:col-span-2"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <div class="flex items-center gap-3"> | |
| <div class="p-2 rounded-lg bg-warning/20 text-warning"> | |
| <svg class="size-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"> | |
| <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 13V6a2 2 0 00-2-2H4a2 2 0 00-2 2v7m18 0a2 2 0 01-2 2H4a2 2 0 01-2-2m18 0l-2 2m-2-2l-2 2m-2-2l-2 2m-2-2l-2 2" /> | |
| </svg> | |
| </div> | |
| <h2 class="font-bold text-white tracking-wide uppercase text-sm font-mono">Storage I/O</h2> | |
| </div> | |
| <div class="text-xs font-mono text-gray-500 bg-black/30 px-2 py-1 rounded">NVMe</div> | |
| </div> | |
| <div id="disk-chart" class="chart-container h-[280px]"></div> | |
| </div> | |
| </div> | |
| </div> | |
| <script> | |
| const { createApp, ref, onMounted } = Vue; | |
| createApp({ | |
| setup() { | |
| const isConnected = ref(false); | |
| let ws = null; | |
| const charts = {}; | |
| const initChart = (id, title, color) => { | |
| const chart = echarts.init(document.getElementById(id), 'dark'); | |
| chart.setOption({ | |
| backgroundColor: 'transparent', | |
| tooltip: { | |
| trigger: 'axis', | |
| backgroundColor: 'rgba(13, 13, 13, 0.9)', | |
| borderColor: 'rgba(255, 255, 255, 0.1)', | |
| textStyle: { color: '#E0E0E0', fontFamily: 'Fira Code' } | |
| }, | |
| grid: { left: '2%', right: '2%', bottom: '5%', top: '10%', containLabel: true }, | |
| xAxis: { | |
| type: 'time', | |
| splitLine: { show: false }, | |
| axisLabel: { color: '#666', fontFamily: 'Fira Code', fontSize: 10 } | |
| }, | |
| yAxis: { | |
| type: 'value', | |
| boundaryGap: [0, '20%'], | |
| splitLine: { lineStyle: { color: 'rgba(255, 255, 255, 0.05)' } }, | |
| axisLabel: { color: '#666', fontFamily: 'Fira Code', fontSize: 10 } | |
| }, | |
| series: [{ | |
| name: title, | |
| type: 'line', | |
| smooth: true, | |
| showSymbol: false, | |
| data: [], | |
| itemStyle: { color: color }, | |
| lineStyle: { width: 3, cap: 'round' }, | |
| areaStyle: { | |
| color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ | |
| { offset: 0, color: color + '44' }, // 27% opacity | |
| { offset: 1, color: color + '00' } // 0% opacity | |
| ]) | |
| } | |
| }] | |
| }); | |
| window.addEventListener('resize', () => chart.resize()); | |
| return chart; | |
| }; | |
| const updateCharts = (metrics) => { | |
| const time = metrics.timestamp * 1000; | |
| // CPU | |
| charts.cpu.setOption({ | |
| series: [{ data: [...charts.cpu.getOption().series[0].data, [time, metrics.cpu.usage_percent]].slice(-60) }] | |
| }); | |
| // Memory | |
| charts.mem.setOption({ | |
| series: [{ data: [...charts.mem.getOption().series[0].data, [time, metrics.memory.percent]].slice(-60) }] | |
| }); | |
| // Network | |
| charts.net.setOption({ | |
| series: [{ data: [...charts.net.getOption().series[0].data, [time, metrics.network.rx_kbps]].slice(-60) }] | |
| }); | |
| // Disk | |
| charts.disk.setOption({ | |
| series: [{ data: [...charts.disk.getOption().series[0].data, [time, metrics.disk.read_kbps]].slice(-60) }] | |
| }); | |
| }; | |
| const handleHistory = (history) => { | |
| if (!history || !Array.isArray(history)) return; | |
| const cpuData = [], memData = [], netData = [], diskData = []; | |
| history.forEach(metrics => { | |
| const time = metrics.timestamp * 1000; | |
| cpuData.push([time, metrics.cpu.usage_percent]); | |
| memData.push([time, metrics.memory.percent]); | |
| netData.push([time, metrics.network.rx_kbps]); | |
| diskData.push([time, metrics.disk.read_kbps]); | |
| }); | |
| charts.cpu.setOption({ series: [{ data: cpuData.slice(-60) }] }); | |
| charts.mem.setOption({ series: [{ data: memData.slice(-60) }] }); | |
| charts.net.setOption({ series: [{ data: netData.slice(-60) }] }); | |
| charts.disk.setOption({ series: [{ data: diskData.slice(-60) }] }); | |
| }; | |
| onMounted(async () => { | |
| // Init Charts with new colors | |
| charts.cpu = initChart('cpu-chart', 'CPU Usage', '#3B82F6'); | |
| charts.mem = initChart('mem-chart', 'Memory Usage', '#A855F7'); | |
| charts.net = initChart('net-chart', 'Network RX', '#22C55E'); | |
| charts.disk = initChart('disk-chart', 'Disk Read', '#F59E0B'); | |
| // Connect WebSocket | |
| const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'; | |
| ws = new WebSocket(`${protocol}//${window.location.host}/ws/metrics`); | |
| ws.onopen = () => { isConnected.value = true; }; | |
| ws.onclose = () => { isConnected.value = false; }; | |
| ws.onmessage = (event) => { | |
| try { | |
| const data = JSON.parse(event.data); | |
| if (Array.isArray(data)) { | |
| handleHistory(data); | |
| } else { | |
| updateCharts(data); | |
| } | |
| } catch (e) { console.error("WS parse error", e); } | |
| }; | |
| }); | |
| return { isConnected }; | |
| } | |
| }).mount('#app'); | |
| </script> | |
| <style> | |
| [v-cloak] { display: none; } | |
| </style> | |
| </body> | |
| </html> | |