aboutsummaryrefslogtreecommitdiff
path: root/www/html/analyse.py
diff options
context:
space:
mode:
Diffstat (limited to 'www/html/analyse.py')
-rwxr-xr-x[-rw-r--r--]www/html/analyse.py38
1 files changed, 29 insertions, 9 deletions
diff --git a/www/html/analyse.py b/www/html/analyse.py
index 57c0892..df72cae 100644..100755
--- a/www/html/analyse.py
+++ b/www/html/analyse.py
@@ -9,20 +9,40 @@ def index(req):
content=str()
#sql part
-# conn=connexionBD()
-# cur=conn.cursor()
-# sql="select * from paquet;"
-# cur.execute(sql)
-# conn.commit()
-# data=cur.fetchall()
-# conn.close()
-#sql part
+ conn=connexionBD()
+ cur=conn.cursor()
+
+ cur.execute("SELECT COUNT(*) FROM paquet")
+ conn.commit()
+ total=str(cur.fetchone()[0])
+
+ cur.execute("SELECT COUNT(DISTINCT ip_source) FROM paquet")
+ conn.commit()
+ total_ip_src=str(cur.fetchone()[0])
+
+ cur.execute("SELECT COUNT(DISTINCT ip_destination) FROM paquet")
+ conn.commit()
+ total_ip_dst=str(cur.fetchone()[0])
+
+ cur.execute("SELECT COUNT(DISTINCT port_source) FROM paquet")
+ conn.commit()
+ total_port_src=str(cur.fetchone()[0])
+ cur.execute("SELECT COUNT(DISTINCT port_destination) FROM paquet")
+ conn.commit()
+ total_port_dst=str(cur.fetchone()[0])
+
+ conn.close()
+#sql part
#write the html page
req.write(baseHTML("ATS-Project","""
<h1>Analyse</h1>
+<p>Nombre total de paquets : <b>"""+total+"""</b></p>
+<p>Nombre total d'adresses IP source differentes : <b>"""+total_ip_src+"""</b></p>
+<p>Nombre total d'adresses IP destination differentes : <b>"""+total_ip_dst+"""</b></p>
+<p>Nombre total de ports source differents : <b>"""+total_port_src+"""</b></p>
+<p>Nombre total de ports destination differents : <b>"""+total_port_dst+"""</b></p>
"""
-+ content
))