848f804169
- FastAPI 后端 + Vue 3 前端 - Docker Compose 一键部署 - Casdoor OAuth 认证集成 - LogHive 集中式日志 - 设备批量 CSV 导入/导出 - WebSocket 实时状态推送 - 企业微信告警通知 - fping 高性能并发 Ping 检测 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
19 lines
840 B
Python
19 lines
840 B
Python
from datetime import datetime
|
|
from sqlalchemy import Column, Integer, Float, Boolean, DateTime, BigInteger
|
|
from .device import Base
|
|
|
|
|
|
class PingRecord(Base):
|
|
"""单次 ping 结果记录"""
|
|
__tablename__ = "ping_records"
|
|
|
|
id = Column(BigInteger, primary_key=True, autoincrement=True)
|
|
device_id = Column(Integer, nullable=False, index=True)
|
|
is_alive = Column(Boolean, nullable=False, comment="是否通")
|
|
response_time_ms = Column(Float, nullable=True, comment="响应时间毫秒,不通则为 NULL")
|
|
round_num = Column(Integer, nullable=False, comment="轮次编号(从 1 递增)")
|
|
created_at = Column(DateTime, default=datetime.now, index=True, comment="记录时间")
|
|
|
|
def __repr__(self):
|
|
return f"<PingRecord(device={self.device_id}, alive={self.is_alive}, rtt={self.response_time_ms})>"
|