diff options
author | Emile Joubert <emile@lshift.net> | 2008-11-24 20:28:22 +0000 |
---|---|---|
committer | Emile Joubert <emile@lshift.net> | 2008-11-24 20:28:22 +0000 |
commit | e50aed2bf07b7e5f71753e15fe5ae45a2ccf8555 (patch) | |
tree | e3a05ac1512bdf17013159cfae724d4804f08b9b | |
parent | 3b6c1fcece95e328a20e2996e615353ce7ca3467 (diff) | |
parent | 19e527607f379d9a706a66c0809252d8870b2bec (diff) | |
download | rabbitmq-server-e50aed2bf07b7e5f71753e15fe5ae45a2ccf8555.tar.gz |
Merge bug18381 into bug19684, tidying
-rw-r--r-- | packaging/Makefile | 3 | ||||
-rwxr-xr-x | packaging/checks.sh | 45 | ||||
-rw-r--r-- | packaging/debs/Debian/Makefile | 1 | ||||
-rw-r--r-- | src/rabbit_control.erl | 80 |
4 files changed, 79 insertions, 50 deletions
diff --git a/packaging/Makefile b/packaging/Makefile deleted file mode 100644 index 44a9b328..00000000 --- a/packaging/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -check_tools: - @sh ./checks.sh - @echo All the needed tools seem to be installed, great! diff --git a/packaging/checks.sh b/packaging/checks.sh deleted file mode 100755 index 63e88701..00000000 --- a/packaging/checks.sh +++ /dev/null @@ -1,45 +0,0 @@ -#! /bin/sh - -# We check for the presence of the tools necessary to build a release on a -# Debian based OS. - -TOOLS_STOP=0 - -checker () { - if [ ! `which $1` ] - then - echo "$1 is missing, please install it" - TOOLS_STOP=1 - NEW_NAME=`echo $1 | sed -e 's/-/_/g'` - eval "$NEW_NAME=1" - else - echo "$1 found" - fi -}; - -echo ~~~~~~~~~~~~ Looking for mandatory programs ~~~~~~~~~~~~ - -for i in cdbs-edit-patch reprepro rpm elinks wget zip gpg rsync -do - checker $i -done -echo ~~~~~~~~~~~~~~~~~~~~~~~~~~ DONE ~~~~~~~~~~~~~~~~~~~~~~~ - -if [ 1 = $TOOLS_STOP ] -then - [ $cdbs_edit_patch ] && cdbs_edit_patch="cdbs " - [ $reprepro ] && reprepro="reprepro " - [ $rpm ] && rpm="rpm " - [ $elinks ] && elinks="elinks " - [ $wget ] && wget="wget " - [ $zip ] && zip="zip " - [ $gpg ] && gpg="gpg " - [ $rsync ] && rsync="rsync " - - echo - echo We suggest you run the command - echo "apt-get install ${cdbs_edit_patch}${reprepro}${rpm}${elinks}${wget}${zip}${gpg}${rsync}" - echo -fi - -exit $TOOLS_STOP diff --git a/packaging/debs/Debian/Makefile b/packaging/debs/Debian/Makefile index 3e74cb52..9479feb0 100644 --- a/packaging/debs/Debian/Makefile +++ b/packaging/debs/Debian/Makefile @@ -16,7 +16,6 @@ all: @echo 'Please choose a target from the Makefile.' package: clean - make -C ../.. check_tools cp $(TARBALL_DIR)/$(TARBALL) $(DEBIAN_ORIG_TARBALL) tar -zxvf $(DEBIAN_ORIG_TARBALL) cp -r debian $(UNPACKED_DIR) diff --git a/src/rabbit_control.erl b/src/rabbit_control.erl index bc588279..d4906d8f 100644 --- a/src/rabbit_control.erl +++ b/src/rabbit_control.erl @@ -89,12 +89,34 @@ Available commands: list_user_vhosts <UserName> list_vhost_users <VHostPath> + list_queues <QueueInfoItem> [<QueueInfoItem> ...] + list_exchanges <ExchangeInfoItem> [<ExchangeInfoItem> ...] + list_bindings + list_connections <ConnectionInfoItem> [<ConnectionInfoItem> ...] + <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 \"server.example.com\", the master node will usually be rabbit@server (unless 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. +<QueueInfoItem> must be a member of the list [name, durable, auto_delete, +arguments, pid, messages_ready, messages_unacknowledged, messages_uncommitted, +messages, acks_uncommitted, consumers, transactions, memory]. The default is + to display name and (number of) messages. + +<ExchangeInfoItem> must be a member of the list [name, type, durable, +auto_delete, arguments]. The default is to display name and type. + +The output format for \"list_bindings\" is a list of rows containing +virtual host, exchange name, routing key, queue name and arguments, in that +order. + +<ConnectioInfoItem> must be a member of the list [pid, address, port, +peer_address, peer_port, state, channels, user, vhost, timeout, frame_max, +recv_oct, recv_cnt, send_oct, send_cnt, send_pend]. The default is to display +user, peer_address and peer_port. + "), halt(1). @@ -179,7 +201,63 @@ action(list_user_vhosts, Node, Args = [_Username]) -> 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})). + display_list(call(Node, {rabbit_access_control, list_vhost_users, Args})); + +action(list_queues, Node, Args) -> + io:format("Listing queues ...~n"), + ArgAtoms = [list_to_atom(X) || X <- default_if_empty(Args, ["name", "messages"])], + display_info_list(rpc_call(Node, rabbit_amqqueue, info_all, [ArgAtoms]), ArgAtoms); + +action(list_exchanges, Node, Args) -> + io:format("Listing exchanges ...~n"), + ArgAtoms = [list_to_atom(X) || X <- default_if_empty(Args, ["name", "type"])], + display_info_list(rpc_call(Node, rabbit_exchange, info_all, [ArgAtoms]), ArgAtoms); + +action(list_bindings, Node, []) -> + io:format("Listing bindings ...~n"), + lists:map( + fun({#resource{name = ExchangeName, virtual_host = VirtualHost}, + #resource{name = QueueName, virtual_host = VirtualHost}, + RoutingKey, Arguments}) -> + io:format("~s@~s ~s ~s@~s ~w~n", + [ExchangeName, VirtualHost, RoutingKey, QueueName, VirtualHost, Arguments]) + end, + rpc_call(Node, rabbit_exchange, list_bindings, [])), + ok; + +action(list_connections, Node, Args) -> + io:format("Listing connections ...~n"), + ArgAtoms = [list_to_atom(X) || X <- default_if_empty(Args, ["user", "peer_address", "peer_port"])], + display_info_list(rpc_call(Node, rabbit_networking, connection_info_all, [ArgAtoms]), ArgAtoms). + +default_if_empty(List, Default) when is_list(List) -> + case List of + [] -> Default; + _ -> List + end. + +display_info_list(Results, InfoItemArgs) when is_list(Results) -> + lists:map( + fun (ResultRow) -> + lists:foreach( + fun(InfoItemName) -> + {value, Info = {InfoItemName, Data}} = lists:keysearch(InfoItemName, 1, ResultRow), + case Info of + {_, #resource{virtual_host = VHostPath, name = Name}} -> + io:format("~s@~s ", [Name, VHostPath]); + {Key, IpAddress} when Key =:= address; Key =:= peer_address andalso is_tuple(IpAddress) -> + io:format("~s ", [inet_parse:ntoa(IpAddress)]); + _ when is_binary(Data) -> + io:format("~s ", [Data]); + _ -> + io:format("~w ", [Data]) + end + end, + InfoItemArgs), + io:nl() + end, + Results), + ok. display_list(L) when is_list(L) -> lists:foreach(fun (I) -> |