You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
haproxy-wi/inc/metrics.js

156 lines
3.8 KiB

function getChartData(server) {
$.ajax({
url: "options.py",
data: {
new_metrics: '1',
server: server,
token: $('#token').val()
},
5 years ago
type: "POST",
5 years ago
success: function (result) {
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: [
{
5 years ago
label: 'Connections',
data: data[0].split(','),
borderColor: 'rgba(75, 192, 192, 1)',
backgroundColor: 'rgba(75, 192, 192, 0.2)',
},
{
5 years ago
label: 'SSL Connections',
data: data[1].split(','),
borderColor: 'rgba(54, 162, 235, 1)',
backgroundColor: 'rgba(54, 162, 235, 0.2)',
},
{
5 years ago
label: 'Session rate',
data: data[2].split(','),
borderColor: 'rgba(255, 206, 86, 1)',
backgroundColor: 'rgba(255, 206, 86, 0.2)',
5 years ago
}
]
},
options: {
maintainAspectRatio: false,
5 years ago
title: {
display: true,
text: data[3],
fontSize: 20,
padding: 0,
},
scales: {
yAxes: [{
ticks: {
beginAtZero: true,
}
}]
},
legend: {
display: true,
labels: {
fontColor: 'rgb(255, 99, 132)',
defaultFontSize: '10',
defaultFontFamily: 'BlinkMacSystemFont'
5 years ago
},
}
}
});
}
function getWafChartData(server) {
$.ajax({
url: "options.py",
data: {
new_waf_metrics: '1',
server: server,
token: $('#token').val()
},
5 years ago
type: "POST",
5 years ago
success: function (result) {
5 years ago
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) {
5 years ago
var ctx = 's_'+server
5 years ago
var myChart = new Chart(ctx, {
type: 'line',
data: {
labels: labels.split(','),
datasets: [
{
5 years ago
label: 'Connections',
5 years ago
data: data[0].split(','),
borderColor: 'rgba(75, 192, 192, 1)',
backgroundColor: 'rgba(75, 192, 192, 0.2)',
}
]
},
options: {
maintainAspectRatio: false,
title: {
display: true,
text: "WAF "+data[1],
fontSize: 20,
padding: 0,
},
scales: {
yAxes: [{
ticks: {
beginAtZero: true,
}
}]
},
legend: {
display: true,
labels: {
fontColor: 'rgb(255, 99, 132)',
defaultFontSize: '10',
defaultFontFamily: 'BlinkMacSystemFont'
},
}
}
});
}
5 years ago
$("#secIntervals").css("display", "none");
function loadMetrics() {
5 years ago
$.ajax({
url: "options.py",
data: {
table_metrics: '1',
token: $('#token').val()
},
beforeSend: function() {
$('#table_metrics').html('<img class="loading_full_page" src="/inc/images/loading.gif" />')
5 years ago
},
5 years ago
type: "POST",
5 years ago
success: function (data) {
$( "#table_metrics" ).html( data );
}
});
}