Add counts of exchanges / queues / connections / channels / consumers

This commit is contained in:
Simon MacMullen 2012-08-22 13:36:08 +01:00
parent 4d0121be84
commit e16baac28f
4 changed files with 40 additions and 6 deletions

View File

@ -81,6 +81,9 @@ td.l { text-align: left !important; }
td.c { text-align: center !important; } td.c { text-align: center !important; }
td.r { text-align: right !important; } td.r { text-align: right !important; }
p.mini-stats { margin-bottom: 20px; }
p.mini-stats span { margin-right: 10px; }
p.status-ok { color: #888; text-align: right; } p.status-ok { color: #888; text-align: right; }
p.status-error { background: #f44; border: 1px solid #800; color: white; margin-top: 50px !important; } p.status-error { background: #f44; border: 1px solid #800; color: white; margin-top: 50px !important; }
p.warning, div.form-popup-warn { background: #ff8; border: 1px solid #bb8; } p.warning, div.form-popup-warn { background: #ff8; border: 1px solid #bb8; }

View File

@ -52,6 +52,15 @@ if (version_warning) {
<h2>Totals</h2> <h2>Totals</h2>
<div class="hider updatable"> <div class="hider updatable">
<% if (overview.statistics_db_node != 'not_running') { %> <% if (overview.statistics_db_node != 'not_running') { %>
<p class="mini-stats">
<span>Connections: <b><%= overview.object_totals.connections %></b></span>
<span>Channels: <b><%= overview.object_totals.channels %></b></span>
<span>Exchanges: <b><%= overview.object_totals.exchanges %></b></span>
<span>Queues: <b><%= overview.object_totals.queues %></b></span>
<% if (overview.object_totals['consumers'] != undefined) { %>
<span>Consumers: <b><%= overview.object_totals.consumers %></b></span>
<% } %>
</p>
<h3>Queued messages <span class="help" id="queued-messages"></span></h3> <h3>Queued messages <span class="help" id="queued-messages"></span></h3>
<div class="box"> <div class="box">
<%= queue_length(overview.queue_totals, 'Ready', 'messages_ready') %> <%= queue_length(overview.queue_totals, 'Ready', 'messages_ready') %>

View File

@ -272,7 +272,8 @@ handle_call({get_overview, User}, _From, State = #state{tables = Tables}) ->
Qs0 = [rabbit_mgmt_format:queue(Q) || V <- VHosts, Qs0 = [rabbit_mgmt_format:queue(Q) || V <- VHosts,
Q <- rabbit_amqqueue:list(V)], Q <- rabbit_amqqueue:list(V)],
Qs1 = basic_queue_stats(Qs0, State), Qs1 = basic_queue_stats(Qs0, State),
Totals = sum(Qs1, ?OVERVIEW_QUEUE_STATS), QueueTotals = sum(Qs1, ?OVERVIEW_QUEUE_STATS),
Filter = fun(Id, Name) -> Filter = fun(Id, Name) ->
lists:member(pget(vhost, pget(Name, Id)), VHosts) lists:member(pget(vhost, pget(Name, Id)), VHosts)
end, end,
@ -285,8 +286,27 @@ handle_call({get_overview, User}, _From, State = #state{tables = Tables}) ->
end, end,
Publish = F(channel_exchange_stats, exchange), Publish = F(channel_exchange_stats, exchange),
Consume = F(channel_queue_stats, queue_details), Consume = F(channel_queue_stats, queue_details),
F2 = case User of
all -> fun (L) -> length(L) end;
_ -> fun (L) -> length(rabbit_mgmt_util:filter_user(L, User)) end
end,
%% Filtering out the user's consumers would be rather expensive so let's
%% just not show it
Consumers = case User of
all -> [{consumers,
ets:info(orddict:fetch(consumers, Tables), size)}];
_ -> []
end,
ObjectTotals = Consumers ++
[{queues, length(Qs0)},
{exchanges, length([X || V <- VHosts,
X <- rabbit_exchange:list(V)])},
{connections, F2(created_events(connection_stats, Tables))},
{channels, F2(created_events(channel_stats, Tables))}],
reply([{message_stats, Publish ++ Consume}, reply([{message_stats, Publish ++ Consume},
{queue_totals, Totals}], State); {queue_totals, QueueTotals},
{object_totals, ObjectTotals}], State);
handle_call(_Request, _From, State) -> handle_call(_Request, _From, State) ->
reply(not_understood, State). reply(not_understood, State).

View File

@ -27,8 +27,8 @@
-export([with_channel/4, with_channel/5]). -export([with_channel/4, with_channel/5]).
-export([props_to_method/2, props_to_method/4]). -export([props_to_method/2, props_to_method/4]).
-export([all_or_one_vhost/2, http_to_amqp/5, reply/3, filter_vhost/3]). -export([all_or_one_vhost/2, http_to_amqp/5, reply/3, filter_vhost/3]).
-export([filter_conn_ch_list/3, with_decode/5, decode/1, decode/2, redirect/2, -export([filter_conn_ch_list/3, filter_user/2]).
args/1]). -export([with_decode/5, decode/1, decode/2, redirect/2, args/1]).
-export([reply_list/3, reply_list/4, sort_list/2, destination_type/1]). -export([reply_list/3, reply_list/4, sort_list/2, destination_type/1]).
-export([post_respond/1, columns/1, want_column/2, is_monitor/1]). -export([post_respond/1, columns/1, want_column/2, is_monitor/1]).
-export([list_visible_vhosts/1, b64decode_or_throw/1]). -export([list_visible_vhosts/1, b64decode_or_throw/1]).
@ -388,8 +388,10 @@ filter_vhost(List, _ReqData, Context) ->
VHosts = list_login_vhosts(Context#context.user), VHosts = list_login_vhosts(Context#context.user),
[I || I <- List, lists:member(pget(vhost, I), VHosts)]. [I || I <- List, lists:member(pget(vhost, I), VHosts)].
filter_user(List, _ReqData, filter_user(List, _ReqData, #context{user = User}) ->
#context{user = #user{username = Username, tags = Tags}}) -> filter_user(List, User).
filter_user(List, #user{username = Username, tags = Tags}) ->
case is_monitor(Tags) of case is_monitor(Tags) of
true -> List; true -> List;
false -> [I || I <- List, pget(user, I) == Username] false -> [I || I <- List, pget(user, I) == Username]