diff --git a/ffmap/db/gws.py b/ffmap/db/gws.py index f996bb4..047113c 100755 --- a/ffmap/db/gws.py +++ b/ffmap/db/gws.py @@ -47,6 +47,10 @@ mysql.execute(""" `mac` char(17) COLLATE utf8_unicode_ci NOT NULL, `netif` varchar(15) COLLATE utf8_unicode_ci NOT NULL, `vpnmac` char(17) COLLATE utf8_unicode_ci DEFAULT NULL, + `ipv4` char(18) COLLATE utf8_unicode_ci DEFAULT NULL, + `ipv6` varchar(60) COLLATE utf8_unicode_ci DEFAULT NULL, + `dhcpstart` char(15) COLLATE utf8_unicode_ci DEFAULT NULL, + `dhcpend` char(15) COLLATE utf8_unicode_ci DEFAULT NULL, `last_contact` datetime NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci """) diff --git a/ffmap/gwtools.py b/ffmap/gwtools.py index 557eec5..af8c548 100644 --- a/ffmap/gwtools.py +++ b/ffmap/gwtools.py @@ -47,16 +47,28 @@ def import_gw_data(mysql, gw_data): n["vpnmac"] = nmacs.get(n["vpnif"],None) else: n["vpnmac"] = None + if not "ipv4" in n or not n["ipv4"]: + n["ipv4"] = None + if not "ipv6" in n or not n["ipv6"]: + n["ipv6"] = None + if not "dhcpstart" in n or not n["dhcpstart"]: + n["dhcpstart"] = None + if not "dhcpend" in n or not n["dhcpend"]: + n["dhcpend"] = None - ndata.append((newid,n["mac"],n["netif"],n["vpnmac"],time,)) + ndata.append((newid,n["mac"],n["netif"],n["vpnmac"],n["ipv4"],n["ipv6"],n["dhcpstart"],n["dhcpend"],time,)) mysql.executemany(""" - INSERT INTO gw_netif (gw, mac, netif, vpnmac, last_contact) - VALUES (%s, %s, %s, %s, %s) + INSERT INTO gw_netif (gw, mac, netif, vpnmac, ipv4, ipv6, dhcpstart, dhcpend, last_contact) + VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s) ON DUPLICATE KEY UPDATE gw=VALUES(gw), netif=VALUES(netif), vpnmac=VALUES(vpnmac), + ipv4=VALUES(ipv4), + ipv6=VALUES(ipv6), + dhcpstart=VALUES(dhcpstart), + dhcpend=VALUES(dhcpend), last_contact=VALUES(last_contact) """,ndata) diff --git a/ffmap/stattools.py b/ffmap/stattools.py index 49150a5..6d31d24 100644 --- a/ffmap/stattools.py +++ b/ffmap/stattools.py @@ -316,7 +316,7 @@ def gws_info(mysql,selecthood=None): tup = () data = mysql.fetchdict(""" - SELECT router_gw.mac AS mac, gw.name AS gw, stats_page, n1.netif AS gwif, n2.netif AS batif, n2.mac AS batmac + SELECT router_gw.mac AS mac, gw.name AS gw, stats_page, n1.netif AS gwif, n2.netif AS batif, n2.mac AS batmac, n2.ipv4 AS ipv4, n2.ipv6 AS ipv6, n2.dhcpstart AS dhcpstart, n2.dhcpend AS dhcpend FROM router INNER JOIN router_gw ON router.id = router_gw.router LEFT JOIN ( diff --git a/ffmap/web/templates/statistics.html b/ffmap/web/templates/statistics.html index b155e36..c045140 100644 --- a/ffmap/web/templates/statistics.html +++ b/ffmap/web/templates/statistics.html @@ -194,6 +194,15 @@