From 2b9d103c5c3066c03d6d3ee52d85aa9d96bb7791 Mon Sep 17 00:00:00 2001 From: clyhtsuriva Date: Sat, 16 May 2020 11:20:30 +0200 Subject: Update www --- www/html/bilan.py | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100755 www/html/bilan.py (limited to 'www/html/bilan.py') diff --git a/www/html/bilan.py b/www/html/bilan.py new file mode 100755 index 0000000..376f0c6 --- /dev/null +++ b/www/html/bilan.py @@ -0,0 +1,75 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + +import mod_python +from fonctions import baseHTML, connexionBD, lien + +def index(req): + req.content_type="text/html" + content=str() + +#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]) +# + cur.execute("SELECT COUNT(*) FROM paquet WHERE (heure>=( SELECT LOCALTIME - interval '1 hour' ) AND heure<= (SELECT LOCALTIME));") + conn.commit() + total_uneheure=str(cur.fetchone()[0]) +# + cur.execute("SELECT ip_destination, COUNT(ip_destination) FROM paquet GROUP BY ip_destination") + conn.commit() + each_ip_dest=cur.fetchall() +### + conn.close() +#sql part + +#loop + for i in each_ip_dest : + content+=(""" +""" + str(i[0]) + """ +""" + str(i[1]) + """ + """) +#loop + +#write the html page + + req.write(baseHTML("ATS-Project",""" +

Bilan

+ +
+ + +"""+str(content)+""" +
IP destinationRecurrence
+ + + +""" +)) -- cgit v1.2.3