Added deletion of dead servers (downs>=purge_days)
This commit is contained in:
pare
13fd0434de
commit
f21e3f8461
S'han modificat 1 arxius amb 32 adicions i 0 eliminacions
|
@ -86,6 +86,32 @@ def dead():
|
|||
|
||||
return dead_lst
|
||||
|
||||
def delete_deads():
|
||||
|
||||
conn = None
|
||||
|
||||
try:
|
||||
|
||||
conn = psycopg2.connect(database = cleanserver_db, user = cleanserver_db_user, password = "", host = "/var/run/postgresql", port = "5432")
|
||||
|
||||
cur = conn.cursor()
|
||||
|
||||
cur.execute("delete from peers where downs >=(%s)", (purge_days,))
|
||||
|
||||
conn.commit()
|
||||
|
||||
cur.close()
|
||||
|
||||
except (Exception, psycopg2.DatabaseError) as error:
|
||||
|
||||
print(error)
|
||||
|
||||
finally:
|
||||
|
||||
if conn is not None:
|
||||
|
||||
conn.close()
|
||||
|
||||
def write_server(server, alive, checked):
|
||||
|
||||
cleanserver_db, cleanserver_db_user = dbconfig()
|
||||
|
@ -302,6 +328,12 @@ if __name__ == '__main__':
|
|||
servers_count+=1
|
||||
|
||||
##########################################
|
||||
# delete dead servers old than purge_days
|
||||
|
||||
delete_deads()
|
||||
|
||||
##########################################
|
||||
# get current hostname peers
|
||||
|
||||
user_agent = {'User-agent': 'Mozilla/5.0'}
|
||||
|
||||
|
|
Loading…
Referencia en una nova incidència