summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniil Fedotov <dfedotov@pivotal.io>2015-12-21 14:40:58 +0000
committerDaniil Fedotov <dfedotov@pivotal.io>2015-12-21 14:40:58 +0000
commit2e55211eb60b0b51fff87059dab88e82865a772a (patch)
tree821a266f371a2f3c557fd116d6dd7ff70df66e8b /src
parentab42bc257b866f6fec7e52b3bdc0b30c43fd0ea8 (diff)
downloadrabbitmq-server-git-2e55211eb60b0b51fff87059dab88e82865a772a.tar.gz
Datetime in rabbit_diagnostics
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_diagnostics.erl31
1 files changed, 22 insertions, 9 deletions
diff --git a/src/rabbit_diagnostics.erl b/src/rabbit_diagnostics.erl
index a611a24e1c..ac1392d68f 100644
--- a/src/rabbit_diagnostics.erl
+++ b/src/rabbit_diagnostics.erl
@@ -27,17 +27,17 @@ maybe_stuck() -> maybe_stuck(5000).
maybe_stuck(Timeout) ->
Pids = processes(),
- io:format("There are ~p processes.~n", [length(Pids)]),
+ io:format("~s There are ~p processes.~n", [get_time(), length(Pids)]),
maybe_stuck(Pids, Timeout).
maybe_stuck(Pids, Timeout) when Timeout =< 0 ->
- io:format("Found ~p suspicious processes.~n", [length(Pids)]),
- [io:format("~p~n", [info(Pid)]) || Pid <- Pids],
+ io:format("~s Found ~p suspicious processes.~n", [get_time(), length(Pids)]),
+ [io:format("~s ~p~n", [get_time(), info(Pid)]) || Pid <- Pids],
ok;
maybe_stuck(Pids, Timeout) ->
Pids2 = [P || P <- Pids, looks_stuck(P)],
- io:format("Investigated ~p processes this round, ~pms to go.~n",
- [length(Pids2), Timeout]),
+ io:format("~s Investigated ~p processes this round, ~pms to go.~n",
+ [get_time(), length(Pids2), Timeout]),
timer:sleep(500),
maybe_stuck(Pids2, Timeout - 500).
@@ -80,19 +80,19 @@ top_memory_use() -> top_memory_use(30).
top_memory_use(Count) ->
Pids = processes(),
- io:format("Memory use: top ~p of ~p processes.~n", [Count, length(Pids)]),
+ io:format("~s Memory use: top ~p of ~p processes.~n", [get_time(), Count, length(Pids)]),
Procs = [{info(Pid, memory, 0), info(Pid)} || Pid <- Pids],
Sorted = lists:sublist(lists:reverse(lists:sort(Procs)), Count),
- io:format("~p~n", [Sorted]).
+ io:format("~s ~p~n", [get_time(), Sorted]).
top_binary_refs() -> top_binary_refs(30).
top_binary_refs(Count) ->
Pids = processes(),
- io:format("Binary refs: top ~p of ~p processes.~n", [Count, length(Pids)]),
+ io:format("~s Binary refs: top ~p of ~p processes.~n", [get_time(), Count, length(Pids)]),
Procs = [{{binary_refs, binary_refs(Pid)}, info(Pid)} || Pid <- Pids],
Sorted = lists:sublist(lists:reverse(lists:sort(Procs)), Count),
- io:format("~p~n", [Sorted]).
+ io:format("~s ~p~n", [get_time(), Sorted]).
binary_refs(Pid) ->
{binary, Refs} = info(Pid, binary, []),
@@ -111,3 +111,16 @@ info(Pid, Infos, Default) ->
false -> Default
end
end.
+
+get_time() ->
+ {{Y,M,D}, {H,Min,Sec}} = calendar:local_time(),
+ [ integer_to_list(Y), "-",
+ prefix_zero(integer_to_list(M)), "-",
+ prefix_zero(integer_to_list(D)), " ",
+ prefix_zero(integer_to_list(H)), ":",
+ prefix_zero(integer_to_list(Min)), ":",
+ prefix_zero(integer_to_list(Sec))
+ ].
+
+prefix_zero([C]) -> [$0, C];
+prefix_zero([_,_] = Full) -> Full.