1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
//
// Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved.
dispatcher_add(function(sammy) {
sammy.get('#/top', function() {
var nodes = JSON.parse(sync_get('/nodes'));
go_to('#/top/' + nodes[0].name + "/20");
});
sammy.get('#/top/ets', function() {
var nodes = JSON.parse(sync_get('/nodes'));
go_to('#/top/ets/' + nodes[0].name + "/20");
});
sammy.get('#/top/:node/:row_count', function() {
render({'top': {path: '/top/' + esc(this.params['node']),
options: {sort: true,
row_count: this.params['row_count']}},
'nodes': '/nodes'},
'processes', '#/top');
});
sammy.get('#/top/ets/:node/:row_count', function() {
render({'top': {path: '/top/ets/' + esc(this.params['node']),
options: {sort: true,
row_count: this.params['row_count']}},
'nodes': '/nodes'},
'ets_tables', '#/top/ets');
});
sammy.get('#/process/:pid', function() {
render({'process': '/process/' + esc(this.params['pid'])},
'process', '#/top');
});
});
NAVIGATION['Admin'][0]['Top Processes'] = ['#/top', 'administrator'];
NAVIGATION['Admin'][0]['Top ETS Tables'] = ['#/top/ets', 'administrator'];
HELP['gen-server2-buffer'] = "The processes with a <strong>gen_server2 buffer</strong> value of <code>\>= 0</code> are of type gen_server2. " +
"They drain their Erlang mailbox into an internal queue as an optimisation. " +
"In this context, \"queue\" refers to an internal data structure and must not be confused with a RabbitMQ queue.";
$(document).on('change', 'select#top-node', function() {
var url='#/top/' + $(this).val() + "/" + $('select#row-count').val();
go_to(url);
});
$(document).on('change', 'select#top-node-ets', function() {
var url='#/top/ets/' + $(this).val() + "/" + $('select#row-count-ets').val();
go_to(url);
});
$(document).on('change', 'select#row-count', function() {
go_to('#/top/' + $('select#top-node').val() + "/" + $(this).val());
});
$(document).on('change', 'select#row-count-ets', function() {
go_to('#/top/ets/' + $('select#top-node-ets').val() + "/" + $(this).val());
});
function link_pid(name) {
return _link_to(name, '#/process/' + esc(name));
}
// fmt_sort assumes ascending ordering by default and
// relies on two global variables, current_sort and current_sort_reverse.
// rabbitmq-top, however, wants to sort things in descending order by default
// because otherwise it is useless on initial page load.
//
// Thsi discrepancy means that either in the management UI or in the top
// tables the sorting indicator (a triangle) will be reversed.
//
// Changing the global variables has side effects, so we
// copy fmt_sort here and flip the arrow to meet top's needs.
function fmt_sort_desc_by_default(display, sort) {
var prefix = '';
if (current_sort == sort) {
prefix = '<span class="arrow">' +
(current_sort_reverse ? '▲ ' : '▼ ') +
'</span>';
}
return '<a class="sort" sort="' + sort + '">' + prefix + display + '</a>';
}
function fmt_process_name(process) {
if (process == undefined) return '';
var name = process.name;
if (name.supertype != undefined) {
if (name.supertype == 'channel') {
return link_channel(name.connection_name + ' (' +
name.channel_number + ')');
}
else if (name.supertype == 'queue') {
return link_queue(name.vhost, name.queue_name);
}
else if (name.supertype == 'connection') {
return link_conn(name.connection_name);
}
}
else {
return '<b>' + name.name + '</b>';
}
}
function fmt_remove_rabbit_prefix(name) {
if (name == 'rabbit_amqqueue_process') return 'queue';
if (name.substring(0, 7) == 'rabbit_') {
return name.substring(7);
}
else {
return name;
}
}
function fmt_pids(pids) {
var txt = '';
for (var i = 0; i < pids.length; i++) {
txt += link_pid(pids[i]) + ' ';
}
return txt;
}
function fmt_reduction_delta(delta) {
return Math.round(delta / 5); // gen_server updates every 5s
}
|