v2routers: Added page for V1/V2 comparison
Selection of deleted hoods for V1 is a dirty walkaround and needs to be adjusted for every new deleted hood. Since this is an undocumented page, this is okay ... Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
This commit is contained in:
parent
4c2b4f1628
commit
7d2488bcc5
|
@ -71,6 +71,38 @@ def router_list():
|
|||
|
||||
return render_template("router_list.html", query_str=query_str, routers=routers, numrouters=len(routers))
|
||||
|
||||
# test
|
||||
@app.route('/v2routers')
|
||||
def v2_routers():
|
||||
try:
|
||||
mysql = FreifunkMySQL()
|
||||
statsv2 = mysql.fetchall("""
|
||||
SELECT time, CAST(SUM(clients) AS SIGNED) clients, CAST(SUM(online) AS SIGNED) online, CAST(SUM(offline) AS SIGNED) offline, CAST(SUM(unknown) AS SIGNED) unknown, CAST(SUM(orphaned) AS SIGNED) orphaned, CAST(SUM(rx) AS SIGNED) rx, CAST(SUM(tx) AS SIGNED) tx
|
||||
FROM stats_hood
|
||||
INNER JOIN hoods ON hoods.id = stats_hood.hood
|
||||
INNER JOIN hoodsv2 ON hoodsv2.name = hoods.name
|
||||
WHERE time > 1531612800
|
||||
GROUP BY time
|
||||
""")
|
||||
statsv1 = mysql.fetchall("""
|
||||
SELECT time, CAST(SUM(clients) AS SIGNED) clients, CAST(SUM(online) AS SIGNED) online, CAST(SUM(offline) AS SIGNED) offline, CAST(SUM(unknown) AS SIGNED) unknown, CAST(SUM(orphaned) AS SIGNED) orphaned, CAST(SUM(rx) AS SIGNED) rx, CAST(SUM(tx) AS SIGNED) tx
|
||||
FROM stats_hood
|
||||
INNER JOIN hoods ON hoods.id = stats_hood.hood
|
||||
LEFT JOIN hoodsv1 ON hoodsv1.name = hoods.name
|
||||
WHERE time > 1531612800 AND ( hoodsv1.name IS NOT NULL OR hoods.name IN ('ArnsteinV1','MuenchbergV1','MarktredwitzV1','BayreuthV1','AnsbachV1','FichtelbergV1','BambergV1','ForchheimV1','ErlangenV1','ErlangenWestV1','EbernV1','CoburgV1','HassbergeV1','LaufV1','RehauV1','AschaffenburgV1','WuerzburgV1','AdelsdorfV1','EbermannstadtV1','NuernbergV1','HassbergeSuedV1','FuerthV1','SchweinfurtV1','BGLV1') )
|
||||
GROUP BY time
|
||||
""")
|
||||
mysql.close()
|
||||
statsv2 = mysql.utcawaretupleint(statsv2,"time")
|
||||
statsv1 = mysql.utcawaretupleint(statsv1,"time")
|
||||
|
||||
return render_template("v2routers.html",statsv2 = statsv2,statsv1 = statsv1)
|
||||
except Exception as e:
|
||||
writelog(CONFIG["debug_dir"] + "/fail_v2.txt", str(e))
|
||||
import traceback
|
||||
writefulllog("Warning: Failed to display v2 page: %s\n__%s" % (e, traceback.format_exc().replace("\n", "\n__")))
|
||||
|
||||
|
||||
# router by mac (short link version)
|
||||
@app.route('/mac/<mac>', methods=['GET'])
|
||||
def router_mac(mac):
|
||||
|
|
|
@ -0,0 +1,108 @@
|
|||
{% extends "bootstrap.html" %}
|
||||
{% block title %}{{super()}} :: Statistics{% endblock %}
|
||||
{% block head %}{{super()}}
|
||||
<script src="{{ url_for('static', filename='js/graph/date.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/graph/jquery.flot.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/graph/jquery.flot.time.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/graph/jquery.flot.byte.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/graph/jquery.flot.selection.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/graph/jquery.flot.downsample.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/graph/jquery.flot.resize.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/graph/jquery.flot.hiddengraphs.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/graph/jquery.flot.pie.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/graph/jquery.flot.tooltip.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/graph.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/datatables/jquery.dataTables.min.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/datatables/dataTables.bootstrap.min.js') }}"></script>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/datatables/dataTables.bootstrap.min.css') }}">
|
||||
<style type="text/css">
|
||||
.table-condensed {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.table-condensed tr:last-child td, th {
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
@media(max-width:500px) {
|
||||
th {
|
||||
padding-left: 2px !important;
|
||||
padding-right: 2px !important;
|
||||
}
|
||||
td {
|
||||
padding-left: 2px !important;
|
||||
padding-right: 2px !important;
|
||||
}
|
||||
.panel-body {
|
||||
padding-left: 3px !important;
|
||||
padding-right: 3px !important;
|
||||
}
|
||||
}
|
||||
.table-hoods th {
|
||||
text-align: center;
|
||||
}
|
||||
.table-hoods td {
|
||||
text-align: center;
|
||||
}
|
||||
.table-hoods .firstrow {
|
||||
text-align: left;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-6">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Routers V1: {{ statsv1[-1]["online"] }} on, {{ statsv1[-1]["offline"] }} off, {{ statsv1[-1]["unknown"] }} unknown, {{ statsv1[-1]["orphaned"] }} orphaned; {{ statsv1[-1]["online"]+statsv1[-1]["offline"]+statsv1[-1]["unknown"]+statsv1[-1]["orphaned"] }} total</div>
|
||||
<div class="panel-body">
|
||||
<div id="globrouterstat1" class="graph"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Clients V1: {{ statsv1[-1]["clients"] }}</div>
|
||||
<div class="panel-body">
|
||||
<div id="globclientstat1" class="graph"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Traffic V1</div>
|
||||
<div class="panel-body">
|
||||
<div id="netstat1" class="graph"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12 col-md-6">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Routers V2: {{ statsv2[-1]["online"] }} on, {{ statsv2[-1]["offline"] }} off, {{ statsv2[-1]["unknown"] }} unknown, {{ statsv2[-1]["orphaned"] }} orphaned; {{ statsv2[-1]["online"]+statsv2[-1]["offline"]+statsv2[-1]["unknown"]+statsv2[-1]["orphaned"] }} total</div>
|
||||
<div class="panel-body">
|
||||
<div id="globrouterstat" class="graph"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Clients V2: {{ statsv2[-1]["clients"] }}</div>
|
||||
<div class="panel-body">
|
||||
<div id="globclientstat" class="graph"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Traffic V2</div>
|
||||
<div class="panel-body">
|
||||
<div id="netstat" class="graph"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
var global_stats_v2 = {{ statsv2|statbson2json|safe }};
|
||||
var global_stats_v1 = {{ statsv1|statbson2json|safe }};
|
||||
var routers_page_url = "{{ url_for('router_list') }}";
|
||||
$(document).ready(function() {
|
||||
global_client_graph(global_stats_v2,"globclientstat");
|
||||
global_router_graph(global_stats_v2,"globrouterstat");
|
||||
network_graph(global_stats_v2,"netstat","sent to clients","received from clients");
|
||||
global_client_graph(global_stats_v1,"globclientstat1");
|
||||
global_router_graph(global_stats_v1,"globrouterstat1");
|
||||
network_graph(global_stats_v1,"netstat1","sent to clients","received from clients");
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
Loading…
Reference in New Issue