Files
NetworkDeviceManagementSystem/backend/scheduler/scheduler.py

33 lines
1.3 KiB
Python
Raw Normal View History

2026-05-27 13:50:27 +07:00
from apscheduler.schedulers.background import BackgroundScheduler
# Khởi tạo background scheduler
# Thư viện APScheduler sẽ chạy các job ping/snmp định kỳ trong nền của Flask app
scheduler = BackgroundScheduler()
def start_scheduler():
"""Khởi chạy scheduler nếu nó chưa chạy"""
if not scheduler.running:
scheduler.start()
print("⏰ Background scheduler started.")
def add_device_monitoring_job(device_id, monitor_config):
"""
Thêm các job Ping/SNMP cho thiết bị mới hoặc được kích hoạt.
Sẽ được triển khai chi tiết module monitor_config/device_status.
"""
print(f"⏰ Stub: Added monitoring job for device {device_id}")
def remove_device_monitoring_job(device_id):
"""
Xóa toàn bộ các job Ping/SNMP liên quan đến thiết bị.
Sẽ được triển khai chi tiết module monitor_config/device_status.
"""
print(f"⏰ Stub: Removed monitoring job for device {device_id}")
def reschedule_device_monitoring_job(device_id, monitor_config):
"""
Cập nhật lại tần suất chạy (interval) hoặc phương thức chạy khi cấu hình giám sát thay đổi.
Sẽ được triển khai chi tiết module monitor_config/device_status.
"""
print(f"⏰ Stub: Rescheduled monitoring job for device {device_id}")