[comptage_upload] Maintenant, ça marche, modulo analyse.py
* Je ferai un truc mieux demain.
This commit is contained in:
parent
615fac78ac
commit
dfa71ba8f6
2 changed files with 4 additions and 10 deletions
|
@ -99,11 +99,6 @@ def stats(ip_crans=[], ip_ext=[],
|
||||||
AND (date > timestamp 'now' - interval '%(begin_time)d hours')
|
AND (date > timestamp 'now' - interval '%(begin_time)d hours')
|
||||||
AND (date < timestamp 'now' - interval '%(end_time)d hours')
|
AND (date < timestamp 'now' - interval '%(end_time)d hours')
|
||||||
GROUP BY %(show)s
|
GROUP BY %(show)s
|
||||||
) UNION (
|
|
||||||
SELECT %(select)s FROM upload6 WHERE (%(ip_crans)s) AND (%(ip_ext)s)
|
|
||||||
AND (date > timestamp 'now' - interval '%(begin_time)d hours')
|
|
||||||
AND (date < timestamp 'now' - interval '%(end_time)d hours')
|
|
||||||
GROUP BY %(show)s
|
|
||||||
)
|
)
|
||||||
) AS resultat_intemediaire
|
) AS resultat_intemediaire
|
||||||
WHERE %(sort_by)s >= '%(sort_mini)d'
|
WHERE %(sort_by)s >= '%(sort_mini)d'
|
||||||
|
@ -174,7 +169,6 @@ def stats(ip_crans=[], ip_ext=[],
|
||||||
|
|
||||||
|
|
||||||
def stats_fork(stub='', ip_crans=[],
|
def stats_fork(stub='', ip_crans=[],
|
||||||
show=['ip_crans', 'ip_ext', 'port_crans', 'port_ext'],
|
|
||||||
upload_mini=0, show_limit=10, begin_time=24, end_time=0,
|
upload_mini=0, show_limit=10, begin_time=24, end_time=0,
|
||||||
show_download=False,resolve_dns=False):
|
show_download=False,resolve_dns=False):
|
||||||
if '/' in stub:
|
if '/' in stub:
|
||||||
|
|
|
@ -83,7 +83,7 @@ def connectsmtp():
|
||||||
|
|
||||||
# Pour trouver la chambre où était la machine que l'on déconnecte.
|
# Pour trouver la chambre où était la machine que l'on déconnecte.
|
||||||
def reperage_chambre(mac):
|
def reperage_chambre(mac):
|
||||||
pgsql = psycopg2.connect(database='mac_prises', user='crans')
|
pgsql = psycopg2.connect(host="thot.adm.crans.org", database='mac_prises', user='crans')
|
||||||
# A priori, pas besoin, on ne fait que des select
|
# A priori, pas besoin, on ne fait que des select
|
||||||
pgsql.set_session(autocommit=True)
|
pgsql.set_session(autocommit=True)
|
||||||
curseur = pgsql.cursor()
|
curseur = pgsql.cursor()
|
||||||
|
@ -100,8 +100,8 @@ def reperage_chambre(mac):
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
# upload par entité (adhérent/club/machine crans)
|
# upload par entité (adhérent/club/machine crans)
|
||||||
upload="""SELECT
|
requete="""SELECT
|
||||||
SUM((agregat.total) as tot_upload, machines.type, machines.id
|
SUM(agregat.total) as tot_upload, machines.type, machines.id
|
||||||
FROM (
|
FROM (
|
||||||
SELECT
|
SELECT
|
||||||
'upload', sum(bytes)/1024/1024 AS total, mac_src
|
'upload', sum(bytes)/1024/1024 AS total, mac_src
|
||||||
|
@ -205,7 +205,7 @@ for elupload, eltype, elid in uploadeurs:
|
||||||
# On inscrit l'instance dans la table des avertis_hard
|
# On inscrit l'instance dans la table des avertis_hard
|
||||||
######################################################
|
######################################################
|
||||||
curseur.execute("INSERT INTO avertis_upload_hard (type,id,date) VALUES ('%s','%d','now')"%(eltype,elid))
|
curseur.execute("INSERT INTO avertis_upload_hard (type,id,date) VALUES ('%s','%d','now')"%(eltype,elid))
|
||||||
analyse.stats_fork('-%s' % debut, ip_crans=[m.ip() for m in proprio.machines()], show_limit=1000)
|
#analyse.stats_fork('-%s' % debut, ip_crans=[m.ip() for m in proprio.machines()], show_limit=1000)
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
sys.stderr.write("Blacklist de id=%s pour %s Mo échoué, %s\n" % (proprio.id(), elupload, error))
|
sys.stderr.write("Blacklist de id=%s pour %s Mo échoué, %s\n" % (proprio.id(), elupload, error))
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue