diff --git a/deps/rabbitmq_management/priv/www/js/charts.js b/deps/rabbitmq_management/priv/www/js/charts.js index 6fa177d6c0..afe7cee6a2 100644 --- a/deps/rabbitmq_management/priv/www/js/charts.js +++ b/deps/rabbitmq_management/priv/www/js/charts.js @@ -12,22 +12,22 @@ function message_rates(id, stats) { ['Get', 'get'], ['Deliver (noack)', 'deliver_no_ack'], ['Get (noack)', 'get_no_ack'], ['Return', 'return_unroutable']]; - return rates_chart_or_text(id, stats, items, fmt_rate, fmt_rate_large, fmt_rate_axis, true, 'Message rates', 'message-rates'); + return rates_chart_or_text(id, stats, items, fmt_rate, fmt_rate_axis, true, 'Message rates', 'message-rates'); } function queue_lengths(id, stats) { var items = [['Ready', 'messages_ready'], ['Unacked', 'messages_unacknowledged'], ['Total', 'messages']]; - return rates_chart_or_text(id, stats, items, fmt_msgs, fmt_msgs_large, fmt_num_axis, false, 'Queued messages', 'queued-messages'); + return rates_chart_or_text(id, stats, items, fmt_num_thousands, fmt_plain_axis, false, 'Queued messages', 'queued-messages'); } function data_rates(id, stats) { var items = [['From client', 'recv_oct'], ['To client', 'send_oct']]; - return rates_chart_or_text(id, stats, items, fmt_rate_bytes, fmt_rate_bytes_large, fmt_rate_bytes_axis, true, 'Data rates'); + return rates_chart_or_text(id, stats, items, fmt_rate_bytes, fmt_rate_bytes_axis, true, 'Data rates'); } -function rates_chart_or_text(id, stats, items, chart_fmt, text_fmt, axis_fmt, chart_rates, +function rates_chart_or_text(id, stats, items, fmt, axis_fmt, chart_rates, heading, heading_help) { var mode = get_pref('rate-mode-' + id); var range = get_pref('chart-range'); @@ -37,10 +37,10 @@ function rates_chart_or_text(id, stats, items, chart_fmt, text_fmt, axis_fmt, ch if (keys(stats).length > 0) { if (mode == 'chart') { res = rates_chart( - id, id, items, stats, chart_fmt, axis_fmt, 'full', chart_rates); + id, id, items, stats, fmt, axis_fmt, 'full', chart_rates); } else { - res = rates_text(items, stats, mode, text_fmt); + res = rates_text(items, stats, mode, fmt, chart_rates); } if (res == "") res = '

Waiting for data...

'; } @@ -79,7 +79,7 @@ function node_stat_count(used_key, limit_key, stats, thresholds) { var limit = stats[limit_key]; if (typeof used == 'number') { return node_stat(used_key, 'Used', limit_key, 'available', stats, - fmt_num_obj, fmt_num_axis, + fmt_plain, fmt_plain_axis, fmt_color(used / limit, thresholds)); } else { return used; @@ -91,19 +91,20 @@ function node_stat_count_bar(used_key, limit_key, stats, thresholds) { var limit = stats[limit_key]; if (typeof used == 'number') { return node_stat_bar(used_key, limit_key, 'available', stats, - fmt_num_axis, fmt_color(used / limit, thresholds)); + fmt_plain_axis, + fmt_color(used / limit, thresholds)); } else { return used; } } -function node_stat(used_key, used_name, limit_key, suffix, stats, rate_fmt, +function node_stat(used_key, used_name, limit_key, suffix, stats, fmt, axis_fmt, colour, help, invert) { if (get_pref('rate-mode-node-stats') == 'chart') { var items = [[used_name, used_key], ['Limit', limit_key]]; add_fake_limit_details(used_key, limit_key, stats); return rates_chart('node-stats', 'node-stats-' + used_key, items, stats, - rate_fmt, axis_fmt, 'node', false); + fmt, axis_fmt, 'node', false); } else { return node_stat_bar(used_key, limit_key, suffix, stats, axis_fmt, colour, help, invert); @@ -156,7 +157,7 @@ function node_stats_prefs() { return chart_h3('node-stats', 'Node statistics'); } -function rates_chart(type_id, id, items, stats, rate_fmt, axis_fmt, type, +function rates_chart(type_id, id, items, stats, fmt, axis_fmt, type, chart_rates) { function show(key) { return get_pref('chart-line-' + id + key) === 'true'; @@ -177,9 +178,11 @@ function rates_chart(type_id, id, items, stats, rate_fmt, axis_fmt, type, chart_data[id]['data'][name] = stats[key_details]; chart_data[id]['data'][name].ix = ix; } + var value = chart_rates ? pick_rate(fmt, stats, key) : + pick_abs(fmt, stats, key); legend.push({name: name, key: key, - value: rate_fmt(stats, key), + value: value, show: show(key)}); ix++; } @@ -201,7 +204,7 @@ function rates_chart(type_id, id, items, stats, rate_fmt, axis_fmt, type, return legend.length > 0 ? html : ''; } -function rates_text(items, stats, mode, rate_fmt) { +function rates_text(items, stats, mode, fmt, chart_rates) { var res = ''; for (var i in items) { var name = items[i][0]; @@ -209,9 +212,10 @@ function rates_text(items, stats, mode, rate_fmt) { var key_details = key + '_details'; if (key_details in stats) { var details = stats[key_details]; - res += '
' + name; - res += rate_fmt(stats, key, mode); - res += '
'; + res += '
' + name + ''; + res += chart_rates ? pick_rate(fmt, stats, key, mode) : + pick_abs(fmt, stats, key, mode); + res += '
'; } } return res == '' ? '' : '
' + res + '
'; diff --git a/deps/rabbitmq_management/priv/www/js/formatters.js b/deps/rabbitmq_management/priv/www/js/formatters.js index 3a90fe3817..b929cde357 100644 --- a/deps/rabbitmq_management/priv/www/js/formatters.js +++ b/deps/rabbitmq_management/priv/www/js/formatters.js @@ -12,11 +12,6 @@ function fmt_string(str, unknown) { return fmt_escape_html("" + str); } -function fmt_bytes(bytes) { - if (bytes == undefined) return UNKNOWN_REPR; - return fmt_si_prefix(bytes, bytes, 1024, false) + 'B'; -} - function fmt_si_prefix(num0, max0, thousand, allow_fractions) { if (num == 0) return 0; @@ -227,71 +222,51 @@ function fmt_percent(num) { } } -function fmt_rate(obj, name, mode) { - var raw = fmt_rate0(obj, name, mode, fmt_rate_num); - return raw == '' ? '' : (raw + '/s'); -} - -function fmt_rate_bytes(obj, name, mode) { - var raw = fmt_rate0(obj, name, mode, fmt_bytes); - return raw == '' ? '' : (raw + '/s' + - '(' + fmt_bytes(obj[name]) + ' total)'); -} - -function fmt_bytes_obj(obj, name, mode) { - return fmt_bytes(obj[name]); -} - -function fmt_num_obj(obj, name, mode) { - return obj[name]; -} - -function fmt_rate_large(obj, name, mode) { - return '' + fmt_rate0(obj, name, mode, fmt_rate_num) + - 'msg/s'; -} - -function fmt_rate_bytes_large(obj, name, mode) { - return '' + fmt_rate0(obj, name, mode, fmt_bytes) + '/s' + - '(' + fmt_bytes(obj[name]) + ' total)'; -} - -function fmt_rate0(obj, name, mode, fmt) { +function pick_rate(fmt, obj, name, mode) { if (obj == undefined || obj[name] == undefined || obj[name + '_details'] == undefined) return ''; var details = obj[name + '_details']; return fmt(mode == 'avg' ? details.avg_rate : details.rate); } -function fmt_msgs(obj, name, mode) { - return fmt_msgs0(obj, name, mode) + ' msg'; -} - -function fmt_msgs_large(obj, name, mode) { - return '' + fmt_msgs0(obj, name, mode) + '' + - fmt_rate0(obj, name, mode, fmt_msgs_rate); -} - -function fmt_msgs0(obj, name, mode) { +function pick_abs(fmt, obj, name, mode) { if (obj == undefined || obj[name] == undefined || obj[name + '_details'] == undefined) return ''; var details = obj[name + '_details']; - return mode == 'avg' ? fmt_rate_num(details.avg) : - fmt_num_thousands(obj[name]); + return fmt(mode == 'avg' ? details.avg : obj[name]); } -function fmt_msgs_rate(num) { - if (num > 0) return '+' + fmt_rate_num(num) + ' msg/s'; - else if (num < 0) return '-' + fmt_rate_num(-num) + ' msg/s'; - else return ' '; +function fmt_detail_rate(obj, name, mode) { + return pick_rate(fmt_rate, name, mode); +} + +function fmt_detail_rate_bytes(obj, name, mode) { + return pick_rate(fmt_rate_bytes, name, mode); +} + +// --------------------------------------------------------------------- + +// These are pluggable for charts etc + +function fmt_plain(num) { + return num; +} + +function fmt_plain_axis(num, max) { + return fmt_si_prefix(num, max, 1000, true); +} + +function fmt_rate(num) { + return fmt_rate_num(num) + '/s'; } function fmt_rate_axis(num, max) { - return fmt_si_prefix(num, max, 1000, true) + '/s'; + return fmt_plain_axis(num, max) + '/s'; } -function fmt_num_axis(num, max) { - return fmt_si_prefix(num, max, 1000, true); +function fmt_bytes(bytes) { + if (bytes == undefined) return UNKNOWN_REPR; + return fmt_si_prefix(bytes, bytes, 1024, false) + 'B'; } function fmt_bytes_axis(num, max) { @@ -299,11 +274,20 @@ function fmt_bytes_axis(num, max) { return fmt_bytes(isNaN(num) ? 0 : num); } +function fmt_rate_bytes(num) { + return fmt_bytes(num) + '/s'; +} function fmt_rate_bytes_axis(num, max) { return fmt_bytes_axis(num, max) + '/s'; } +function fmt_ms(num) { + return fmt_rate_num(num) + 'ms'; +} + +// --------------------------------------------------------------------- + function fmt_maybe_vhost(name) { return vhosts_interesting ? ' in virtual host ' + fmt_escape_html(name) + '' diff --git a/deps/rabbitmq_management/priv/www/js/tmpl/channels-list.ejs b/deps/rabbitmq_management/priv/www/js/tmpl/channels-list.ejs index 96442b9167..591a7c04b2 100644 --- a/deps/rabbitmq_management/priv/www/js/tmpl/channels-list.ejs +++ b/deps/rabbitmq_management/priv/www/js/tmpl/channels-list.ejs @@ -167,22 +167,22 @@ <% } %> <% if (rates_mode != 'none') { %> <% if (show_column('channels', 'rate-publish')) { %> - <%= fmt_rate(channel.message_stats, 'publish') %> + <%= fmt_detail_rate(channel.message_stats, 'publish') %> <% } %> <% if (show_column('channels', 'rate-confirm')) { %> - <%= fmt_rate(channel.message_stats, 'confirm') %> + <%= fmt_detail_rate(channel.message_stats, 'confirm') %> <% } %> <% if (show_column('channels', 'rate-return')) { %> - <%= fmt_rate(channel.message_stats, 'return_unroutable') %> + <%= fmt_detail_rate(channel.message_stats, 'return_unroutable') %> <% } %> <% if (show_column('channels', 'rate-deliver')) { %> - <%= fmt_rate(channel.message_stats, 'deliver_get') %> + <%= fmt_detail_rate(channel.message_stats, 'deliver_get') %> <% } %> <% if (show_column('channels', 'rate-redeliver')) { %> - <%= fmt_rate(channel.message_stats, 'redeliver') %> + <%= fmt_detail_rate(channel.message_stats, 'redeliver') %> <% } %> <% if (show_column('channels', 'rate-ack')) { %> - <%= fmt_rate(channel.message_stats, 'ack') %> + <%= fmt_detail_rate(channel.message_stats, 'ack') %> <% } %> <% } %> diff --git a/deps/rabbitmq_management/priv/www/js/tmpl/connections.ejs b/deps/rabbitmq_management/priv/www/js/tmpl/connections.ejs index af5120f814..317328185e 100644 --- a/deps/rabbitmq_management/priv/www/js/tmpl/connections.ejs +++ b/deps/rabbitmq_management/priv/www/js/tmpl/connections.ejs @@ -115,10 +115,10 @@ <%= fmt_client_name(connection.client_properties) %> <% } %> <% if (show_column('connections', 'from_client')) { %> - <%= fmt_rate_bytes(connection, 'recv_oct') %> + <%= fmt_detail_rate_bytes(connection, 'recv_oct') %> <% } %> <% if (show_column('connections', 'to_client')) { %> - <%= fmt_rate_bytes(connection, 'send_oct') %> + <%= fmt_detail_rate_bytes(connection, 'send_oct') %> <% } %> <% if (show_column('connections', 'heartbeat')) { %> <%= fmt_time(connection.timeout, 's') %> diff --git a/deps/rabbitmq_management/priv/www/js/tmpl/exchanges.ejs b/deps/rabbitmq_management/priv/www/js/tmpl/exchanges.ejs index a6d5c84554..58589d5d6f 100644 --- a/deps/rabbitmq_management/priv/www/js/tmpl/exchanges.ejs +++ b/deps/rabbitmq_management/priv/www/js/tmpl/exchanges.ejs @@ -64,10 +64,10 @@ <% } %> <% if (rates_mode != 'none') { %> <% if (show_column('exchanges', 'rate-in')) { %> - <%= fmt_rate(exchange.message_stats, 'publish_in') %> + <%= fmt_detail_rate(exchange.message_stats, 'publish_in') %> <% } %> <% if (show_column('exchanges', 'rate-out')) { %> - <%= fmt_rate(exchange.message_stats, 'publish_out') %> + <%= fmt_detail_rate(exchange.message_stats, 'publish_out') %> <% } %> <% } %> diff --git a/deps/rabbitmq_management/priv/www/js/tmpl/msg-detail-deliveries.ejs b/deps/rabbitmq_management/priv/www/js/tmpl/msg-detail-deliveries.ejs index c3ded25e60..ee9e6f6500 100644 --- a/deps/rabbitmq_management/priv/www/js/tmpl/msg-detail-deliveries.ejs +++ b/deps/rabbitmq_management/priv/www/js/tmpl/msg-detail-deliveries.ejs @@ -20,8 +20,8 @@ <% } else { %> <%= link_queue(del.queue.vhost, del.queue.name) %> <% } %> - <%= fmt_rate(del.stats, 'deliver_get') %> - <%= fmt_rate(del.stats, 'ack') %> + <%= fmt_detail_rate(del.stats, 'deliver_get') %> + <%= fmt_detail_rate(del.stats, 'ack') %> <% } %> diff --git a/deps/rabbitmq_management/priv/www/js/tmpl/msg-detail-publishes.ejs b/deps/rabbitmq_management/priv/www/js/tmpl/msg-detail-publishes.ejs index 0137007a9d..4ea959ac52 100644 --- a/deps/rabbitmq_management/priv/www/js/tmpl/msg-detail-publishes.ejs +++ b/deps/rabbitmq_management/priv/www/js/tmpl/msg-detail-publishes.ejs @@ -34,9 +34,9 @@ <% } else { %> <%= link_exchange(pub.exchange.vhost, pub.exchange.name) %> <% } %> - <%= fmt_rate(pub.stats, 'publish') %> + <%= fmt_detail_rate(pub.stats, 'publish') %> <% if (col_confirm) { %> - <%= fmt_rate(pub.stats, 'confirm') %> + <%= fmt_detail_rate(pub.stats, 'confirm') %> <% } %> <% } %> diff --git a/deps/rabbitmq_management/priv/www/js/tmpl/node.ejs b/deps/rabbitmq_management/priv/www/js/tmpl/node.ejs index fbbe12134b..c7f925c23a 100644 --- a/deps/rabbitmq_management/priv/www/js/tmpl/node.ejs +++ b/deps/rabbitmq_management/priv/www/js/tmpl/node.ejs @@ -106,7 +106,7 @@ <% if (node.mem_limit != 'memory_monitoring_disabled') { %> <%= node_stat('mem_used', 'Used', 'mem_limit', 'high watermark', node, - fmt_bytes_obj, fmt_bytes_axis, + fmt_bytes, fmt_bytes_axis, node.mem_alarm ? 'red' : 'green', node.mem_alarm ? 'memory-alarm' : null) %> <% } else { %> @@ -121,7 +121,7 @@ <% if (node.disk_free_limit != 'disk_free_monitoring_disabled') { %> <%= node_stat('disk_free', 'Free', 'disk_free_limit', 'low watermark', node, - fmt_bytes_obj, fmt_bytes_axis, + fmt_bytes, fmt_bytes_axis, node.disk_free_alarm ? 'red' : 'green', node.disk_free_alarm ? 'disk_free-alarm' : null, true) %> @@ -145,13 +145,11 @@ <% } else if (node.os_pid == undefined) { %>

Node statistics not available

<% } else { %> - + <%= rates_chart_or_text('persister-stats-count', node, [['Read', 'persister_read_count'], ['Write', 'persister_write_count'], ['Sync', 'persister_sync_count']], fmt_rate, fmt_rate_axis, true, 'Operations') %> - <%= rates_chart_or_text('fhc-stats-count', node, [['Read', 'fhc_read_count'], ['Write', 'fhc_write_count'], ['Sync', 'fhc_sync_count']], fmt_rate, fmt_rate_large, fmt_rate_axis, true, 'Operations') %> + <%= rates_chart_or_text('persister-stats-bytes', node, [['Read', 'persister_read_bytes'], ['Write', 'persister_write_bytes']], fmt_rate_bytes, fmt_rate_bytes_axis, true, 'Data rates') %> - <%= rates_chart_or_text('fhc-stats-bytes', node, [['Read', 'fhc_read_bytes'], ['Write', 'fhc_write_bytes']], fmt_rate_bytes, fmt_rate_bytes_large, fmt_rate_bytes_axis, true, 'Data rates') %> - - <%= rates_chart_or_text('fhc-stats-time', node, [['Read', 'fhc_read_avg_time'], ['Write', 'fhc_write_avg_time'], ['Sync', 'fhc_sync_avg_time']], fmt_msgs, fmt_msgs_large, fmt_num_axis, false, 'Time') %> + <%= rates_chart_or_text('persister-stats-time', node, [['Read', 'persister_read_avg_time'], ['Write', 'persister_write_avg_time'], ['Sync', 'persister_sync_avg_time']], fmt_ms, fmt_ms, false, 'Average time per operation') %> <% } %> diff --git a/deps/rabbitmq_management/priv/www/js/tmpl/queues.ejs b/deps/rabbitmq_management/priv/www/js/tmpl/queues.ejs index 3dc65c8e56..3f3b3472cf 100644 --- a/deps/rabbitmq_management/priv/www/js/tmpl/queues.ejs +++ b/deps/rabbitmq_management/priv/www/js/tmpl/queues.ejs @@ -160,16 +160,16 @@ <% } %> <% if (rates_mode != 'none') { %> <% if (show_column('queues', 'rate-incoming')) { %> - <%= fmt_rate(queue.message_stats, 'publish') %> + <%= fmt_detail_rate(queue.message_stats, 'publish') %> <% } %> <% if (show_column('queues', 'rate-deliver')) { %> - <%= fmt_rate(queue.message_stats, 'deliver_get') %> + <%= fmt_detail_rate(queue.message_stats, 'deliver_get') %> <% } %> <% if (show_column('queues', 'rate-redeliver')) { %> - <%= fmt_rate(queue.message_stats, 'redeliver') %> + <%= fmt_detail_rate(queue.message_stats, 'redeliver') %> <% } %> <% if (show_column('queues', 'rate-ack')) { %> - <%= fmt_rate(queue.message_stats, 'ack') %> + <%= fmt_detail_rate(queue.message_stats, 'ack') %> <% } %> <% } %> diff --git a/deps/rabbitmq_management/priv/www/js/tmpl/vhosts.ejs b/deps/rabbitmq_management/priv/www/js/tmpl/vhosts.ejs index 285af23edd..a6cbe9faf5 100644 --- a/deps/rabbitmq_management/priv/www/js/tmpl/vhosts.ejs +++ b/deps/rabbitmq_management/priv/www/js/tmpl/vhosts.ejs @@ -64,17 +64,17 @@ <%= fmt_num_thousands(vhost.messages) %> <% } %> <% if (show_column('vhosts', 'from_client')) { %> - <%= fmt_rate_bytes(vhost, 'recv_oct') %> + <%= fmt_detail_rate_bytes(vhost, 'recv_oct') %> <% } %> <% if (show_column('vhosts', 'to_client')) { %> - <%= fmt_rate_bytes(vhost, 'send_oct') %> + <%= fmt_detail_rate_bytes(vhost, 'send_oct') %> <% } %> <% if (rates_mode != 'none') { %> <% if (show_column('vhosts', 'rate-publish')) { %> - <%= fmt_rate(vhost.message_stats, 'publish') %> + <%= fmt_detail_rate(vhost.message_stats, 'publish') %> <% } %> <% if (show_column('vhosts', 'rate-deliver')) { %> - <%= fmt_rate(vhost.message_stats, 'deliver_get') %> + <%= fmt_detail_rate(vhost.message_stats, 'deliver_get') %> <% } %> <% } %>