rabbit.js
12.1 KB
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
$(
refreshView()
);
function refreshView() {
updateOverView();
updateClusterView();
updateQueuesView();
setTimeout('refreshView()', 30000);
}
function updateOverView() {
$.ajax({
url: contextPath + "rabbitmq/overview",
type: "post",
dataType: "json",
data: {
moId: moId
},
success: function (response) {
updateOverview(response);
},
error: function (e) {
}
});
}
function updateOverview(response) {
var div = document.getElementById("overviewDiv");
div.innerHTML = "";
var cpus = $("<div style='margin-left: 35px; margin-top: 5px'>").addClass("micro-highlight").html("CPU(%): ").appendTo(div);
var cpusValue = $("<strong>").html(response.data.cpu).appendTo(cpus);
var mems = $("<div style='margin-left: 35px; margin-top: 5px'>").addClass("micro-highlight").html("可用/总内存(MB): ").appendTo(div);
var memsValue = $("<strong>").html(response.data.mem).appendTo(mems);
var nets = $("<div style='margin-left: 35px; margin-top: 5px'>").addClass("micro-highlight").html("网络I/O(Mbps): ").appendTo(div);
var netsValue = $("<strong>").html(response.data.net).appendTo(nets);
var connections = $("<div style='margin-left: 35px; margin-top: 5px'>").addClass("micro-highlight").html("Connections: ").appendTo(div);
var conValue = $("<strong>").html(response.data.connections).appendTo(connections);
var channels = $("<div style='margin-left: 35px; margin-top: 5px'>").addClass("micro-highlight").html("Channels: ").appendTo(div);
var chaValue = $("<strong>").html(response.data.channels).appendTo(channels);
var exchanges = $("<div style='margin-left: 35px; margin-top: 5px'>").addClass("micro-highlight").html("Exchanges: ").appendTo(div);
var excValue = $("<strong>").html(response.data.exchanges).appendTo(exchanges);
var Queues = $("<div style='margin-left: 35px; margin-top: 5px'>").addClass("micro-highlight").html("Queues: ").appendTo(div);
var quevalue = $("<strong>").html(response.data.queues).appendTo(Queues);
var consumers = $("<div style='margin-left: 35px; margin-top: 5px'>").addClass("micro-highlight").html("Consumers: ").appendTo(div);
var consValue = $("<strong>").html(response.data.consumers).appendTo(consumers);
var Messages_Ready = $("<div style='margin-left: 35px; margin-top: 5px'>").addClass("micro-highlight").html("Message_Ready: ").appendTo(div);
var readyValue = $("<strong>").html(response.data.messages_ready).appendTo(Messages_Ready);
var Messages_unack = $("<div style='margin-left: 35px; margin-top: 5px'>").addClass("micro-highlight").html("Message_Unack: ").appendTo(div);
var unValue = $("<strong>").html(response.data.messages_unack).appendTo(Messages_unack);
var Messages_total = $("<div style='margin-left: 35px; margin-top: 5px'>").addClass("micro-highlight").html("Message_Total: ").appendTo(div);
var totValue = $("<strong>").html(response.data.messages).appendTo(Messages_total);
}
function updateClusterView() {
$("#clusterViewTable").table(
{
url: contextPath + "rabbitmq/clusterView",
queryParams: {
moId: moId
}, //调用url传递的参数
method: "POST",
striped: true,
panelClass: "panel-success",
pagination: true,
pageSize: 5,
loadFilter: function (data) {
return defaultLoadFilter(data);
},
columns: [{
title: "Name",
formatter: function (value, rowData) {
/*alert(rowData.name);*/
var div = $("<div align='center'>").html(rowData.name);
return div;
}
},
{
title: "File descriptors",
formatter: function (value, rowData) {
var div = $("<div style='width: 240px;'>").addClass("status-bar");
var nameDiv = $("<div style='margin-bottom: 5px;background-repeat: no-repeat;'>")
.html(rowData.fd_used);
if (rowData.fd_used > rowData.fd_total / 2) {
nameDiv.addClass("status-bar-main red");
}
else {
nameDiv.addClass("status-bar-main green");
}
var nameAvliable = $("<sub>").html(rowData.fd_total + " vailable");
div.append(nameDiv);
div.append(nameAvliable);
return div;
}
},
{
title: "Socket descriptors",
formatter: function (value, rowData) {
var div = $("<div style='width: 240px;'>").addClass("status-bar");
var nameDiv = $("<div style='margin-bottom: 5px;background-repeat: no-repeat;'>")
.addClass("status-bar-main green")
.html(rowData.sockets_used);
if (rowData.sockets_used > rowData.sockets_total / 2) {
nameDiv.addClass("status-bar-main red");
}
else {
nameDiv.addClass("status-bar-main green");
}
var nameAvliable = $("<sub>").html(rowData.sockets_total + " available");
div.append(nameDiv);
div.append(nameAvliable);
return div;
}
},
{
title: "Erlang processes",
formatter: function (value, rowData) {
var div = $("<div style='width: 240px;'>").addClass("status-bar");
var nameDiv = $("<div style='margin-bottom: 5px;background-repeat: no-repeat;'>")
.addClass("status-bar-main green")
.html(rowData.proc_used);
if (rowData.proc_used > rowData.proc_total / 2) {
nameDiv.addClass("status-bar-main red");
}
else {
nameDiv.addClass("status-bar-main green");
}
var nameAvliable = $("<sub>").html(rowData.proc_total + " available");
div.append(nameDiv);
div.append(nameAvliable);
return div;
}
},
{
title: "Memory",
formatter: function (value, rowData) {
var div = $("<div style='width: 240px;'>").addClass("status-bar");
var nameDiv = $("<div style='margin-bottom: 5px;background-repeat: no-repeat;'>")
.html(rowData.mem_used);
if (rowData.mem_alarm) {
nameDiv.addClass("status-bar-main red");
}
else {
nameDiv.addClass("status-bar-main green");
}
var nameAvliable = $("<sub>").html(rowData.mem_limit + " vailable");
div.append(nameDiv);
div.append(nameAvliable);
return div;
}
},
{
title: "Disk space",
formatter: function (value, rowData) {
var div = $("<div style='width: 240px;'>").addClass("status-bar");
var nameDiv = $("<div style='margin-bottom: 5px;background-repeat: no-repeat;'>")
.html(rowData.disk_free);
if (rowData.disk_free_alarm) {
nameDiv.addClass("status-bar-main red");
}
else {
nameDiv.addClass("status-bar-main green");
}
var nameAvliable = $("<sub>").html(rowData.disk_free_limit + " available");
div.append(nameDiv);
div.append(nameAvliable);
return div;
}
}
]
});
}
function updateQueuesView() {
$("#queueViewTable").table(
{
url: contextPath + "rabbitmq/queueView",
method: "POST",
queryParams: {
moId: moId
}, //调用url传递的参数
striped: true,
panelClass: "panel-success",
/* sortable: true, //是否启用排序
sortOrder: "Messages_Total",*/
/* pagination: true,
pageSize: 5,*/
loadFilter: function (data) {
return defaultLoadFilter(data);
},
columns: [{
title: "Virtual host",
formatter: function (value, rowData) {
/*alert(rowData.name);*/
var div = $("<div align='center'>").html(rowData.vhost);
return div;
}
}, {
title: "Name",
formatter: function (value, rowData) {
/*alert(rowData.name);*/
var div = $("<div align='center'>").html(rowData.name);
return div;
}
}, {
title: "State",
formatter: function (value, rowData) {
/*alert(rowData.name);*/
var div = $("<div align='center'>").html(rowData.state);
return div;
}
}, {
title: "Messages_Ready",
formatter: function (value, rowData) {
/*alert(rowData.name);*/
var div = $("<div align='center'>").html(rowData.messages_ready);
return div;
}
}, {
title: "Messages_Unack",
formatter: function (value, rowData) {
/*alert(rowData.name);*/
var div = $("<div align='center'>").html(rowData.messages_unacknowledged);
return div;
}
}, {
title: "Messages_Total",
formatter: function (value, rowData) {
/*alert(rowData.name);*/
var div = $("<div align='center'>").html(rowData.messages);
return div;
}
},
{
title: "Alert_High_Watermark",
formatter: function (value, rowData, rowIndex) {
/*alert(rowData.name);*/
var div = $("<div>");
var input = $("<input type='text' id='msg_alert_high_" + rowIndex + "' class='form-control' style='width: 120px;' height='50%'>");
input.val(rowData.alert_high);
var submit = $("<button >").addClass("btn btn-xs btn-danger").html("设置");
submit.click(function () {
fixAlertHigh(rowData, rowIndex);
});
div.append(input);
div.append(" ");
div.append(" ");
div.append(" ");
div.append(submit);
return div;
}
}
]
}
)
}
function fixAlertHigh(rowData, rowIndex) {
/* alert(rowIndex);
alert(rowData.name);
alert($("#msg_alert_high_" + rowIndex + "").val());*/
$.ajax({
url: contextPath + "rabbitmq/fixAlertHigh",
type: "post",
dataType: "json",
data: {
moId: moId,
queueName: rowData.name,
alertHigh: $("#msg_alert_high_" + rowIndex + "").val()
}
})
}