123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- from sqlalchemy import Column, String, Integer, Boolean, Text, DateTime, Float
- from sqlalchemy.ext.declarative import declarative_base
- Base = declarative_base()
- class Event(Base):
- __tablename__ = 'events'
- id = Column(Integer, primary_key=True, autoincrement=True) # 主键
- name = Column(String, nullable=False)
- time = Column(Integer, nullable=False)
- level = Column(String, nullable=True)
- res_name = Column(String, nullable=True)
- view_type = Column(String, nullable=True)
- event_state = Column(String, nullable=True)
- event_type = Column(String, nullable=True)
- res_temp_id = Column(String, nullable=True)
- event_id = Column(String, unique=True, nullable=False)
- res_type = Column(String, nullable=True)
- ip = Column(String, nullable=True)
- policy_id = Column(String, nullable=True)
- metric_id = Column(String, nullable=True)
- metric_name = Column(String, nullable=True)
- res_id = Column(String, nullable=True)
- collect_type = Column(String, nullable=True)
- is_app = Column(String, nullable=True)
- create_time = Column(String, nullable=True)
- sub_res_id = Column(String, nullable=True)
- recovered = Column(String, nullable=True)
- show_accept = Column(Boolean, nullable=False, default=False)
- show_maintain = Column(Boolean, nullable=False, default=False)
- recovered_event_id = Column(String, nullable=True)
- def __repr__(self):
- return f"<Event(name='{self.name}', event_id='{self.event_id}')>"
- class LogEvent(Base):
- __tablename__ = 'log_events'
- id = Column(String, primary_key=True, nullable=False)
- log_type = Column(String, nullable=True)
- alarm_level = Column(String, nullable=True)
- receiver = Column(String, nullable=True)
- resource_name = Column(String, nullable=True)
- send_type = Column(String, nullable=True)
- send_time = Column(String, nullable=True)
- alarm_content = Column(Text, nullable=True)
- send_result = Column(String, nullable=True)
- alarms_id = Column(String, nullable=True)
- log_host = Column(String, nullable=True)
- name = Column(String, nullable=True)
- company_id = Column(String, nullable=True)
- tag1 = Column(String, nullable=True)
- tag2 = Column(String, nullable=True)
- tag3 = Column(String, nullable=True)
- tag4 = Column(String, nullable=True)
- class Resource(Base):
- __tablename__ = 'resources'
- res_id = Column(String, primary_key=True, nullable=False) # 主键字段
- state = Column(String, nullable=True) # 状态
- name = Column(String, nullable=True) # 名称
- location = Column(String, nullable=True) # 位置
- type = Column(String, nullable=True) # 类型
- desc = Column(String, nullable=True) # 描述
- policy_name = Column(String, nullable=True) # 策略名称
- usability = Column(String, nullable=True) # 可用性
- sysoid = Column(String, nullable=True) # 系统 OID
- vender_name = Column(String, nullable=True) # 厂商名称
- name_display = Column(String, nullable=True) # 显示名称
- contact = Column(String, nullable=True) # 联系方式
- model_number = Column(String, nullable=True) # 型号
- ip = Column(String, nullable=True) # IP 地址
- tree_node_id = Column(String, nullable=True) # 树节点 ID
- res_type_id = Column(String, nullable=True) # 资源类型 ID
- series = Column(String, nullable=True) # 系列
- mac = Column(String, nullable=True) # MAC 地址
- location_name = Column(String, nullable=True) # 位置名称
- contact_name = Column(String, nullable=True) # 联系人名称
- mem_rate = Column(String, nullable=True) # 内存使用率
- cpu_rate = Column(String, nullable=True) # CPU 使用率
- busy = Column(String, nullable=True) # 繁忙状态
- sys_info = Column(String, nullable=True) # 系统信息
- vender_id = Column(String, nullable=True) # 厂商 ID
- class Location(Base):
- __tablename__ = 'locations'
- id = Column(String, primary_key=True, nullable=False) # 主键,网段 ID
- name = Column(String, nullable=True) # 名称
- parent_id = Column(String, nullable=True) # 父节点 ID
- full_path_name = Column(String, nullable=True) # 完整路径名称
- class Segment(Base):
- __tablename__ = 'segments'
- id = Column(String, primary_key=True, nullable=False) # 主键,子网 ID
- name = Column(String, nullable=True) # 名称
- ip_subnet = Column(String, nullable=True) # 子网地址
- vlan_id = Column(Integer, nullable=True) # VLAN ID
- vlan_name = Column(String, nullable=True) # VLAN 名称
- location_id = Column(String, nullable=True) # 网段 ID,关联Location.id
- location_full_path = Column(String, nullable=True) # 网段完整路径
- location_name = Column(String, nullable=True) # 网段名称
- class Room(Base):
- __tablename__ = 'rooms'
- id = Column(String, primary_key=True, nullable=False) # 主键,机房 ID
- display_name = Column(String, nullable=True) # 机房显示名称
- level = Column(String, nullable=True) # 机房等级
- rack_count = Column(Integer, nullable=True) # 机柜数量
- res_count = Column(Integer, nullable=True) # 资源数量
- capacity = Column(Integer, nullable=True) # 总容量
- used_capacity = Column(Integer, nullable=True) # 已用容量
- used_capacity_rate = Column(Float, nullable=True) # 容量使用率
- area = Column(Integer, nullable=True) # 面积
- class Element(Base):
- __tablename__ = 'elements'
- id = Column(String, primary_key=True, autoincrement=True) # 自动生成主键
- value = Column(String, nullable=True) # 元素值
- time = Column(DateTime, nullable=True) # 时间
- room_id = Column(String, nullable=False) # 机房 ID,外键关联
- is_cross = Column(String, nullable=True) # 是否跨域
- element_name = Column(String, nullable=True) # 元素名称
- metric_id = Column(String, nullable=True) # 指标 ID
- metric_name = Column(String, nullable=True) # 指标名称
- unit = Column(String, nullable=True) # 单位
- metric_definition_id = Column(String, nullable=True) # 指标定义 ID
- element_definition_name = Column(String, nullable=True) # 元素定义名称
- element_display_name = Column(String, nullable=True) # 元素显示名称
- metric_definition_name = Column(String, nullable=True) # 指标定义名称
- data_type = Column(String, nullable=True) # 数据类型
- element_definition_id = Column(String, nullable=True) # 元素定义 ID
|