pull/161/head
Pavel Loginov 5 years ago
parent aee73a1b85
commit c7f9969ed5

@ -482,13 +482,16 @@ if form.getvalue('new_waf_metrics'):
curr_con = '' curr_con = ''
for i in metric: for i in metric:
labels += str(i[2].split(' ')[1])+',' label = str(i[2])
label = label.split(' ')[1]
label = label.split(':')
labels += label[0]+':'+label[1]+','
curr_con += str(i[1])+',' curr_con += str(i[1])+','
metrics['chartData']['labels'] = labels metrics['chartData']['labels'] = labels
metrics['chartData']['curr_con'] = curr_con metrics['chartData']['curr_con'] = curr_con
metrics['chartData']['server'] = serv metrics['chartData']['server'] = serv
import json import json
print(json.dumps(metrics)) print(json.dumps(metrics))

@ -29,19 +29,19 @@ function renderChart(data, labels, server) {
labels: labels.split(','), labels: labels.split(','),
datasets: [ datasets: [
{ {
label: 'curr_con', label: 'Connections',
data: data[0].split(','), data: data[0].split(','),
borderColor: 'rgba(75, 192, 192, 1)', borderColor: 'rgba(75, 192, 192, 1)',
backgroundColor: 'rgba(75, 192, 192, 0.2)', backgroundColor: 'rgba(75, 192, 192, 0.2)',
}, },
{ {
label: 'curr_ssl_con', label: 'SSL Connections',
data: data[1].split(','), data: data[1].split(','),
borderColor: 'rgba(54, 162, 235, 1)', borderColor: 'rgba(54, 162, 235, 1)',
backgroundColor: 'rgba(54, 162, 235, 0.2)', backgroundColor: 'rgba(54, 162, 235, 0.2)',
}, },
{ {
label: 'sess_rate', label: 'Session rate',
data: data[2].split(','), data: data[2].split(','),
borderColor: 'rgba(255, 206, 86, 1)', borderColor: 'rgba(255, 206, 86, 1)',
backgroundColor: 'rgba(255, 206, 86, 0.2)', backgroundColor: 'rgba(255, 206, 86, 0.2)',
@ -100,7 +100,7 @@ function renderWafChart(data, labels, server) {
labels: labels.split(','), labels: labels.split(','),
datasets: [ datasets: [
{ {
label: 'curr_con', label: 'Connections',
data: data[0].split(','), data: data[0].split(','),
borderColor: 'rgba(75, 192, 192, 1)', borderColor: 'rgba(75, 192, 192, 1)',
backgroundColor: 'rgba(75, 192, 192, 0.2)', backgroundColor: 'rgba(75, 192, 192, 0.2)',
@ -132,20 +132,11 @@ function renderWafChart(data, labels, server) {
} }
$("#secIntervals").css("display", "none"); $("#secIntervals").css("display", "none");
function callIframe(url, callback) {
$('#metrics_iframe').html('<iframe id="metrics" style="width:100%;height:100%;" />');
$('iframe#metrics').attr('src', url);
$('iframe#metrics').load(function() {
callback(this);
});
}
function loadMetrics() { function loadMetrics() {
$.get( "options.py?table_metrics=1&token="+$('#token').val(), function( data ) {
$.get( "options.py?table_metrics=1&token="+$('#token').val(), function( data ) { $( "#table_metrics" ).html( data );
$( "#table_metrics" ).html( data ); });
});
} }

@ -43,7 +43,7 @@ window.onblur= function() {
} else if (cur_url[0] == "viewlogs.py") { } else if (cur_url[0] == "viewlogs.py") {
viewLogs(); viewLogs();
} else if (cur_url[0] == "metrics.py") { } else if (cur_url[0] == "metrics.py") {
loadMetrics(); showMetrics();
} }
} }
} }
@ -144,15 +144,15 @@ function startSetInterval(interval) {
if(interval < 60000) { if(interval < 60000) {
interval = 60000; interval = 60000;
} }
intervalId = setInterval('loadMetrics()', interval); intervalId = setInterval('showMetrics()', interval);
loadMetrics(); showMetrics();
} else if (cur_url[0] == "waf.py") { } else if (cur_url[0] == "waf.py") {
if(interval < 60000) { if(interval < 60000) {
interval = 60000; interval = 60000;
} }
intervalId = setInterval('loadMetrics()', interval); intervalId = setInterval('showMetrics()', interval);
showOverviewWaf(); showOverviewWaf();
loadMetrics(); showWafMetrics();
} }
} else { } else {
pauseAutoRefresh(); pauseAutoRefresh();
@ -245,6 +245,10 @@ function showOverviewServer(name,ip,id) {
} ); } );
} }
function showOverviewWaf() { function showOverviewWaf() {
if (cur_url[0] == "waf.py") {
$.getScript('/inc/chart.min.js');
showWafMetrics()
}
$.ajax( { $.ajax( {
url: "options.py", url: "options.py",
data: { data: {

@ -1,7 +1,6 @@
$( function() { $( function() {
$( "#ajaxwafstatus input" ).change(function() { $( "#ajaxwafstatus input" ).change(function() {
var id = $(this).attr('id'); var id = $(this).attr('id');
console.log(id);
metrics_waf(id); metrics_waf(id);
}); });
} ); } );

Loading…
Cancel
Save