Merge from default.

This commit is contained in:
Simon MacMullen 2011-03-08 17:41:51 +00:00
commit fcb727cba4
12 changed files with 91 additions and 44 deletions

View File

@ -40,6 +40,7 @@ $(CHECKOUT_DIR):
rm -rf $(INCLUDE_DIR)/mochiweb
zip $(LIB_PACKAGE_NAME) $(LIB_PACKAGE_DIR)/
zip -r $(LIB_PACKAGE_NAME) $(LIB_PACKAGE_DIR)/$(EBIN_DIR)/
zip -r $(LIB_PACKAGE_NAME) $(LIB_PACKAGE_DIR)/$(INCLUDE_DIR)/
echo-revision:
@echo $(REVISION)

View File

@ -92,8 +92,14 @@ function fmt_color(r, thresholds) {
return 'green';
}
function fmt_rate(obj, name, show_total) {
return fmt_rate0(obj, name, fmt_num, show_total);
function fmt_rate(obj, name, show_total, cssClass) {
var res = fmt_rate0(obj, name, fmt_num, show_total);
if (cssClass == undefined || res == '') {
return res;
}
else {
return '<span class="' + cssClass + '">' + res + '</span>';
}
}
function fmt_rate_bytes(obj, name) {
@ -112,6 +118,24 @@ function fmt_rate0(obj, name, fmt, show_total) {
return res;
}
function is_stat_empty(obj, name) {
if (obj == undefined
|| obj[name] == undefined
|| obj[name + '_details'] == undefined
|| obj[name + '_details'].rate < 0.00001) return true;
return false;
}
function is_col_empty(channels, name) {
for (var i = 0; i < channels.length; i++) {
var channel = channels[i];
if (!is_stat_empty(channel.message_stats, name)) {
return false;
}
}
return true;
}
function fmt_exchange(name) {
return name == '' ? '<i>(AMQP default)</i>' : name;
}
@ -250,7 +274,9 @@ function message_rates(stats) {
var items = [['Publish', 'publish'], ['Confirm', 'confirm'],
['Deliver', 'deliver'], ['Acknowledge', 'ack'],
['Get', 'get'], ['Deliver (noack)', 'deliver_no_ack'],
['Get (noack)', 'get_no_ack']];
['Get (noack)', 'get_no_ack'],
['Return (mandatory)', 'return_unroutable'],
['Return (immediate)', 'return_not_delivered']];
for (var i in items) {
var name = items[i][0];
var key = items[i][1] + '_details';

View File

@ -1,4 +1,9 @@
<% if (channels.length > 0) { %>
<%
var col_return_unroutable = !is_col_empty(channels, 'return_unroutable');
var col_return_not_delivered = !is_col_empty(channels, 'return_not_delivered');
var ratesWidth = 4 + (col_return_unroutable ? 1 : 0) + (col_return_not_delivered ? 1 : 0);
%>
<table class="list">
<thead>
<tr>
@ -10,7 +15,7 @@
<th colspan="5">Details</th>
<% } %>
<% if (statistics_level == 'fine') { %>
<th colspan="4">Message rates</th>
<th colspan="<%= ratesWidth %>">Message rates</th>
<% } %>
</tr>
<tr>
@ -33,6 +38,12 @@
<th><%= fmt_sort('confirm', 'message_stats.confirm_details.rate') %></th>
<th><%= fmt_sort('deliver / get', 'message_stats.deliver_get_details.rate') %></th>
<th><%= fmt_sort('ack', 'message_stats.ack_details.rate') %></th>
<% if (col_return_unroutable) { %>
<th><%= fmt_sort('return (mandatory)', 'message_stats.return_unroutable_details.rate') %></th>
<% } %>
<% if (col_return_not_delivered) { %>
<th><%= fmt_sort('return (immediate)', 'message_stats.return_not_delivered_details.rate') %></th>
<% } %>
<% } %>
<% } else { %>
<!-- TODO make sortable after bug 23401 -->
@ -47,6 +58,12 @@
<th>confirm</th>
<th>deliver / get</th>
<th>ack</th>
<% if (col_return_unroutable) { %>
<th>return (mandatory)</th>
<% } %>
<% if (col_return_not_delivered) { %>
<th>return (immediate)</th>
<% } %>
<% } %>
<% } %>
</tr>
@ -84,6 +101,12 @@
<td class="r"><%= fmt_rate(channel.message_stats, 'confirm') %></td>
<td class="r"><%= fmt_rate(channel.message_stats, 'deliver_get') %></td>
<td class="r"><%= fmt_rate(channel.message_stats, 'ack') %></td>
<% if (col_return_unroutable) { %>
<td class="r"><%= fmt_rate(channel.message_stats, 'return_unroutable') %></td>
<% } %>
<% if (col_return_not_delivered) { %>
<td class="r"><%= fmt_rate(channel.message_stats, 'return_not_delivered') %></td>
<% } %>
<% } %>
</tr>
<% } %>

View File

@ -53,7 +53,7 @@
<div class="section-hidden">
<h2>Bindings</h2>
<div class="hider updatable">
<div class="hider">
<% if (exchange.name == "") { %>
<h3>Default exchange</h3>
<p>
@ -65,7 +65,7 @@
<% } else { %>
<% if (bindings_destination.length > 0) { %>
<h3>Incoming to <b><%= fmt_exchange(exchange.name) %></b></h3>
<table class="bindings">
<table class="bindings updatable">
<tr>
<td>
<%= format('bindings', {'mode': 'exchange_destination', 'bindings': bindings_destination}) %>
@ -78,7 +78,7 @@
</table>
<% } %>
<h3>Outgoing from <b><%= fmt_exchange(exchange.name) %></b></h3>
<table class="bindings">
<table class="bindings updatable">
<tr>
<td class="binding-endpoint">
<span class="object"><%= fmt_exchange(exchange.name) %></span>

View File

@ -26,8 +26,8 @@
<% } %>
<tr class="total">
<th>Total:</th>
<td><span class="mini-highlight"><%= fmt_rate(totals, 'deliver_get') %></span></td>
<td><span class="mini-highlight"><%= fmt_rate(totals, 'ack') %></span></td>
<td><%= fmt_rate(totals, 'deliver_get', false, 'mini-highlight') %></td>
<td><%= fmt_rate(totals, 'ack', false, 'mini-highlight') %></td>
</tr>
</table>
<% } else { %>

View File

@ -1,4 +1,8 @@
<h3><%= label %></h3>
<%
var col_return_unroutable = !is_stat_empty(totals, 'return_unroutable');
var col_return_not_delivered = !is_stat_empty(totals, 'return_not_delivered');
%>
<% if (object && object.length > 0) { %>
<table class="list list-with-total">
<tr>
@ -13,6 +17,12 @@
<% } %>
<th>publish</th>
<th>confirm</th>
<% if (col_return_unroutable) { %>
<th>return (mandatory)</th>
<% } %>
<% if (col_return_not_delivered) { %>
<th>return (immediate)</th>
<% } %>
</tr>
<%
for (var i = 0; i < object.length; i++) {
@ -31,12 +41,24 @@
<% } %>
<td class="r"><%= fmt_rate(pub.stats, 'publish') %></td>
<td class="r"><%= fmt_rate(pub.stats, 'confirm') %></td>
<% if (col_return_unroutable) { %>
<td class="r"><%= fmt_rate(pub.stats, 'return_unroutable') %></td>
<% } %>
<% if (col_return_not_delivered) { %>
<td class="r"><%= fmt_rate(pub.stats, 'return_not_delivered') %></td>
<% } %>
</tr>
<% } %>
<tr class="total">
<th>Total:</th>
<td><span class="mini-highlight"><%= fmt_rate(totals, 'publish') %></span></td>
<td><span class="mini-highlight"><%= fmt_rate(totals, 'confirm') %></span></td>
<td><%= fmt_rate(totals, 'publish', false, 'mini-highlight') %></td>
<td><%= fmt_rate(totals, 'confirm', false, 'mini-highlight') %></td>
<% if (col_return_unroutable) { %>
<td><%= fmt_rate(totals, 'return_unroutable', false, 'mini-highlight') %></td>
<% } %>
<% if (col_return_not_delivered) { %>
<td><%= fmt_rate(totals, 'return_not_delivered', false, 'mini-highlight') %></td>
<% } %>
</tr>
</table>
<% } else { %>

View File

@ -65,13 +65,13 @@
<%= link_node(node.name) %>
</td>
<% if (!node.running) { %>
<td class="status" colspan="5">
<td class="status" colspan="6">
<div class="red">
Node not running
</div>
</td>
<% } else if (node.external_stats_not_running) { %>
<td class="status" colspan="5">
<td class="status" colspan="6">
<div class="red">
Management agent not installed
</div>

View File

@ -105,9 +105,9 @@
<div class="section-hidden">
<h2>Bindings</h2>
<div class="hider updatable">
<div class="hider">
<h3>Incoming to <b><%= queue.name %></b></h3>
<table class="bindings">
<table class="bindings updatable">
<tr>
<td>
<%= format('bindings', {'mode': 'queue', 'bindings': bindings}) %>

View File

@ -37,7 +37,8 @@
?FINE_STATS_TYPES).
-define(DELIVER_GET, [deliver, deliver_no_ack, get, get_no_ack]).
-define(FINE_STATS, [publish, ack, deliver_get, confirm] ++ ?DELIVER_GET).
-define(FINE_STATS, [publish, ack, deliver_get, confirm,
return_unroutable, return_not_delivered] ++ ?DELIVER_GET).
-define(
FINE_STATS_CHANNEL_LIST,

View File

@ -25,7 +25,7 @@
-export([all_or_one_vhost/2, http_to_amqp/5, reply/3, filter_vhost/3]).
-export([filter_user/3, with_decode/5, redirect/2, args/1]).
-export([reply_list/3, reply_list/4, sort_list/4, destination_type/1]).
-export([relativise/2, post_respond/1]).
-export([post_respond/1]).
-include("rabbit_mgmt.hrl").
-include_lib("amqp_client/include/amqp_client.hrl").
@ -387,23 +387,6 @@ args({struct, L}) ->
args(L) ->
rabbit_mgmt_format:to_amqp_table(L).
relativise("/" ++ F, "/" ++ T) ->
From = string:tokens(F, "/"),
To = string:tokens(T, "/"),
relativise0(From, To).
relativise0([H], [H|_] = To) ->
string:join(To, "/");
relativise0([H|From], [H|To]) ->
relativise0(From, To);
relativise0(From, []) ->
relativise(From, [], 0);
relativise0(From, To) ->
relativise(From, To, 1).
relativise(From, To, Diff) ->
string:join(lists:duplicate(length(From) - Diff, "..") ++ To, "/").
%% Make replying to a post look like anything else...
post_respond({{halt, Code}, ReqData, Context}) ->
{{halt, Code}, ReqData, Context};

View File

@ -82,7 +82,7 @@ accept_content(ReqData, {_Mode, Context}) ->
rabbit_mgmt_util:with_decode(
[routing_key, arguments], ReqData, Context,
fun([Key, Args]) ->
Loc = rabbit_mgmt_util:relativise(
Loc = rabbit_mochiweb_util:relativise(
wrq:path(ReqData),
binary_to_list(
rabbit_mgmt_format:url(

View File

@ -48,15 +48,6 @@ pack_binding_test() ->
rabbit_mgmt_format:unpack_binding_props(<<"bad_routing">>),
ok.
relativise_test() ->
"baz" = rabbit_mgmt_util:relativise("/foo/bar/bash", "/foo/bar/baz"),
"../bax/baz" = rabbit_mgmt_util:relativise("/foo/bar/bash", "/foo/bax/baz"),
"../bax/baz" = rabbit_mgmt_util:relativise("/bar/bash", "/bax/baz"),
".." = rabbit_mgmt_util:relativise("/foo/bar/bash", "/foo/bar"),
"../.." = rabbit_mgmt_util:relativise("/foo/bar/bash", "/foo"),
"bar/baz" = rabbit_mgmt_util:relativise("/foo/bar", "/foo/bar/baz"),
ok.
amqp_table_test() ->
assert_table({struct, []}, []),
assert_table({struct, [{<<"x-expires">>, 1000}]},