summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmile Joubert <emile@lshift.net>2008-11-11 21:18:12 +0000
committerEmile Joubert <emile@lshift.net>2008-11-11 21:18:12 +0000
commitc20d4e8033060497dc4843e47f09134a79914970 (patch)
treeb2385b2f2c857e8333602d507f761f877ad82439
parentc1b8b1d3a075df2514b2eed9f15ecf2593fbd265 (diff)
downloadrabbitmq-server-c20d4e8033060497dc4843e47f09134a79914970.tar.gz
Removed memory queries, only report on selected queue details
-rw-r--r--src/rabbit_amqqueue.erl18
-rw-r--r--src/rabbit_control.erl41
-rw-r--r--src/rabbit_misc.erl14
3 files changed, 27 insertions, 46 deletions
diff --git a/src/rabbit_amqqueue.erl b/src/rabbit_amqqueue.erl
index 6f846daf..67b2ab9b 100644
--- a/src/rabbit_amqqueue.erl
+++ b/src/rabbit_amqqueue.erl
@@ -105,8 +105,8 @@
-spec(internal_delete/1 :: (queue_name()) -> 'ok' | not_found()).
-spec(on_node_down/1 :: (node()) -> 'ok').
-spec(pseudo_queue/2 :: (binary(), pid()) -> amqqueue()).
--spec(info_queue_sorted/2 :: (info_key(), non_neg_integer()) -> [{amqqueue(), info()}]).
--spec(info_queue_sorted/1 :: (info_key()) -> [{amqqueue(), info()}]).
+-spec(info_queue_sorted/1 :: ([info_key()]) -> [{amqqueue(), [info()]}]).
+-spec(info_queue_sorted/2 :: (non_neg_integer(), [info_key()]) -> [{amqqueue(), [info()]}]).
-endif.
@@ -339,17 +339,17 @@ safe_pmap_ok(H, F, L) ->
Errors -> {error, Errors}
end.
-
info_lookup({#amqqueue{}, InfoTupleList}, InfoKey) ->
case lists:keysearch(InfoKey, 1, InfoTupleList) of
- false -> {error, not_found};
+ false -> throw({bad_argument, InfoKey});
{value, {InfoKey, InfoValue}} -> InfoValue
end.
%% TODO: avoid sorting if Length is much less than the number of queues
-info_queue_sorted(InfoKey) ->
- lists:sort(fun(A, B) -> info_lookup(A, InfoKey) > info_lookup(B, InfoKey) end,
- rabbit_amqqueue:info_all()).
-info_queue_sorted(InfoKey, Length) ->
- lists:sublist(info_queue_sorted(InfoKey), Length).
+info_queue_sorted(InfoItems = [SortItem | _]) ->
+ lists:sort(fun(A, B) -> info_lookup(A, SortItem) > info_lookup(B, SortItem) end,
+ rabbit_amqqueue:info_all(InfoItems)).
+
+info_queue_sorted(Length, InfoItems) ->
+ lists:sublist(info_queue_sorted(InfoItems), Length).
diff --git a/src/rabbit_control.erl b/src/rabbit_control.erl
index 6589c384..d7c6d254 100644
--- a/src/rabbit_control.erl
+++ b/src/rabbit_control.erl
@@ -89,11 +89,8 @@ Available commands:
list_user_vhosts <UserName>
list_vhost_users <VHostPath>
- set_memory_threshold <Percentage>
- get_memory_consumption
+ list_queues [-l <ResultSize>] <InfoItem> [<InfoItem> ...]
- list_queues
- list_deepest_queues
<node> should be the name of the master node of the RabbitMQ cluster. It
defaults to the node named \"rabbit\" on the local host. On a host named
@@ -101,6 +98,11 @@ defaults to the node named \"rabbit\" on the local host. On a host named
NODENAME has been set to some non-default value at broker startup time). The
output of hostname -s is usually the correct suffix to use after the \"@\" sign.
+<InfoItem> must be a member of the list [messages_ready,
+messages_unacknowledged, messages_uncommitted, messages, acks_uncommitted,
+consumers, transactions, memory]. At most <ResultSize> queues will be listed,
+in descending order of the first <InfoItem>.
+
"),
halt(1).
@@ -187,25 +189,18 @@ action(list_vhost_users, Node, Args = [_VHostPath]) ->
io:format("Listing users for vhosts ~p...", Args),
display_list(call(Node, {rabbit_access_control, list_vhost_users, Args}));
-action(set_memory_threshold, Node, Args) ->
- io:format("% Setting memory threshold to ~p ...~n", Args),
- rpc_call(Node, rabbit_misc, set_memory_threshold, Args);
-
-action(get_memory_consumption, Node, []) ->
- io:format("% Getting memory consumption ...~n", []),
- Res = rpc_call(Node, rabbit_misc, get_memory_consumption, []),
- io:format("~p~n", [Res]);
-
-action(list_queues, Node, []) ->
- io:format("Listing all queues ..."),
- Res = rpc_call(Node, rabbit_amqqueue, info_all, []),
- io:format("~p~n", [Res]),
- ok;
-
-action(list_deepest_queues, Node, Args = [Depth]) ->
- io:format("Listing ~p deepest queues ...~n", Args),
- Res = rpc_call(Node, rabbit_amqqueue, info_queue_sorted, [messages, list_to_integer(Depth)]),
- io:format("~p~n", [Res]),
+action(list_queues, Node, Args) ->
+ io:format("Listing queues ...~n"),
+ Res =
+ case Args of
+ ["-l", Length | InfoItems] ->
+ rpc_call(Node, rabbit_amqqueue, info_queue_sorted,
+ [list_to_integer(Length), [list_to_atom(X) || X <- InfoItems]]);
+ InfoItems ->
+ rpc_call(Node, rabbit_amqqueue, info_queue_sorted,
+ [[list_to_atom(X) || X <- InfoItems]])
+ end,
+ io:format("~n~p~n", [Res]),
ok.
display_list(L) when is_list(L) ->
diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl
index a807c6e9..2c134002 100644
--- a/src/rabbit_misc.erl
+++ b/src/rabbit_misc.erl
@@ -43,7 +43,6 @@
-export([guid/0, string_guid/1, binstring_guid/1]).
-export([dirty_read_all/1, dirty_foreach_key/2, dirty_dump_log/1]).
-export([append_file/2]).
--export([set_memory_threshold/1, get_memory_consumption/0]).
-import(mnesia).
-import(lists).
@@ -100,8 +99,6 @@
-spec(dirty_dump_log/1 :: (string()) -> 'ok' | {'error', any()}).
-spec(append_file/2 :: (string(), string()) -> 'ok' | {'error', any()}).
--spec(get_memory_consumption/0 :: () -> ({non_neg_integer(), non_neg_integer()})).
--spec(set_memory_threshold/1 :: (string()) -> 'ok' | {'error', any()}).
-endif.
%%----------------------------------------------------------------------------
@@ -373,14 +370,3 @@ append_file(File, _, Suffix) ->
Error -> Error
end.
-set_memory_threshold(Level) ->
- case Res = string:to_float(Level) of
- {error, _} -> Res;
- {_Percentage, [_]} -> {error, unexpected_suffix};
- {Percentage, _} -> memsup:set_sysmem_high_watermark(Percentage)
- end.
-
-get_memory_consumption() ->
- {Total, Allocated, _Worst} = memsup:get_memory_data(),
- {Total, Allocated}.
-