fix router

This commit is contained in:
安礼成 2023-03-01 17:56:16 +08:00
parent e7b96b3cd5
commit bf9369df6d

View File

@ -76,42 +76,21 @@ table_size() ->
%% helper methods
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
to_map(#host{host_id = HostId, name = Name, model = Model, cell_id = CellId, activated_ts = ActivatedTs, update_ts = UpdateTs, status = Status,
metric = #host_metric{
cpus = Cpus,
cpu_temperature = CpuTemperature,
memory = #memory_metric{used = MemoryUsed, total = MemoryTotal},
disk = #disk_metric{used = DiskUsed, total = DiskTotal},
interfaces = Interfaces}}) ->
to_map(#router{router_id = RouterId, name = Name, status = Status, endpoint = Endpoint}) ->
EndpointInfo = case Endpoint of
undefined ->
#{};
#http_endpoint{url = Url} ->
#{
<<"type">> => <<"http">>,
<<"url">> => Url
};
#kafka_endpoint{} ->
#{}
end,
#{
<<"host_id">> => HostId,
<<"router_id">> => RouterId,
<<"name">> => Name,
<<"model">> => Model,
<<"cell_id">> => CellId,
<<"activated_ts">> => ActivatedTs,
<<"update_ts">> => UpdateTs,
<<"status">> => Status,
<<"metric">> => #{
<<"cpus">> => lists:map(fun(#cpu_metric{num = Num, load = Load}) ->
#{<<"num">> => Num, <<"load">> => Load }
end,
Cpus),
<<"cpu_temperature">> => CpuTemperature,
<<"memory">> => #{
<<"used">> => MemoryUsed,
<<"total">> => MemoryTotal
},
<<"disk">> => #{
<<"used">> => DiskUsed,
<<"total">> => DiskTotal
},
<<"interfaces">> => lists:map(fun(#interface_metric{name = IName, desc = IDesc, status = IStatus, detail = IDetail}) ->
#{
<<"name">> => IName,
<<"desc">> => IDesc,
<<"status">> => IStatus,
<<"detatil">> => IDetail
}
end, Interfaces)
}
<<"endpoint">> => EndpointInfo
}.