25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-30 16:36:29 +01:00

Show uptime date in WebAdmin, it's easier to understand that uptime seconds

This commit is contained in:
Badlop 2021-05-19 14:51:03 +02:00
parent 494ba9a635
commit 58a623778f

View File

@ -1354,6 +1354,7 @@ get_node(global, Node, [<<"stats">>], _Query, Lang) ->
[wall_clock]), [wall_clock]),
UpTimeS = (str:format("~.3f", UpTimeS = (str:format("~.3f",
[element(1, UpTime) / 1000])), [element(1, UpTime) / 1000])),
UpTimeDate = uptime_date(Node),
CPUTime = ejabberd_cluster:call(Node, erlang, statistics, [runtime]), CPUTime = ejabberd_cluster:call(Node, erlang, statistics, [runtime]),
CPUTimeS = (str:format("~.3f", CPUTimeS = (str:format("~.3f",
[element(1, CPUTime) / 1000])), [element(1, CPUTime) / 1000])),
@ -1374,6 +1375,10 @@ get_node(global, Node, [<<"stats">>], _Query, Lang) ->
[?XCT(<<"td">>, ?T("Uptime:")), [?XCT(<<"td">>, ?T("Uptime:")),
?XAC(<<"td">>, [{<<"class">>, <<"alignright">>}], ?XAC(<<"td">>, [{<<"class">>, <<"alignright">>}],
UpTimeS)]), UpTimeS)]),
?XE(<<"tr">>,
[?X(<<"td">>),
?XAC(<<"td">>, [{<<"class">>, <<"alignright">>}],
UpTimeDate)]),
?XE(<<"tr">>, ?XE(<<"tr">>,
[?XCT(<<"td">>, ?T("CPU Time:")), [?XCT(<<"td">>, ?T("CPU Time:")),
?XAC(<<"td">>, [{<<"class">>, <<"alignright">>}], ?XAC(<<"td">>, [{<<"class">>, <<"alignright">>}],
@ -1468,6 +1473,16 @@ get_node(Host, Node, NPath, Query, Lang) ->
_ -> Res _ -> Res
end. end.
uptime_date(Node) ->
Localtime = ejabberd_cluster:call(Node, erlang, localtime, []),
Now = calendar:datetime_to_gregorian_seconds(Localtime),
{Wall, _} = ejabberd_cluster:call(Node, erlang, statistics, [wall_clock]),
LastRestart = Now - (Wall div 1000),
{{Year, Month, Day}, {Hour, Minute, Second}} =
calendar:gregorian_seconds_to_datetime(LastRestart),
str:format("~w-~.2.0w-~.2.0w ~.2.0w:~.2.0w:~.2.0w",
[Year, Month, Day, Hour, Minute, Second]).
%%%================================== %%%==================================
%%%% node parse %%%% node parse