[statistiques] passage de la nouvelle méthode de comptage en production
darcs-hash:20100224005313-61eff-786eeaaa420b0034622090717edb6aa1166a861c.gz
This commit is contained in:
parent
5e988111e9
commit
73b2a5c82f
1 changed files with 6 additions and 44 deletions
|
@ -46,15 +46,16 @@ pgsql = PgSQL.connect(host='/var/run/postgresql',
|
|||
database='filtrage', user='crans')
|
||||
curseur = pgsql.cursor()
|
||||
|
||||
pgsql2 = PgSQL.connect(host='/var/run/postgresql',
|
||||
database='netacct-ng', user='crans')
|
||||
curseur2 = pgsql2.cursor()
|
||||
|
||||
###########################
|
||||
# Statistiques d'upload : #
|
||||
###########################
|
||||
# Y a-t-il eu des récidivistes
|
||||
|
||||
def ipv4or6(addr):
|
||||
if ':' in addr:
|
||||
return "IPv6"
|
||||
else:
|
||||
return "IPv4"
|
||||
|
||||
# Liste des uploads :
|
||||
#####################
|
||||
|
@ -72,48 +73,14 @@ WHERE
|
|||
GROUP BY ip_crans
|
||||
ORDER BY somme DESC"""
|
||||
curseur.execute(requete)
|
||||
liste_upload = tableau(data = [ (l[1], l[2], gethostname(str(l[0])))
|
||||
liste_upload = tableau(data = [ (l[1], l[2], ipv4or6(str(l[0])), gethostname(str(l[0])))
|
||||
for l in curseur.fetchall()
|
||||
if int(l[1]) > 100*1024*1024
|
||||
and str(l[0]) not in serveurs_ips ],
|
||||
titre = ['upload', 'download', 'machine'],
|
||||
largeur = [10, 10, 30],
|
||||
format = ['o', 'o', 's'],
|
||||
alignement = ['d', 'd', 'c']).encode('iso-8859-15')
|
||||
|
||||
|
||||
# Liste des uploads (expérimental) :
|
||||
####################################
|
||||
requete = """SELECT ip_crans, sum(upload) AS somme, sum(download)
|
||||
FROM upload
|
||||
WHERE
|
||||
date > timestamp 'now' - interval '1 day'
|
||||
AND NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM exemptes
|
||||
WHERE
|
||||
upload.ip_crans <<= exemptes.ip_crans
|
||||
AND upload.ip_ext <<= exemptes.ip_dest
|
||||
)
|
||||
GROUP BY ip_crans
|
||||
ORDER BY somme DESC"""
|
||||
curseur2.execute(requete)
|
||||
|
||||
def ipv4or6(addr):
|
||||
if ':' in addr:
|
||||
return "IPv6"
|
||||
else:
|
||||
return "IPv4"
|
||||
|
||||
liste_upload2 = tableau(data = [ (l[1], l[2], ipv4or6(str(l[0])), gethostname(str(l[0])))
|
||||
for l in curseur2.fetchall()
|
||||
if int(l[1]) > 100*1024*1024 or ':' in l[0]],
|
||||
titre = ['upload', 'download', 'proto', 'machine'],
|
||||
largeur = [10, 10, 10, 40],
|
||||
format = ['o', 'o', 's', 's'],
|
||||
alignement = ['d', 'd', 'c', 'c']).encode('iso-8859-15')
|
||||
|
||||
|
||||
# Trafic exempté :
|
||||
##################
|
||||
requete = """SELECT ip_crans, sum(upload) AS somme, sum(download)
|
||||
|
@ -324,10 +291,6 @@ Content-Type: text/plain; charset="iso-8859-15"
|
|||
|
||||
%(liste_upload)s
|
||||
|
||||
*Statistiques de trafic* (expérimental)
|
||||
|
||||
%(liste_upload2)s
|
||||
|
||||
*Statistiques de trafic des adhérents exemptés* (juste le trafic exempté)
|
||||
|
||||
%(liste_exemptes)s
|
||||
|
@ -345,7 +308,6 @@ corps = message % { 'From': expediteur,
|
|||
'liste_etherunk': liste_etherunk,
|
||||
'liste_serveurs': liste_serveurs,
|
||||
'liste_upload': liste_upload,
|
||||
'liste_upload2': liste_upload2,
|
||||
'liste_p2p': liste_p2p,
|
||||
'liste_virus': liste_virus,
|
||||
'liste_virus2': liste_virus2,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue