This commit is contained in:
安礼成 2023-02-16 14:24:54 +08:00
parent 357c908612
commit e8e596ba72
3 changed files with 60 additions and 7 deletions

View File

@ -8,19 +8,72 @@
%%%-------------------------------------------------------------------
-author("licheng5").
%%
-define(STATUS_INACTIVE, 0).
-define(STATUS_ONLINE, 1).
-define(STATUS_OFFLINE, 2).
-define(STATUS_DELETE, 3).
%%
-define(HOST_STATUS_INACTIVE, 0).
-define(HOST_STATUS_ONLINE, 1).
-define(HOST_STATUS_OFFLINE, 2).
-define(HOST_STATUS_DELETE, 3).
%% 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(host_metrics, {
cpus = [],
cpu_temperature = 0,
memory = #memory_metric{},
disk = #disk_metric{},
interfaces = []
}).
%%
-record(host, {
%% ID
id :: binary(),
%%
name :: binary(),
%%
model :: binary(),
%%
cell_id :: integer(),
%%
terminal_num = 0 :: integer(),
%%
metrics,
%%
activated_ts = 0 :: integer(),
%% 线
update_ts = 0 :: integer(),
status = 0 :: integer()
}).

View File

@ -39,7 +39,7 @@ insert(Id, Name, Model, CellId) ->
cell_id = CellId,
terminal_num = 0,
update_ts = 0,
status = ?STATUS_INACTIVE
status = ?HOST_STATUS_INACTIVE
},
case mnesia:transaction(fun() -> mnesia:write(host, Host, write) end) of

View File

@ -36,7 +36,7 @@ insert(Id, HostId, Name, ProductId, VendorId, Model, CellId) ->
cell_id = CellId,
host_id = HostId,
update_ts = 0,
status = ?STATUS_INACTIVE
status = ?HOST_STATUS_INACTIVE
},
case mnesia:transaction(fun() -> mnesia:write(terminal, Terminal, write) end) of