Files
anqing/deployment/acer/web/system_monitor.html
JarodLee bbd43a1e71 2026年开始重新工作的设计
重新启用安庆市高花亭小学学校工作台,整理办公、教学、协作与设备管理入口。
接入年月背景与 Bing 壁纸,安装高花亭校园乐园论坛主题。
修复旧论坛浏览器兼容和 Windows CDO 邮件支持,补充真实 Acer 性能监控。
保存配套部署源码、安装脚本和说明;运行数据库与邮箱凭据留在服务器。
2026-11-26 08:45:07 +00:00

621 lines
21 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Acer 系统性能监控 - Acer · JARODACER</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
background: linear-gradient(135deg, #0d1117 0%, #161b22 100%);
color: #e6edf3;
min-height: 100vh;
padding: 20px;
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 24px;
padding-bottom: 16px;
border-bottom: 1px solid #30363d;
}
.header h1 { font-size: 22px; font-weight: 600; }
.header .status {
display: flex;
align-items: center;
gap: 8px;
font-size: 13px;
color: #7ee787;
}
.header .status .dot {
width: 8px; height: 8px;
border-radius: 50%;
background: #7ee787;
animation: pulse 2s infinite;
}
@keyframes pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.4; }
}
.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
gap: 16px;
margin-bottom: 24px;
}
.card {
background: #161b22;
border: 1px solid #30363d;
border-radius: 12px;
padding: 20px;
transition: border-color 0.3s;
}
.card:hover { border-color: #58a6ff; }
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 16px;
}
.card-title {
font-size: 14px;
color: #8b949e;
text-transform: uppercase;
letter-spacing: 1px;
}
.card-value {
font-size: 36px;
font-weight: 700;
font-variant-numeric: tabular-nums;
}
.card-unit { font-size: 16px; color: #8b949e; margin-left: 4px; }
.card-bar {
height: 8px;
background: #21262d;
border-radius: 4px;
overflow: hidden;
margin-top: 12px;
}
.card-bar-fill {
height: 100%;
border-radius: 4px;
transition: width 0.5s ease;
}
.card-detail {
margin-top: 12px;
font-size: 12px;
color: #8b949e;
display: flex;
justify-content: space-between;
}
.cpu-fill { background: linear-gradient(90deg, #238636, #2ea043); }
.cpu-fill.warn { background: linear-gradient(90deg, #d29922, #e3b341); }
.cpu-fill.danger { background: linear-gradient(90deg, #da3633, #f85149); }
.mem-fill { background: linear-gradient(90deg, #1f6feb, #388bfd); }
.mem-fill.warn { background: linear-gradient(90deg, #d29922, #e3b341); }
.mem-fill.danger { background: linear-gradient(90deg, #da3633, #f85149); }
.disk-fill { background: linear-gradient(90deg, #8957e5, #bc8cff); }
.net-fill { background: linear-gradient(90deg, #238636, #2ea043); }
.chart-container {
background: #161b22;
border: 1px solid #30363d;
border-radius: 12px;
padding: 20px;
margin-bottom: 24px;
}
.chart-title {
font-size: 14px;
color: #8b949e;
text-transform: uppercase;
letter-spacing: 1px;
margin-bottom: 12px;
}
canvas {
width: 100% !important;
height: 220px !important;
}
.log-section {
background: #161b22;
border: 1px solid #30363d;
border-radius: 12px;
padding: 20px;
}
.log-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 12px;
}
.log-title {
font-size: 14px;
color: #8b949e;
text-transform: uppercase;
letter-spacing: 1px;
}
.log-controls { display: flex; gap: 8px; }
.btn {
padding: 6px 14px;
border: 1px solid #30363d;
border-radius: 6px;
background: #21262d;
color: #e6edf3;
font-size: 12px;
cursor: pointer;
transition: all 0.2s;
}
.btn:hover { border-color: #58a6ff; background: #1f2428; }
.btn-primary { border-color: #238636; background: #238636; }
.btn-primary:hover { background: #2ea043; }
.log-table {
width: 100%;
font-size: 12px;
font-variant-numeric: tabular-nums;
max-height: 300px;
overflow-y: auto;
}
.log-table::-webkit-scrollbar { width: 6px; }
.log-table::-webkit-scrollbar-track { background: #21262d; }
.log-table::-webkit-scrollbar-thumb { background: #30363d; border-radius: 3px; }
.log-table table { width: 100%; border-collapse: collapse; }
.log-table th {
text-align: left;
padding: 6px 10px;
color: #8b949e;
font-weight: 500;
position: sticky;
top: 0;
background: #161b22;
border-bottom: 1px solid #30363d;
}
.log-table td {
padding: 4px 10px;
border-bottom: 1px solid #21262d;
}
.log-table tr:hover td { background: #1c2128; }
.summary {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 12px;
margin-bottom: 24px;
}
.summary-item {
background: #161b22;
border: 1px solid #30363d;
border-radius: 8px;
padding: 14px;
text-align: center;
}
.summary-label { font-size: 12px; color: #8b949e; margin-bottom: 4px; }
.summary-value { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.warning-banner {
background: #1c2128;
border: 1px solid #d29922;
border-radius: 8px;
padding: 12px 16px;
margin-bottom: 16px;
font-size: 13px;
color: #e3b341;
display: none;
}
.warning-banner.show { display: block; }
.footer {
text-align: center;
font-size: 12px;
color: #484f58;
margin-top: 24px;
padding-top: 16px;
border-top: 1px solid #21262d;
}
</style>
</head>
<body>
<div class="header">
<h1>Acer 系统性能监控 <span style="color:#58a6ff;font-size:14px;">Acer · JARODACER</span></h1>
<div class="status">
<span class="dot"></span>
<span id="uptime">运行中</span>
</div>
</div>
<div class="warning-banner" id="warningBanner"></div>
<div class="grid">
<!-- CPU -->
<div class="card">
<div class="card-header">
<span class="card-title">CPU 使用率</span>
<span style="font-size:12px;color:#8b949e;" id="cpuCores">- 核</span>
</div>
<span class="card-value" id="cpuValue">--</span><span class="card-unit">%</span>
<div class="card-bar"><div class="card-bar-fill cpu-fill" id="cpuBar" style="width:0%"></div></div>
<div class="card-detail">
<span id="cpuSpeed">核心/评分: --</span>
<span id="cpuAvg">平均: --%</span>
</div>
</div>
<!-- 内存 -->
<div class="card">
<div class="card-header">
<span class="card-title">内存使用</span>
<span style="font-size:12px;color:#8b949e;" id="memTotal">总计: --</span>
</div>
<span class="card-value" id="memValue">--</span><span class="card-unit">%</span>
<div class="card-bar"><div class="card-bar-fill mem-fill" id="memBar" style="width:0%"></div></div>
<div class="card-detail">
<span id="memUsed">已用: --</span>
<span id="memFree">可用: --</span>
</div>
</div>
<!-- 硬盘 -->
<div class="card">
<div class="card-header">
<span class="card-title">磁盘占用</span>
<span style="font-size:12px;color:#8b949e;" id="diskLabel">系统盘</span>
</div>
<span class="card-value" id="diskValue">--</span><span class="card-unit">%</span>
<div class="card-bar"><div class="card-bar-fill disk-fill" id="diskBar" style="width:0%"></div></div>
<div class="card-detail">
<span id="diskUsed">已用: --</span>
<span id="diskFree">可用: --</span>
</div>
</div>
<!-- 网络 -->
<div class="card">
<div class="card-header">
<span class="card-title">网络速率</span>
<span style="font-size:12px;color:#8b949e;" id="netType">--</span>
</div>
<span class="card-value" id="netDown">--</span><span class="card-unit" id="netDownUnit">KB/s</span>
<div class="card-bar"><div class="card-bar-fill net-fill" id="netBar" style="width:0%"></div></div>
<div class="card-detail">
<span id="netUp">上传: -- KB/s</span>
<span id="netTotal">累计: --</span>
</div>
</div>
</div>
<!-- 图表 -->
<div class="chart-container">
<div class="chart-title">实时趋势图 (最近 60 个采样点)</div>
<canvas id="chart"></canvas>
</div>
<!-- 汇总 -->
<div class="summary">
<div class="summary-item">
<div class="summary-label">采样次数</div>
<div class="summary-value" id="sampleCount">0</div>
</div>
<div class="summary-item">
<div class="summary-label">CPU 峰值</div>
<div class="summary-value" id="cpuPeak">--%</div>
</div>
<div class="summary-item">
<div class="summary-label">内存峰值</div>
<div class="summary-value" id="memPeak">--%</div>
</div>
<div class="summary-item">
<div class="summary-label">网络峰值</div>
<div class="summary-value" id="netPeak">--</div>
</div>
<div class="summary-item">
<div class="summary-label">Acer 开机时长</div>
<div class="summary-value" id="runTime">00:00:00</div>
</div>
</div>
<!-- 日志 -->
<div class="log-section">
<div class="log-header">
<span class="log-title">历史记录</span>
<div class="log-controls">
<button class="btn" onclick="exportCSV()">导出 CSV</button>
<button class="btn" onclick="clearLog()">清空</button>
<button class="btn btn-primary" id="pauseBtn" onclick="togglePause()">暂停</button>
</div>
</div>
<div class="log-table">
<table>
<thead>
<tr>
<th>时间</th>
<th>CPU%</th>
<th>内存%</th>
<th>磁盘%</th>
<th>下载</th>
<th>上传</th>
</tr>
</thead>
<tbody id="logBody"></tbody>
</table>
</div>
</div>
<div id="driveDetails" style="line-height:1.8;overflow-wrap:anywhere;margin-top:18px"></div><div class="footer">数据来源:Acer Windows 系统计数器 · 约每 5 秒更新 · 网络为在线物理网卡流量 · 历史和峰值为本次查看采样</div>
<script>
let isPaused=false, sampleCount=0, startTime=Date.now();
let cpuPeak=0,memPeak=0,netPeak=0;
let cpuHistory=[],memHistory=[],netHistory=[],timeLabels=[],logData=[];
const MAX_HISTORY=60,STORAGE_KEY='acer_real_metrics_log_v1',INTERVAL=5000;
let busy=false,lastSample='',lastGood=0,serverOffset=0;
const el=id=>document.getElementById(id);
const gb=n=>(n/1073741824).toFixed(1);
function unavailable(message){
el('uptime').textContent=message;
for(const id of ['cpuValue','memValue','diskValue','netDown','memUsed','memFree','diskUsed','diskFree','netUp','netTotal']) el(id).textContent='--';
for(const id of ['cpuBar','memBar','diskBar','netBar']) el(id).style.width='0%';
el('warningBanner').textContent='Acer 数据暂不可用,请检查采集服务。';el('warningBanner').classList.add('show');
}
window.addEventListener('load',()=>{
monitor();setInterval(()=>{if(!isPaused)monitor();},INTERVAL);
setInterval(()=>{if(!isPaused&&lastGood&&Date.now()-lastGood>20000)unavailable('数据已过期');updateUptime();},1000);
});
async function monitor(){
if(busy)return;busy=true;
try{
const controller=new AbortController(),timeout=setTimeout(()=>controller.abort(),10000);
let r;try{r=await fetch('/acer-metrics.json?t='+Date.now(),{cache:'no-store',signal:controller.signal});}finally{clearTimeout(timeout)}
if(!r.ok)throw Error('HTTP '+r.status);
const d=await r.json();
if(!d.ok||!Number.isFinite(d.cpu.percent)||!d.memory.total||!Array.isArray(d.disks)||!d.disks.length)throw Error('Invalid metrics');
const sample=Date.parse(d.sampledAt);if(!Number.isFinite(sample))throw Error('Invalid timestamp');
const serverTime=Date.parse(r.headers.get('Date'));if(Number.isFinite(serverTime)&&serverTime-sample>20000)throw Error('Stale metrics');
if(d.sampledAt===lastSample){if(Date.now()-lastGood>20000)throw Error('Stopped collector');return}
lastSample=d.sampledAt;lastGood=Date.now();
startTime=Date.now()-d.uptimeSeconds*1000;
const cpu=d.cpu.percent,mem=Number(((1-d.memory.free/d.memory.total)*100).toFixed(1));
const total=d.disks.reduce((n,x)=>n+x.total,0),free=d.disks.reduce((n,x)=>n+x.free,0);
const disk=Number(((1-free/total)*100).toFixed(1));
const net={down:d.network.receivedBytesPerSecond/1024,up:d.network.sentBytesPerSecond/1024};
cpuHistory.push(cpu);memHistory.push(mem);netHistory.push(net.down);
const time=new Date(sample).toLocaleTimeString('zh-CN',{hour12:false});timeLabels.push(time);
for(const a of [cpuHistory,memHistory,netHistory,timeLabels])if(a.length>MAX_HISTORY)a.shift();
updateUI(cpu,mem,disk,net,gb(d.memory.total-d.memory.free),gb(d.memory.free),gb(total-free),gb(free));
el('cpuCores').textContent=d.cpu.logicalCores+' 线程';el('cpuSpeed').textContent=d.cpu.name;
el('memTotal').textContent='总计: '+gb(d.memory.total)+' GB';
el('diskLabel').textContent='本地磁盘合计 '+gb(total)+' GB';
el('netType').textContent=d.network.adapters.join(' + ')||'无在线物理网卡';
el('netTotal').textContent='所有在线物理网卡合计';
if(!d.network.ready){el('netDown').textContent='--';el('netUp').textContent='上传: 等待下一次采样'}
el('driveDetails').textContent=d.disks.map(x=>x.drive+' 已用 '+gb(x.used)+' / '+gb(x.total)+' GB(可用 '+gb(x.free)+' GB)').join(' · ');
el('uptime').textContent=d.host+' · 更新于 '+time;
cpuPeak=Math.max(cpuPeak,cpu);memPeak=Math.max(memPeak,mem);netPeak=Math.max(netPeak,net.down);
el('cpuPeak').textContent=cpuPeak+'%';el('memPeak').textContent=memPeak+'%';
const peak=formatSpeed(netPeak);el('netPeak').textContent=peak.value+' '+peak.unit;
el('sampleCount').textContent=++sampleCount;
const entry={time,cpu,mem,disk,down:net.down,up:net.up};
logData.push(entry);if(logData.length>500)logData.shift();saveLog();addLogRow(entry);
checkWarning(cpu,mem,Math.max(...d.disks.map(x=>x.used/x.total*100)));drawChart();
}catch(e){unavailable('采集连接中断 / 数据过期')}finally{busy=false}
}
// ========== UI 更新 ==========
function updateUI(cpu, mem, disk, net, memUsed, memFree, diskUsed, diskFree) {
// CPU
document.getElementById('cpuValue').textContent = cpu;
const cpuBar = document.getElementById('cpuBar');
cpuBar.style.width = cpu + '%';
cpuBar.className = 'card-bar-fill cpu-fill' + getWarnClass(cpu);
document.getElementById('cpuAvg').textContent = '平均: ' + (cpuHistory.reduce((a,b)=>a+b,0) / Math.max(cpuHistory.length,1)).toFixed(1) + '%';
// 内存
document.getElementById('memValue').textContent = mem;
const memBar = document.getElementById('memBar');
memBar.style.width = mem + '%';
memBar.className = 'card-bar-fill mem-fill' + getWarnClass(mem);
document.getElementById('memUsed').textContent = '已用: ' + memUsed + ' GB';
document.getElementById('memFree').textContent = '可用: ' + memFree + ' GB';
// 磁盘
document.getElementById('diskValue').textContent = disk;
document.getElementById('diskBar').style.width = disk + '%';
document.getElementById('diskUsed').textContent = '已用: ' + diskUsed + ' GB';
document.getElementById('diskFree').textContent = '可用: ' + diskFree + ' GB';
// 网络
const downFormatted = formatSpeed(net.down);
document.getElementById('netDown').textContent = downFormatted.value;
document.getElementById('netDownUnit').textContent = downFormatted.unit;
const upFormatted = formatSpeed(net.up);
document.getElementById('netUp').textContent = '上传: ' + upFormatted.value + ' ' + upFormatted.unit;
document.getElementById('netTotal').textContent = '累计: ' + formatSpeed(net.totalDown || 0).value + ' ' + formatSpeed(net.totalDown || 0).unit;
// 网络条 (归一化到 10MB/s)
const netPercent = Math.min((net.down / (10 * 1024)) * 100, 100);
document.getElementById('netBar').style.width = netPercent + '%';
}
function getWarnClass(val) {
if (val >= 85) return ' danger';
if (val >= 70) return ' warn';
return '';
}
function formatSpeed(kb) {
if (kb >= 1024) return { value: (kb / 1024).toFixed(1), unit: 'MB/s' };
return { value: kb.toFixed(1), unit: 'KB/s' };
}
// ========== 告警 ==========
function checkWarning(cpu, mem, disk) {
const banner = document.getElementById('warningBanner');
const warnings = [];
if (cpu >= 85) warnings.push('CPU 使用率过高 (' + cpu + '%)');
if (mem >= 85) warnings.push('内存使用率过高 (' + mem + '%)');
if (disk >= 90) warnings.push('磁盘空间不足 (' + disk + '%)');
if (warnings.length > 0) {
banner.textContent = '⚠ ' + warnings.join(' · ');
banner.classList.add('show');
} else {
banner.classList.remove('show');
}
}
// ========== 图表 ==========
function drawChart() {
const canvas = document.getElementById('chart');
const ctx = canvas.getContext('2d');
const dpr = window.devicePixelRatio || 1;
const w = canvas.clientWidth * dpr;
const h = 220 * dpr;
canvas.width = w;
canvas.height = h;
ctx.scale(dpr, dpr);
const cw = canvas.clientWidth;
const ch = 220;
const padTop = 10;
const padBottom = 40;
const padLeft = 36;
const padRight = 16;
const chartW = cw - padLeft - padRight;
const chartH = ch - padTop - padBottom;
ctx.clearRect(0, 0, cw, ch);
// 网格
ctx.strokeStyle = '#21262d';
ctx.lineWidth = 1;
for (let i = 0; i <= 4; i++) {
const y = padTop + (chartH / 4) * i;
ctx.beginPath();
ctx.moveTo(padLeft, y);
ctx.lineTo(cw - padRight, y);
ctx.stroke();
}
// Y轴标签
ctx.fillStyle = '#484f58';
ctx.font = '10px monospace';
ctx.textAlign = 'right';
for (let i = 0; i <= 4; i++) {
const y = padTop + (chartH / 4) * i;
ctx.fillText((100 - i * 25) + '%', padLeft - 5, y + 3);
}
// 绘制线条
function drawLine(data, color) {
if (data.length < 2) return;
ctx.strokeStyle = color;
ctx.lineWidth = 2;
ctx.beginPath();
data.forEach((val, i) => {
const x = padLeft + (chartW / Math.max(MAX_HISTORY - 1, 1)) * i;
const y = padTop + chartH - (val / 100) * chartH;
if (i === 0) ctx.moveTo(x, y);
else ctx.lineTo(x, y);
});
ctx.stroke();
}
drawLine(cpuHistory, '#2ea043');
drawLine(memHistory, '#388bfd');
// X轴时间标签 (最多显示 6 个)
if (timeLabels.length > 0) {
ctx.fillStyle = '#484f58';
ctx.font = '9px monospace';
ctx.textAlign = 'center';
const maxLabels = Math.min(6, timeLabels.length);
for (let i = 0; i < maxLabels; i++) {
const idx = Math.round((i / (maxLabels - 1 || 1)) * (timeLabels.length - 1));
const x = padLeft + (chartW / Math.max(MAX_HISTORY - 1, 1)) * Math.min(idx, timeLabels.length - 1);
const label = timeLabels[Math.min(idx, timeLabels.length - 1)];
ctx.fillText(label, x, padTop + chartH + 18);
}
}
// 图例
ctx.textAlign = 'left';
ctx.fillStyle = '#2ea043';
ctx.fillRect(padLeft, 2, 12, 3);
ctx.fillStyle = '#8b949e';
ctx.fillText('CPU', padLeft + 16, 7);
ctx.fillStyle = '#388bfd';
ctx.fillRect(padLeft + 60, 2, 12, 3);
ctx.fillStyle = '#8b949e';
ctx.fillText('内存', padLeft + 76, 7);
}
// ========== 日志 ==========
function addLogRow(entry) {
const tbody = document.getElementById('logBody');
const row = tbody.insertRow(0);
row.innerHTML = `<td>${entry.time}</td><td>${entry.cpu}%</td><td>${entry.mem}%</td><td>${entry.disk}%</td><td>${formatSpeed(entry.down).value} ${formatSpeed(entry.down).unit}</td><td>${formatSpeed(entry.up).value} ${formatSpeed(entry.up).unit}</td>`;
// 最多保留 200 行
while (tbody.rows.length > 200) tbody.deleteRow(tbody.rows.length - 1);
}
function saveLog() {
try {
localStorage.setItem(STORAGE_KEY, JSON.stringify(logData.slice(-200)));
} catch(e) {}
}
function loadLog() {
try {
const saved = localStorage.getItem(STORAGE_KEY);
if (saved) {
logData = JSON.parse(saved);
logData.forEach(entry => addLogRow(entry));
sampleCount = logData.length;
document.getElementById('sampleCount').textContent = sampleCount;
}
} catch(e) {}
}
function exportCSV() {
const csv = '时间,CPU%,内存%,磁盘%,下载KB/s,上传KB/s\n' +
logData.map(e => `${e.time},${e.cpu},${e.mem},${e.disk},${e.down.toFixed(1)},${e.up.toFixed(1)}`).join('\n');
const blob = new Blob(['\ufeff' + csv], { type: 'text/csv;charset=utf-8' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'perf_log_' + new Date().toISOString().slice(0,10) + '.csv';
a.click();
URL.revokeObjectURL(url);
}
function clearLog() {
logData = [];
localStorage.removeItem(STORAGE_KEY);
document.getElementById('logBody').innerHTML = '';
sampleCount = 0;
cpuPeak = 0; memPeak = 0; netPeak = 0;
document.getElementById('sampleCount').textContent = '0';
document.getElementById('cpuPeak').textContent = '--%';
document.getElementById('memPeak').textContent = '--%';
document.getElementById('netPeak').textContent = '--';
cpuHistory = []; memHistory = []; netHistory = []; timeLabels = [];
drawChart();
}
function togglePause() {
isPaused = !isPaused;
document.getElementById('pauseBtn').textContent = isPaused ? '继续' : '暂停';
}
// ========== 运行时长 ==========
function updateUptime() {
const elapsed = Math.floor((Date.now() - startTime) / 1000);
const h = String(Math.floor(elapsed / 3600)).padStart(2, '0');
const m = String(Math.floor((elapsed % 3600) / 60)).padStart(2, '0');
const s = String(elapsed % 60).padStart(2, '0');
document.getElementById('runTime').textContent = `${h}:${m}:${s}`;
}
</script>
</body>
</html>