nouveau format de tableau, utilisation dans la gestion de la surveillance du
rseau darcs-hash:20051103235738-4ec08-4cbc92f43c8eb43da17d910d09e5d5597e9d781c.gz
This commit is contained in:
parent
ba62565f57
commit
92fa0abe2a
3 changed files with 132 additions and 78 deletions
|
@ -5,7 +5,7 @@ import socket
|
|||
import sys
|
||||
from pyPgSQL import PgSQL
|
||||
sys.path.append('/usr/scripts/gestion/')
|
||||
from affich_tools import tableau
|
||||
from affich_tools import tableau_ng
|
||||
|
||||
def stats (ip_crans, group=['ip_ext','port_crans','port_ext'], upload_mini=0, limit=10) :
|
||||
"""
|
||||
|
@ -23,27 +23,37 @@ def stats (ip_crans, group=['ip_ext','port_crans','port_ext'], upload_mini=0, li
|
|||
##########################################
|
||||
|
||||
select = []
|
||||
largeurs = []
|
||||
titres = []
|
||||
|
||||
largeur = []
|
||||
titre = []
|
||||
format = []
|
||||
alignement = []
|
||||
|
||||
if 'ip_ext' in group :
|
||||
select.append('ip_ext')
|
||||
largeurs.append('*')
|
||||
titres.append('machine ext')
|
||||
largeur.append(30)
|
||||
titre.append('machine ext')
|
||||
format.append('s')
|
||||
alignement.append('c')
|
||||
|
||||
if 'port_ext' in group :
|
||||
select.append('port_ext')
|
||||
largeurs.append(10)
|
||||
titres.append('port ext')
|
||||
largeur.append(10)
|
||||
titre.append('port ext')
|
||||
format.append('s')
|
||||
alignement.append('d')
|
||||
|
||||
if 'port_crans' in group :
|
||||
select.append('port_crans')
|
||||
largeurs.append(10)
|
||||
titres.append('port crans')
|
||||
largeur.append(10)
|
||||
titre.append('port crans')
|
||||
format.append('s')
|
||||
alignement.append('d')
|
||||
|
||||
select += ['floor(sum(download)/1024/1024) as download','floor(sum(upload)/1024/1024) as upload']
|
||||
largeurs += [8,8]
|
||||
titres += ['download','upload']
|
||||
select += ['sum(download) as download','sum(upload) as upload']
|
||||
largeur += [10,10]
|
||||
titre += ['download','upload']
|
||||
format += ['o','o']
|
||||
alignement += ['d','d']
|
||||
|
||||
# requete dans la base
|
||||
######################
|
||||
|
@ -54,7 +64,7 @@ def stats (ip_crans, group=['ip_ext','port_crans','port_ext'], upload_mini=0, li
|
|||
curseur.execute(requete)
|
||||
results = curseur.fetchall()
|
||||
|
||||
# on transforme tout en chaine
|
||||
# on transforme tout en chaine
|
||||
results = [ [ str(x) for x in line ] for line in results ]
|
||||
|
||||
# on modifie les ip en noms de machine
|
||||
|
@ -69,7 +79,7 @@ def stats (ip_crans, group=['ip_ext','port_crans','port_ext'], upload_mini=0, li
|
|||
col = select.index(champ)
|
||||
results = [ x[:col] + [nom_de_machine(x[col])] + x[col+1:] for x in results ]
|
||||
|
||||
return tableau(largeurs, [titres] + results )
|
||||
return tableau_ng(results, titre=titre, largeur=largeur, alignement=alignement, format=format)
|
||||
|
||||
if __name__ == '__main__' :
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue