Merge pull request #10044 from zmstone/0228-fix-node-info-format
fix(emqx_mgmt): format stoped nodes correctly
This commit is contained in:
commit
fdc0ad6669
|
@ -141,9 +141,28 @@ node_info() ->
|
|||
uptime => proplists:get_value(uptime, BrokerInfo),
|
||||
version => iolist_to_binary(proplists:get_value(version, BrokerInfo)),
|
||||
edition => emqx_release:edition_longstr(),
|
||||
role => mria_rlog:role()
|
||||
role => mria_rlog:role(),
|
||||
log_path => log_path(),
|
||||
sys_path => iolist_to_binary(code:root_dir())
|
||||
}.
|
||||
|
||||
log_path() ->
|
||||
RootDir = code:root_dir(),
|
||||
Configs = logger:get_handler_config(),
|
||||
case get_log_path(Configs) of
|
||||
undefined ->
|
||||
<<"log.file_handler.default.enable is false, not logging to file.">>;
|
||||
Path ->
|
||||
iolist_to_binary(filename:join(RootDir, Path))
|
||||
end.
|
||||
|
||||
get_log_path([#{config := #{file := Path}} | _LoggerConfigs]) ->
|
||||
filename:dirname(Path);
|
||||
get_log_path([_LoggerConfig | LoggerConfigs]) ->
|
||||
get_log_path(LoggerConfigs);
|
||||
get_log_path([]) ->
|
||||
undefined.
|
||||
|
||||
get_sys_memory() ->
|
||||
case os:type() of
|
||||
{unix, linux} ->
|
||||
|
|
|
@ -293,31 +293,12 @@ get_stats(Node) ->
|
|||
%% internal function
|
||||
|
||||
format(_Node, Info = #{memory_total := Total, memory_used := Used}) ->
|
||||
RootDir = list_to_binary(code:root_dir()),
|
||||
LogPath =
|
||||
case log_path() of
|
||||
undefined ->
|
||||
<<"log.file_handler.default.enable is false,only log to console">>;
|
||||
Path ->
|
||||
filename:join(RootDir, Path)
|
||||
end,
|
||||
Info#{
|
||||
memory_total := emqx_mgmt_util:kmg(Total),
|
||||
memory_used := emqx_mgmt_util:kmg(Used),
|
||||
sys_path => RootDir,
|
||||
log_path => LogPath
|
||||
}.
|
||||
|
||||
log_path() ->
|
||||
Configs = logger:get_handler_config(),
|
||||
get_log_path(Configs).
|
||||
|
||||
get_log_path([#{config := #{file := Path}} | _LoggerConfigs]) ->
|
||||
filename:dirname(Path);
|
||||
get_log_path([_LoggerConfig | LoggerConfigs]) ->
|
||||
get_log_path(LoggerConfigs);
|
||||
get_log_path([]) ->
|
||||
undefined.
|
||||
memory_used := emqx_mgmt_util:kmg(Used)
|
||||
};
|
||||
format(_Node, Info) when is_map(Info) ->
|
||||
Info.
|
||||
|
||||
node_error() ->
|
||||
emqx_dashboard_swagger:error_codes([?SOURCE_ERROR], <<"Node error">>).
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Fix node information formatter for stopped nodes in the cluster.
|
|
@ -0,0 +1 @@
|
|||
修复 v5.0.18 引入的一个节点信息序列化时发生的错误。
|
Loading…
Reference in New Issue