149 lines
3.1 KiB
Erlang
149 lines
3.1 KiB
Erlang
%%%-------------------------------------------------------------------
|
||
%%% @author licheng5
|
||
%%% @copyright (C) 2023, <COMPANY>
|
||
%%% @doc
|
||
%%%
|
||
%%% @end
|
||
%%% Created : 14. 2月 2023 19:48
|
||
%%%-------------------------------------------------------------------
|
||
-author("licheng5").
|
||
|
||
%% 主机状态定义
|
||
-define(HOST_STATUS_INACTIVE, 0).
|
||
-define(HOST_STATUS_ONLINE, 1).
|
||
-define(HOST_STATUS_OFFLINE, 2).
|
||
-define(HOST_STATUS_DELETE, 3).
|
||
|
||
%% 终端状态
|
||
-define(TERMINAL_STATUS_OFFLINE, 0).
|
||
-define(TERMINAL_STATUS_ONLINE, 1).
|
||
|
||
%% cpu相关
|
||
-record(cpu_metric, {
|
||
%% cpu编号
|
||
num = 1,
|
||
%% 负载
|
||
load = 0
|
||
}).
|
||
|
||
%% 内存相关, 单位kb
|
||
-record(memory_metric, {
|
||
%% 使用量
|
||
used = 0,
|
||
%% 总量
|
||
total = 0
|
||
}).
|
||
|
||
%% 硬盘相关, 单位kb
|
||
-record(disk_metric, {
|
||
%% 使用量
|
||
used = 0,
|
||
%% 总量
|
||
total = 0
|
||
}).
|
||
|
||
%% 接口相关
|
||
-record(interface_metric, {
|
||
%% 接口名称
|
||
name = <<>>,
|
||
%% 接口详情
|
||
desc = <<>>,
|
||
%% 接口状态
|
||
status
|
||
}).
|
||
|
||
%% 终端指标收集
|
||
-record(terminal_metric, {
|
||
%% 标识
|
||
symbol :: binary(),
|
||
%% 名称
|
||
name :: binary(),
|
||
%% 当前最新值
|
||
last_value = 0 :: number(),
|
||
%% 历史值序列, 队列;保存最近的100数值, 格式为: [{ts, value}]
|
||
queue = [] :: queus:queue(),
|
||
%% 最后更新时间
|
||
update_ts = 0 :: integer()
|
||
}).
|
||
|
||
%% 主机定义
|
||
-record(host, {
|
||
%% ID
|
||
id :: binary(),
|
||
%% 名称
|
||
name :: binary(),
|
||
%% 型号
|
||
model :: binary(),
|
||
%% 单元网格编号
|
||
cell_id :: integer(),
|
||
%% 接入时间
|
||
activated_ts = 0 :: integer(),
|
||
%% 最后上线时间
|
||
update_ts = 0 :: integer(),
|
||
%% 主机状态
|
||
status = ?HOST_STATUS_INACTIVE :: integer()
|
||
}).
|
||
|
||
%% 主机指标, 主机和指标之间是一对一的关系,可以分离出新的表
|
||
-record(host_metric, {
|
||
%% ID
|
||
host_id :: binary(),
|
||
%% cpu相关
|
||
cpus = [],
|
||
%% cpu温度
|
||
cpu_temperature = 0,
|
||
%% 内存状态
|
||
memory = #memory_metric{},
|
||
%% 硬盘状态
|
||
disk = #disk_metric{},
|
||
%% 接口状态
|
||
interfaces = []
|
||
}).
|
||
|
||
%% 终端设备表
|
||
-record(terminal, {
|
||
%% 设备ID
|
||
id :: binary(),
|
||
%% 关联主机
|
||
host_id :: binary(),
|
||
%% 名称
|
||
name :: binary(),
|
||
%% 设备编码
|
||
code :: binary(),
|
||
%% 接入协议
|
||
access_protocol :: binary(),
|
||
%% 产品ID,枚举类型
|
||
product_id :: integer(),
|
||
%% 厂商ID,枚举类型
|
||
vendor_id :: integer(),
|
||
%% 型号
|
||
model :: binary(),
|
||
%% 所在单元ID,管理系统负责
|
||
cell_id :: integer(),
|
||
%% 指标, 终端指标涉及到查询效率和更新效率的问题,因此合并到一起
|
||
metrics = [] :: [#terminal_metric{}],
|
||
%% 终端状态
|
||
status = 0 :: integer(),
|
||
%% 最后上线时间
|
||
update_ts = 0 :: integer()
|
||
}).
|
||
|
||
%% 微服务表
|
||
-record(microservice, {
|
||
%% ID, 基于UUID生成
|
||
id :: binary(),
|
||
%% 关联主机
|
||
host_id :: binary(),
|
||
%% 名称
|
||
name :: binary(),
|
||
%% 类型
|
||
category :: binary(),
|
||
%% 应用对象
|
||
apply_object :: binary(),
|
||
%% 版本
|
||
version :: binary(),
|
||
%% 执行次数
|
||
execute_count = 0,
|
||
%% 部署时间
|
||
deploy_ts = 0 :: integer()
|
||
}). |