Introduce v2 field in router table
If a router sends his hood, it is considered to be V2. V2 hoods are highlighted on the statistics page. This requires changes to the MySQL database! Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
This commit is contained in:
parent
6d735a549a
commit
d298cc7762
|
@ -89,6 +89,7 @@ mysql.execute("""
|
|||
`position_comment` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`community` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`hood` varchar(30) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
|
||||
`v2` tinyint(1) NOT NULL,
|
||||
`status_text` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`contact` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`lng` double DEFAULT NULL,
|
||||
|
|
|
@ -152,14 +152,14 @@ def import_nodewatcher_xml(mysql, mac, xml, banned, netifdict):
|
|||
SET status = %s, hostname = %s, last_contact = %s, sys_time = %s, sys_uptime = %s, sys_memfree = %s, sys_membuff = %s, sys_memcache = %s,
|
||||
sys_loadavg = %s, sys_procrun = %s, sys_proctot = %s, clients = %s, clients_eth = %s, clients_w2 = %s, clients_w5 = %s,
|
||||
w2_active = %s, w2_busy = %s, w5_active = %s, w5_busy = %s, w2_airtime = %s, w5_airtime = %s, wan_uplink = %s, cpu = %s, chipset = %s, hardware = %s, os = %s,
|
||||
batman = %s, kernel = %s, nodewatcher = %s, firmware = %s, firmware_rev = %s, description = %s, position_comment = %s, community = %s, hood = %s,
|
||||
batman = %s, kernel = %s, nodewatcher = %s, firmware = %s, firmware_rev = %s, description = %s, position_comment = %s, community = %s, hood = %s, v2 = %s,
|
||||
status_text = %s, contact = %s, lng = %s, lat = %s, neighbors = %s, reset = %s
|
||||
WHERE id = %s
|
||||
""",(
|
||||
ru["status"],ru["hostname"],ru["last_contact"],ru["sys_time"],ru["sys_uptime"],ru["memory"]["free"],ru["memory"]["buffering"],ru["memory"]["caching"],
|
||||
ru["sys_loadavg"],ru["processes"]["runnable"],ru["processes"]["total"],ru["clients"],ru["clients_eth"],ru["clients_w2"],ru["clients_w5"],
|
||||
ru["w2_active"],ru["w2_busy"],ru["w5_active"],ru["w5_busy"],ru["w2_airtime"],ru["w5_airtime"],ru["has_wan_uplink"],ru["cpu"],ru["chipset"],ru["hardware"],ru["os"],
|
||||
ru["batman_adv"],ru["kernel"],ru["nodewatcher"],ru["firmware"],ru["firmware_rev"],ru["description"],ru["position_comment"],ru["community"],ru["hood"],
|
||||
ru["batman_adv"],ru["kernel"],ru["nodewatcher"],ru["firmware"],ru["firmware_rev"],ru["description"],ru["position_comment"],ru["community"],ru["hood"],ru["v2"],
|
||||
ru["status_text"],ru["contact"],ru["lng"],ru["lat"],ru["visible_neighbours"],reset,router_id,))
|
||||
|
||||
# Previously, I just deleted all entries and recreated them again with INSERT.
|
||||
|
@ -208,14 +208,14 @@ def import_nodewatcher_xml(mysql, mac, xml, banned, netifdict):
|
|||
INSERT INTO router (status, hostname, created, last_contact, sys_time, sys_uptime, sys_memfree, sys_membuff, sys_memcache,
|
||||
sys_loadavg, sys_procrun, sys_proctot, clients, clients_eth, clients_w2, clients_w5,
|
||||
w2_active, w2_busy, w5_active, w5_busy, w2_airtime, w5_airtime, wan_uplink, cpu, chipset, hardware, os,
|
||||
batman, kernel, nodewatcher, firmware, firmware_rev, description, position_comment, community, hood,
|
||||
batman, kernel, nodewatcher, firmware, firmware_rev, description, position_comment, community, hood, v2,
|
||||
status_text, contact, lng, lat, neighbors)
|
||||
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
|
||||
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
|
||||
""",(
|
||||
ru["status"],ru["hostname"],created,ru["last_contact"],ru["sys_time"],ru["sys_uptime"],ru["memory"]["free"],ru["memory"]["buffering"],ru["memory"]["caching"],
|
||||
ru["sys_loadavg"],ru["processes"]["runnable"],ru["processes"]["total"],ru["clients"],ru["clients_eth"],ru["clients_w2"],ru["clients_w5"],
|
||||
None,None,None,None,None,None,ru["has_wan_uplink"],ru["cpu"],ru["chipset"],ru["hardware"],ru["os"],
|
||||
ru["batman_adv"],ru["kernel"],ru["nodewatcher"],ru["firmware"],ru["firmware_rev"],ru["description"],ru["position_comment"],ru["community"],ru["hood"],
|
||||
ru["batman_adv"],ru["kernel"],ru["nodewatcher"],ru["firmware"],ru["firmware_rev"],ru["description"],ru["position_comment"],ru["community"],ru["hood"],ru["v2"],
|
||||
ru["status_text"],ru["contact"],ru["lng"],ru["lat"],ru["visible_neighbours"],))
|
||||
router_id = mysql.cursor().lastrowid
|
||||
|
||||
|
@ -711,6 +711,8 @@ def parse_nodewatcher_xml(xml):
|
|||
"firmware_rev": evalxpath(tree,"/data/system_data/firmware_revision/text()"),
|
||||
}
|
||||
|
||||
router_update["v2"] = bool(router_update["hood"])
|
||||
|
||||
try:
|
||||
lng = evalxpathfloat(tree,"/data/system_data/geo/lng/text()")
|
||||
except ValueError:
|
||||
|
|
|
@ -154,7 +154,7 @@ def hoods(mysql,selectgw=None):
|
|||
|
||||
def hoods_sum(mysql,selectgw=None):
|
||||
data = mysql.fetchall("""
|
||||
SELECT hood, COUNT(id) AS count, SUM(clients) AS clients
|
||||
SELECT hood, COUNT(id) AS count, SUM(clients) AS clients, MAX(v2) AS v2
|
||||
FROM router
|
||||
GROUP BY hood
|
||||
""")
|
||||
|
@ -162,7 +162,7 @@ def hoods_sum(mysql,selectgw=None):
|
|||
for rs in data:
|
||||
if not rs["hood"]:
|
||||
rs["hood"] = "Default"
|
||||
result[rs["hood"]] = {"routers": rs["count"], "clients": rs["clients"]}
|
||||
result[rs["hood"]] = {"routers": rs["count"], "clients": rs["clients"], "v2": rs["v2"]}
|
||||
return result
|
||||
|
||||
def hoods_gws(mysql):
|
||||
|
|
|
@ -45,6 +45,9 @@
|
|||
.table-hoods .firstrow {
|
||||
text-align: left;
|
||||
}
|
||||
.hoodv2 a {
|
||||
color: #2db200;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
|
@ -70,7 +73,7 @@
|
|||
<tbody>
|
||||
{%- for hood, value in hoods|dictsort %}
|
||||
<tr>
|
||||
<td class="firstrow"><a href="{{ url_for('router_list', q='hood:^%s$' % hood.replace(' ','_')) }}">{{ hood }}</a></td>
|
||||
<td class="firstrow{%- if hoods_sum[hood]["v2"] %} hoodv2{%- endif %}"><a href="{{ url_for('router_list', q='hood:^%s$' % hood.replace(' ','_')) }}">{{ hood }}</a></td>
|
||||
<td class="stats">{{ hoods_gws[hood] or "-" }}</td>
|
||||
<td class="success">{{ value["online"] or 0 }}</td>
|
||||
<td class="danger" data-order="{{ value["offline"] or 0 }}">{{ value["offline"] or 0 }}{%- if value["orphaned"] %} ({{ value["orphaned"] or 0 }}){%- endif %}</td>
|
||||
|
|
Loading…
Reference in New Issue