| name | system-monitor |
| description | 查看 AstrBot 系统运行状态和性能统计 |
| version | 2.0.0 |
| author | AstrBot Community |
| requires_admin | true |
| requires_computer_use | true |
System Monitor
查看 AstrBot 系统状态。
使用场景
- "系统状态怎么样?" / "查看运行状态"
- "运行多久了?"
- "现在有多少个插件?"
可用工具
查看系统状态
async def get_system_status(context):
try:
import psutil
import time
from datetime import datetime, timedelta
cpu_percent = psutil.cpu_percent(interval=1)
memory = psutil.virtual_memory()
disk = psutil.disk_usage('/')
uptime = time.time() - context.start_time
uptime_str = str(timedelta(seconds=int(uptime)))
plugins_count = len(context.get_registered_stars())
skills_count = len(context.skill_mgr.list_skills(active_only=True))
providers_count = len(context.get_llm_providers())
lines = [
"📊 系统状态:\n",
"## 资源使用",
f"- CPU: {cpu_percent}%",
f"- 内存: {memory.percent}% ({memory.used / 1024**3:.1f}GB / {memory.total / 1024**3:.1f}GB)",
f"- 磁盘: {disk.percent}% ({disk.used / 1024**3:.1f}GB / {disk.total / 1024**3:.1f}GB)",
"",
"## AstrBot 状态",
f"- 运行时长: {uptime_str}",
f"- 插件数量: {plugins_count}",
f"- Skills 数量: {skills_count}",
f"- 模型提供商: {providers_count}",
"",
"## 版本信息",
f"- AstrBot 版本: {context.get_astrbot_version()}",
f"- Python 版本: {context.get_python_version()}",
]
return "\n".join(lines)
except Exception as e:
return f"❌ 获取系统状态失败:{e}"
event = globals().get('event')
if not event.is_admin():
print("❌ 错误:仅管理员可用")
import sys; sys.exit(1)
context = globals().get('context')
result = await get_system_status(context)
print(result)
注意事项
- 系统状态实时获取,可能有1-2秒延迟
- CPU 使用率需要采样1秒
- 内存和磁盘使用显示的是整个系统的状态