服务器监控

This commit is contained in:
liuwei
2025-05-27 09:06:21 +08:00
parent 108735fdad
commit 60b6b9f491
6 changed files with 234 additions and 1 deletions

19
main.py
View File

@@ -3,6 +3,7 @@
import asyncio
import threading
from admin.GlancesMonitor import GlancesMonitor
from utils.decorator.async_job import async_job
from configuration import Config
from plugins.xiuren_image.images_cache import ImageCacheManager
@@ -67,6 +68,24 @@ def main():
robot.LOG.error(f"Dashboard服务器启动失败: {e}")
asyncio.run(async_job.run_all())
try:
# 初始化 Glances 监控
monitor = GlancesMonitor(
email_sender=robot.email_sender,
host='localhost',
port=61208,
cpu_threshold=80.0,
load_threshold=None, # 自动设为 CPU 核心数 * 2
io_threshold=80.0,
disk_usage_threshold=60.0,
handle_threshold=20000,
recipient=config.email.get("alert_recipient")
)
monitor.run()
except Exception as e:
robot.LOG.error(f"GlancesMonitor服务器启动失败: {e}")
# 让机器人一直跑
robot.keep_running_and_block_process()