|
|
|
@ -2242,7 +2242,7 @@ def select_keepalived_alert(**kwargs):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def select_keep_alive():
|
|
|
|
|
query = Server.select(Server.ip, Server.groups).where(Server.active == 1)
|
|
|
|
|
query = Server.select(Server.ip, Server.groups, Server.server_id).where(Server.active == 1)
|
|
|
|
|
try:
|
|
|
|
|
query_res = query.execute()
|
|
|
|
|
except Exception as e:
|
|
|
|
@ -2252,7 +2252,7 @@ def select_keep_alive():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def select_nginx_keep_alive():
|
|
|
|
|
query = Server.select(Server.ip, Server.groups).where(Server.nginx_active == 1)
|
|
|
|
|
query = Server.select(Server.ip, Server.groups, Server.server_id).where(Server.nginx_active == 1)
|
|
|
|
|
try:
|
|
|
|
|
query_res = query.execute()
|
|
|
|
|
except Exception as e:
|
|
|
|
@ -2262,7 +2262,7 @@ def select_nginx_keep_alive():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def select_apache_keep_alive():
|
|
|
|
|
query = Server.select(Server.ip, Server.groups).where(Server.apache_active == 1)
|
|
|
|
|
query = Server.select(Server.ip, Server.groups, Server.server_id).where(Server.apache_active == 1)
|
|
|
|
|
try:
|
|
|
|
|
query_res = query.execute()
|
|
|
|
|
except Exception as e:
|
|
|
|
@ -2272,7 +2272,7 @@ def select_apache_keep_alive():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def select_keepalived_keep_alive():
|
|
|
|
|
query = Server.select(Server.ip, Server.port, Server.groups).where(Server.keepalived_active == 1)
|
|
|
|
|
query = Server.select(Server.ip, Server.port, Server.groups, Server.server_id).where(Server.keepalived_active == 1)
|
|
|
|
|
try:
|
|
|
|
|
query_res = query.execute()
|
|
|
|
|
except Exception as e:
|
|
|
|
@ -2290,6 +2290,26 @@ def select_keepalived(serv):
|
|
|
|
|
return keepalived
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def select_update_keep_alive_restart(server_id: int, service: str) -> int:
|
|
|
|
|
try:
|
|
|
|
|
restarted = KeepaliveRestart.get(
|
|
|
|
|
(KeepaliveRestart.server_id == server_id) &
|
|
|
|
|
(KeepaliveRestart.service == service)
|
|
|
|
|
).restarted
|
|
|
|
|
except Exception as e:
|
|
|
|
|
out_error(e)
|
|
|
|
|
else:
|
|
|
|
|
return restarted or 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def update_keep_alive_restart(server_id: int, service: str, restarted: int) -> None:
|
|
|
|
|
query = KeepaliveRestart.insert(server_id=server_id, service=service, restarted=restarted).on_conflict('replace')
|
|
|
|
|
try:
|
|
|
|
|
query.execute()
|
|
|
|
|
except Exception as e:
|
|
|
|
|
out_error(e)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def update_keepalived(serv):
|
|
|
|
|
query = Server.update(keepalived='1').where(Server.ip == serv)
|
|
|
|
|
try:
|
|
|
|
|