summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2014-10-01 17:27:21 +0100
committerSimon MacMullen <simon@rabbitmq.com>2014-10-01 17:27:21 +0100
commit11c0e14d63c5d0cae43bd047d76438dc2f118251 (patch)
tree278967d5829d3355a5e6fca7f67c25a787d2f38c
parent52c11cfa28c5b416600c6ee0f9a09e599d3d956b (diff)
downloadrabbitmq-server-11c0e14d63c5d0cae43bd047d76438dc2f118251.tar.gz
Present memory and aggregated binaries in the same way.
-rw-r--r--src/rabbit_vm.erl27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/rabbit_vm.erl b/src/rabbit_vm.erl
index 4b4a9ed8..f15202bd 100644
--- a/src/rabbit_vm.erl
+++ b/src/rabbit_vm.erl
@@ -39,7 +39,7 @@ memory() ->
lists:append(All), distinguishers(), [memory]),
[Qs, QsSlave, Conns, MsgIndexProc, MgmtDbProc, Plugins] =
- [aggregate_memory(Names, Sums)
+ [aggregate(Names, Sums, memory, fun (X) -> X end)
|| Names <- distinguished_interesting_sups()],
Mnesia = mnesia_memory(),
@@ -66,7 +66,7 @@ memory() ->
{other_proc, lists:max([0, OtherProc])}, %% [1]
{mnesia, Mnesia},
{mgmt_db, MgmtDbETS + MgmtDbProc},
- {msg_index, MsgIndexETS + MsgIndexProc},
+ {msg_index, MsgIndexETS + MsgIndexProc},
{other_ets, ETS - Mnesia - MsgIndexETS - MgmtDbETS},
{binary, Bin},
{code, Code},
@@ -88,7 +88,16 @@ binary() ->
sets:add_element({Ptr, Sz}, Acc0)
end, Acc, Info)
end, distinguishers(), [{binary, sets:new()}]),
- [{K, aggregate_binary(V)} || {K, V} <- Sums ++ [{unknown, Rest}]].
+ [Other, Qs, QsSlave, Conns, MsgIndexProc, MgmtDbProc, Plugins] =
+ [aggregate(Names, [{other, Rest} | Sums], binary, fun sum_binary/1)
+ || Names <- [[other] | distinguished_interesting_sups()]],
+ [{connection_procs, Conns},
+ {queue_procs, Qs},
+ {queue_slave_procs, QsSlave},
+ {plugins, Plugins},
+ {mgmt_db, MgmtDbProc},
+ {msg_index, MsgIndexProc},
+ {other, Other}].
%%----------------------------------------------------------------------------
@@ -148,17 +157,17 @@ process_name(Pid) ->
is_plugin("rabbitmq_" ++ _) -> true;
is_plugin(App) -> lists:member(App, ?MAGIC_PLUGINS).
-aggregate_memory(Names, Sums) ->
- lists:sum([extract_memory(Name, Sums) || Name <- Names]).
+aggregate(Names, Sums, Key, Fun) ->
+ lists:sum([extract(Name, Sums, Key, Fun) || Name <- Names]).
-extract_memory(Name, Sums) ->
+extract(Name, Sum, Key, Fun) ->
case keyfind(Name, Sums) of
- {value, Accs} -> keyfetch(memory, Accs);
+ {value, Accs} -> Fun(keyfetch(Key, Accs));
false -> 0
end.
-aggregate_binary([{binary, Set}]) ->
- sets:fold(fun({_Ptr, Sz}, Acc) -> Acc + Sz end, 0, Set).
+sum_binary(Set) ->
+ sets:fold(fun({_Pt, Sz}, Acc) -> Acc + Sz end, 0, Set).
queue_type(PDict) ->
case keyfind(process_name, PDict) of