pull/161/head
Pavel Loginov 2019-10-06 10:43:22 +03:00
parent a86c7a0d25
commit 5f8cd37f7c
5 changed files with 13 additions and 9 deletions

View File

@ -783,7 +783,7 @@ def select_waf_servers_metrics(uuid, **kwargs):
else:
for group in cur:
if group[5] == '1':
sql = """ select servers.ip from servers left join waf as waf on waf.server_id = servers.id where servers.enable = 1 and waf.metrics = '1' """
sql = """ select servers.ip from servers left join waf as waf on waf.server_id = servers.id where servers.enable = 1 and waf.metrics = '1' """
else:
sql = """ select servers.ip from servers left join waf as waf on waf.server_id = servers.id where servers.enable = 1 and waf.metrics = '1' and servers.groups like '%{group}%' """.format(group=group[5])
try:
@ -797,7 +797,7 @@ def select_waf_servers_metrics(uuid, **kwargs):
def select_waf_metrics(serv, **kwargs):
con, cur = create_db.get_cur()
sql = """ select * from waf_metrics where serv = '%s' order by `date` desc """ % serv
sql = """ select * from (select * from waf_metrics where serv = '%s' order by `date` desc limit 30) order by `date`""" % serv
try:
cur.execute(sql)
except sqltool.Error as e:

View File

@ -16,6 +16,9 @@ th, tr, td {
<script src="/inc/metrics.js"></script>
<script src="/inc/chart.min.js"></script>
<div id="table_metrics"></div>
<div id="refresh" style="text-align: right;margin-top: 20px;margin-right: 10px;" title="Refresh metrics" onclick="showMetrics()">
<img src="/inc/images/update.png" alt="Refresh" class="icon">
</div>
{% for s in servers %}
<div class="chart-container">
<canvas id="{{s.0}}" role="img"></canvas>

View File

@ -28,10 +28,12 @@
<link href="/inc/chart.min.css" rel="stylesheet">
<script src="/inc/metrics.js"></script>
<script src="/inc/chart.min.js"></script>
<div id="refresh" style="text-align: right;margin-top: 20px;margin-right: 20px;" title="Refresh metrics" onclick="showWafMetrics()">
<img src="/inc/images/update.png" alt="Refresh" class="icon">
</div>
{% for s in servers %}
<div class="chart-container">
<canvas id="{{s.0}}" role="img"></canvas>
<canvas id="s_{{s.0}}" role="img"></canvas>
</div>
{% endfor %}

View File

@ -81,10 +81,8 @@ function getWafChartData(server) {
token: $('#token').val()
},
type: "GET",
success: function (result) {
success: function (result) {
var data = [];
data.push(result.chartData.curr_con);
data.push(result.chartData.server);
var labels = result.chartData.labels;
@ -93,7 +91,8 @@ function getWafChartData(server) {
});
}
function renderWafChart(data, labels, server) {
var ctx = document.getElementById(server)
console.log(server)
var ctx = 's_'+server
var myChart = new Chart(ctx, {
type: 'line',
data: {

View File

@ -150,7 +150,7 @@ function startSetInterval(interval) {
if(interval < 60000) {
interval = 60000;
}
intervalId = setInterval('showMetrics()', interval);
intervalId = setInterval('showOverviewWaf()', interval);
showOverviewWaf();
showWafMetrics();
}