包含: - furniture-3d-system:Next.js 16 全栈应用(资产中心、产品管理、3D装配动画) - autocad-plugin:AutoCAD 家具导出插件源码 - 资产中心改造:编辑弹窗化、删除功能、Toast反馈、自定义Select组件 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
75 lines
4.1 KiB
PowerShell
75 lines
4.1 KiB
PowerShell
# Docker 资源监控脚本
|
|
# 用途:实时监控 Docker 容器和资源使用情况
|
|
# 使用:.\scripts\docker-monitor.ps1
|
|
# 退出:按 Ctrl+C
|
|
|
|
$vhdxPath = "D:\Users\Mr_Wu01\Documents\DockerDesktopWSL\disk\docker_data.vhdx"
|
|
|
|
while ($true) {
|
|
Clear-Host
|
|
Write-Host "=== Docker 资源监控 ===" -ForegroundColor Cyan
|
|
Write-Host "时间: $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" -ForegroundColor Yellow
|
|
Write-Host "按 Ctrl+C 退出`n" -ForegroundColor Gray
|
|
|
|
# 1. 容器状态
|
|
Write-Host "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -ForegroundColor DarkGray
|
|
Write-Host "容器状态:" -ForegroundColor Green
|
|
Write-Host "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -ForegroundColor DarkGray
|
|
|
|
try {
|
|
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" 2>$null
|
|
} catch {
|
|
Write-Host "❌ Docker 未运行或无法连接" -ForegroundColor Red
|
|
}
|
|
|
|
# 2. 资源使用
|
|
Write-Host "`n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -ForegroundColor DarkGray
|
|
Write-Host "资源使用:" -ForegroundColor Green
|
|
Write-Host "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -ForegroundColor DarkGray
|
|
|
|
try {
|
|
docker stats --no-stream --format "table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}\t{{.NetIO}}\t{{.BlockIO}}" 2>$null
|
|
} catch {
|
|
Write-Host "无法获取资源使用信息" -ForegroundColor Yellow
|
|
}
|
|
|
|
# 3. 磁盘使用
|
|
Write-Host "`n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -ForegroundColor DarkGray
|
|
Write-Host "磁盘使用:" -ForegroundColor Green
|
|
Write-Host "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -ForegroundColor DarkGray
|
|
|
|
try {
|
|
docker system df 2>$null
|
|
} catch {
|
|
Write-Host "无法获取磁盘使用信息" -ForegroundColor Yellow
|
|
}
|
|
|
|
# 4. VHDX 文件大小
|
|
Write-Host "`n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -ForegroundColor DarkGray
|
|
Write-Host "VHDX 文件:" -ForegroundColor Green
|
|
Write-Host "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -ForegroundColor DarkGray
|
|
|
|
if (Test-Path $vhdxPath) {
|
|
$vhdxSize = [math]::Round((Get-Item $vhdxPath).Length/1GB, 2)
|
|
$color = if ($vhdxSize -gt 50) { "Red" } elseif ($vhdxSize -gt 20) { "Yellow" } else { "Green" }
|
|
$status = if ($vhdxSize -gt 50) { "⚠️ 警告" } elseif ($vhdxSize -gt 20) { "⚠️ 注意" } else { "✅ 正常" }
|
|
|
|
Write-Host "文件路径: $vhdxPath" -ForegroundColor Gray
|
|
Write-Host "文件大小: $vhdxSize GB - $status" -ForegroundColor $color
|
|
|
|
if ($vhdxSize -gt 20) {
|
|
Write-Host "建议: 运行 .\scripts\docker-cleanup.ps1 清理数据" -ForegroundColor Yellow
|
|
}
|
|
if ($vhdxSize -gt 50) {
|
|
Write-Host "建议: 运行 .\scripts\docker-compress-vhdx.ps1 压缩文件" -ForegroundColor Red
|
|
}
|
|
} else {
|
|
Write-Host "❌ 未找到 VHDX 文件" -ForegroundColor Red
|
|
}
|
|
|
|
Write-Host "`n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -ForegroundColor DarkGray
|
|
Write-Host "刷新间隔: 5秒" -ForegroundColor Gray
|
|
|
|
Start-Sleep -Seconds 5
|
|
}
|