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