Mise en forme.
darcs-hash:20060325222144-68412-ec4176db30697af907a81f8d4a67c9c77c352d8d.gz
This commit is contained in:
parent
f16056b8b4
commit
65b6a8768d
2 changed files with 138 additions and 123 deletions
|
@ -44,22 +44,22 @@ mail = smtplib.SMTP('localhost')
|
|||
#####################
|
||||
requete = "SELECT ip_crans,sum(upload) as somme,sum(download) FROM upload WHERE ip_crans IN (SELECT ip_crans FROM avertis_upload where hard='1' or soft='1') and date > timestamp 'now' - interval '1 day' GROUP BY ip_crans ORDER BY somme DESC"
|
||||
curseur.execute(requete)
|
||||
liste_upload = tableau_ng( data = [ [l[1], l[2], socket.gethostbyaddr(str(l[0]))[0]] for l in curseur.fetchall() ],
|
||||
titre = ['upload','download','machine'],
|
||||
largeur = [10, 10, 30],
|
||||
format = ['o','o','s'],
|
||||
alignement = ['d','d','c']).encode('iso-8859-15')
|
||||
liste_upload = tableau_ng(data = [ [l[1], l[2], socket.gethostbyaddr(str(l[0]))[0]] for l in curseur.fetchall() ],
|
||||
titre = ['upload', 'download', 'machine'],
|
||||
largeur = [10, 10, 30],
|
||||
format = ['o', 'o', 's'],
|
||||
alignement = ['d', 'd', 'c']).encode('iso-8859-15')
|
||||
|
||||
|
||||
# Traffic exempté :
|
||||
###################
|
||||
requete = "SELECT ip_crans,sum(upload) AS somme , sum(download) FROM upload WHERE ip_crans IN ( SELECT ip_crans from exemptes) and date > timestamp 'now' - interval '1 day' GROUP BY ip_crans ORDER BY somme DESC"
|
||||
curseur.execute(requete)
|
||||
liste_exemptes = tableau_ng( data = [ [l[1],l[2],socket.gethostbyaddr(str(l[0]))[0] ] for l in curseur.fetchall() ],
|
||||
titre = ['upload','download','machine'],
|
||||
largeur = [10, 10, 30],
|
||||
format = ['o','o','s'],
|
||||
alignement = ['d','d','c']).encode('iso-8859-15')
|
||||
liste_exemptes = tableau_ng(data = [ [l[1], l[2], socket.gethostbyaddr(str(l[0]))[0] ] for l in curseur.fetchall() ],
|
||||
titre = ['upload', 'download', 'machine'],
|
||||
largeur = [10, 10, 30],
|
||||
format = ['o', 'o', 's'],
|
||||
alignement = ['d', 'd', 'c']).encode('iso-8859-15')
|
||||
|
||||
|
||||
# Upload des serveurs :
|
||||
|
@ -84,7 +84,7 @@ liste_serveurs = tableau_ng( data = liste_serveurs,
|
|||
|
||||
# statistiques des gros uploads depuis les serveurs
|
||||
###################################################
|
||||
gros_uploads_des_serveurs = stats (ip_crans=[x.ip() for x in AssociationCrans().machines() if x.nom() not in [u'sila.crans.org']],show=['ip_crans','ip_ext'],upload_mini=50,show_limit=100).encode('iso-8859-15')
|
||||
gros_uploads_des_serveurs = stats(ip_crans=[x.ip() for x in AssociationCrans().machines() if x.nom() not in [u'sila.crans.org']], show=['ip_crans', 'ip_ext'], upload_mini=50, show_limit=100).encode('iso-8859-15')
|
||||
|
||||
############################
|
||||
# Statistiques virus/p2p : #
|
||||
|
@ -95,13 +95,13 @@ gros_uploads_des_serveurs = stats (ip_crans=[x.ip() for x in AssociationCrans().
|
|||
requete = "SELECT DISTINCT ip_crans FROM avertis_virus"
|
||||
curseur.execute(requete)
|
||||
infections = [ x[0] for x in curseur.fetchall() ]
|
||||
liste_virus=[]
|
||||
liste_virus = []
|
||||
for IP in infections:
|
||||
try:
|
||||
hostname = socket.gethostbyaddr("%s"%IP)[0]
|
||||
hostname = socket.gethostbyaddr("%s" % IP)[0]
|
||||
except socket.herror:
|
||||
continue
|
||||
liste_virus.append(["%s"%(str(hostname))])
|
||||
liste_virus.append(["%s" % (str(hostname))])
|
||||
|
||||
liste_virus = tableau_ng(liste_virus, titre=['machine'], largeur=[30]).encode('iso-8859-15')
|
||||
|
||||
|
@ -112,11 +112,11 @@ curseur.execute(requete)
|
|||
liste_virus2 = []
|
||||
for IP, compteur in curseur.fetchall():
|
||||
hostname = socket.gethostbyaddr(IP)[0]
|
||||
liste_virus2.append([hostname,compteur])
|
||||
liste_virus2 = tableau_ng( data = liste_virus2,
|
||||
titre = ['machine','nombre'],
|
||||
largeur = [30, 12],
|
||||
alignement = ['c','d'] ).encode('iso-8859-15')
|
||||
liste_virus2.append([hostname, compteur])
|
||||
liste_virus2 = tableau_ng(data = liste_virus2,
|
||||
titre = ['machine', 'nombre'],
|
||||
largeur = [30, 12],
|
||||
alignement = ['c', 'd']).encode('iso-8859-15')
|
||||
|
||||
|
||||
# Machines ayant fait de attaques flood dans la journée :
|
||||
|
@ -126,11 +126,11 @@ curseur.execute(requete)
|
|||
liste_virus3 = []
|
||||
for IP, compteur in curseur.fetchall():
|
||||
hostname = socket.gethostbyaddr(IP)[0]
|
||||
liste_virus3.append([hostname,compteur])
|
||||
liste_virus3 = tableau_ng( data = liste_virus3,
|
||||
titre = ['machine','nombre'],
|
||||
largeur = [30, 12],
|
||||
alignement = ['c','d'] ).encode('iso-8859-15')
|
||||
liste_virus3.append([hostname, compteur])
|
||||
liste_virus3 = tableau_ng(data = liste_virus3,
|
||||
titre = ['machine', 'nombre'],
|
||||
largeur = [30, 12],
|
||||
alignement = ['c', 'd']).encode('iso-8859-15')
|
||||
|
||||
|
||||
# Machines ayant utilisé des protocoles P2P dans la journée :
|
||||
|
@ -155,13 +155,16 @@ for IP, protocole, compteur, blackliste in curseur.fetchall():
|
|||
hostname = socket.gethostbyaddr(IP)[0]
|
||||
# Le champ blackliste contient la date du blacklistage si il a eu lieu
|
||||
if blackliste :
|
||||
liste_p2p.append(['*%s*'%hostname, '*%s*'%protocole, '*%d*'%compteur, '*%d*'%config.p2p.limite[protocole]])
|
||||
liste_p2p.append(['*%s*' % hostname,
|
||||
'*%s*' % protocole,
|
||||
'*%d*' % compteur,
|
||||
'*%d*' % config.p2p.limite[protocole]])
|
||||
else:
|
||||
liste_p2p.append([hostname, protocole, compteur, config.p2p.limite[protocole]])
|
||||
liste_p2p = tableau_ng( data = liste_p2p,
|
||||
titre = ['machine','protocole','nombre','limite'],
|
||||
largeur = [32, 14, 10, 8],
|
||||
alignement = ['c','c','d','d'] ).encode('iso-8859-15')
|
||||
liste_p2p = tableau_ng(data = liste_p2p,
|
||||
titre = ['machine', 'protocole', 'nombre', 'limite'],
|
||||
largeur = [32, 14, 10, 8],
|
||||
alignement = ['c', 'c', 'd', 'd']).encode('iso-8859-15')
|
||||
|
||||
|
||||
|
||||
|
@ -171,7 +174,7 @@ liste_p2p = tableau_ng( data = liste_p2p,
|
|||
|
||||
expediteur = "disconnect@crans.org"
|
||||
destinataire = "disconnect@crans.org"
|
||||
message="""From: %(From)s
|
||||
message = """From: %(From)s
|
||||
To: %(To)s
|
||||
Subject: Statistiques des dernières 24h
|
||||
Message-Id: <%(uuid)s1@crans.org>
|
||||
|
@ -213,17 +216,17 @@ statistiques.py
|
|||
|
||||
uuid = md5.md5(str(long(time.time() * 1000)) +
|
||||
str(long(random.random()*100000000000000000L))).hexdigest()
|
||||
corps = message %{'From':expediteur,
|
||||
'To':destinataire,
|
||||
'uuid':uuid,
|
||||
'liste_upload':liste_upload,
|
||||
'liste_p2p':liste_p2p,
|
||||
'liste_virus':liste_virus,
|
||||
'liste_virus2':liste_virus2,
|
||||
'liste_virus3':liste_virus3,
|
||||
'liste_exemptes':liste_exemptes,
|
||||
'liste_serveurs':liste_serveurs,
|
||||
'gros_uploads_des_serveurs':gros_uploads_des_serveurs}
|
||||
corps = message % { 'From': expediteur,
|
||||
'To': destinataire,
|
||||
'uuid': uuid,
|
||||
'liste_upload': liste_upload,
|
||||
'liste_p2p': liste_p2p,
|
||||
'liste_virus': liste_virus,
|
||||
'liste_virus2': liste_virus2,
|
||||
'liste_virus3': liste_virus3,
|
||||
'liste_exemptes': liste_exemptes,
|
||||
'liste_serveurs': liste_serveurs,
|
||||
'gros_uploads_des_serveurs': gros_uploads_des_serveurs }
|
||||
|
||||
mail.sendmail('disconnect@crans.org','disconnect@crans.org',corps)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue