haproxy-wi/inc/metrics.js

151 lines
3.7 KiB
JavaScript
Raw Normal View History

2019-10-05 20:41:07 +00:00
function getChartData(server) {
$.ajax({
url: "options.py",
data: {
new_metrics: '1',
server: server,
token: $('#token').val()
},
type: "GET",
2019-10-11 04:49:55 +00:00
success: function (result) {
2019-10-05 20:41:07 +00:00
var data = [];
data.push(result.chartData.curr_con);
data.push(result.chartData.curr_ssl_con);
data.push(result.chartData.sess_rate);
data.push(result.chartData.server);
var labels = result.chartData.labels;
renderChart(data, labels, server);
}
});
}
function renderChart(data, labels, server) {
var ctx = document.getElementById(server)
var myChart = new Chart(ctx, {
type: 'line',
data: {
labels: labels.split(','),
datasets: [
{
2019-10-06 06:50:12 +00:00
label: 'Connections',
2019-10-05 20:41:07 +00:00
data: data[0].split(','),
borderColor: 'rgba(75, 192, 192, 1)',
backgroundColor: 'rgba(75, 192, 192, 0.2)',
},
{
2019-10-06 06:50:12 +00:00
label: 'SSL Connections',
2019-10-05 20:41:07 +00:00
data: data[1].split(','),
borderColor: 'rgba(54, 162, 235, 1)',
backgroundColor: 'rgba(54, 162, 235, 0.2)',
},
{
2019-10-06 06:50:12 +00:00
label: 'Session rate',
2019-10-05 20:41:07 +00:00
data: data[2].split(','),
borderColor: 'rgba(255, 206, 86, 1)',
backgroundColor: 'rgba(255, 206, 86, 0.2)',
2019-10-05 21:30:16 +00:00
}
]
},
options: {
title: {
display: true,
text: data[3],
fontSize: 20,
padding: 0,
},
scales: {
yAxes: [{
ticks: {
beginAtZero: true,
}
}]
},
legend: {
display: true,
labels: {
fontColor: 'rgb(255, 99, 132)'
},
}
}
});
}
function getWafChartData(server) {
$.ajax({
url: "options.py",
data: {
new_waf_metrics: '1',
server: server,
token: $('#token').val()
},
type: "GET",
2019-10-06 07:43:22 +00:00
success: function (result) {
2019-10-05 21:30:16 +00:00
var data = [];
data.push(result.chartData.curr_con);
data.push(result.chartData.server);
var labels = result.chartData.labels;
renderWafChart(data, labels, server);
}
});
}
function renderWafChart(data, labels, server) {
2019-10-06 07:43:22 +00:00
console.log(server)
var ctx = 's_'+server
2019-10-05 21:30:16 +00:00
var myChart = new Chart(ctx, {
type: 'line',
data: {
labels: labels.split(','),
datasets: [
2019-10-05 20:41:07 +00:00
{
2019-10-06 06:50:12 +00:00
label: 'Connections',
2019-10-05 21:30:16 +00:00
data: data[0].split(','),
borderColor: 'rgba(75, 192, 192, 1)',
backgroundColor: 'rgba(75, 192, 192, 0.2)',
2019-10-05 20:41:07 +00:00
}
]
},
options: {
title: {
display: true,
text: "WAF "+data[1],
2019-10-05 20:41:07 +00:00
fontSize: 20,
padding: 0,
},
scales: {
yAxes: [{
ticks: {
beginAtZero: true,
}
}]
},
legend: {
display: true,
labels: {
fontColor: 'rgb(255, 99, 132)'
},
}
}
});
}
2019-10-05 21:30:16 +00:00
2019-10-05 20:41:07 +00:00
$("#secIntervals").css("display", "none");
function loadMetrics() {
2019-10-11 04:49:55 +00:00
$.ajax({
url: "options.py",
data: {
table_metrics: '1',
token: $('#token').val()
},
beforeSend: function() {
$('#table_metrics').prepend('<img class="loading_full_page" src="/inc/images/loading.gif" />')
},
type: "GET",
success: function (data) {
$( "#table_metrics" ).html( data );
}
});
2019-10-05 20:41:07 +00:00
}