mirror of https://github.com/Aidaho12/haproxy-wi
parent
bb2dfcd993
commit
34d67e1e61
|
@ -206,7 +206,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td class="checkbox">
|
<td class="checkbox">
|
||||||
{% if server.11 == 1 %}
|
{% if server.12 == 1 %}
|
||||||
<label for="active-{{server.0}}"></label><input type="checkbox" id="active-{{server.0}}" checked>
|
<label for="active-{{server.0}}"></label><input type="checkbox" id="active-{{server.0}}" checked>
|
||||||
{% else %}
|
{% else %}
|
||||||
<label for="active-{{server.0}}"></label><input type="checkbox" id="active-{{server.0}}">
|
<label for="active-{{server.0}}"></label><input type="checkbox" id="active-{{server.0}}">
|
||||||
|
|
|
@ -138,7 +138,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td class="checkbox">
|
<td class="checkbox">
|
||||||
{% if server.11 == 1 %}
|
{% if server.12 == 1 %}
|
||||||
<label for="active-{{server.0}}"></label><input type="checkbox" id="active-{{server.0}}" checked>
|
<label for="active-{{server.0}}"></label><input type="checkbox" id="active-{{server.0}}" checked>
|
||||||
{% else %}
|
{% else %}
|
||||||
<label for="active-{{server.0}}"></label><input type="checkbox" id="active-{{server.0}}">
|
<label for="active-{{server.0}}"></label><input type="checkbox" id="active-{{server.0}}">
|
||||||
|
|
|
@ -22,50 +22,27 @@ class GracefulKiller:
|
||||||
def main():
|
def main():
|
||||||
servers = sql.select_keep_alive()
|
servers = sql.select_keep_alive()
|
||||||
port = sql.get_setting('haproxy_sock_port')
|
port = sql.get_setting('haproxy_sock_port')
|
||||||
firstrun = True
|
|
||||||
currentstat = []
|
|
||||||
oldstat = []
|
|
||||||
readstats = ""
|
readstats = ""
|
||||||
killer = GracefulKiller()
|
killer = GracefulKiller()
|
||||||
old_stat_service = ""
|
|
||||||
cur_stat_service = ""
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
for serv in servers:
|
for serv in servers:
|
||||||
try:
|
try:
|
||||||
readstats = subprocess.check_output(["echo show stat | nc "+serv[0]+" "+port], shell=True)
|
readstats = subprocess.check_output(["echo show stat | nc "+serv[0]+" "+port], shell=True)
|
||||||
except CalledProcessError as e:
|
except CalledProcessError as e:
|
||||||
if firstrun == False:
|
alert = "Try start HAProxy serivce at " + serv[0]
|
||||||
cur_stat_service = "error"
|
funct.logging("localhost", " "+alert, keep_alive=1)
|
||||||
if old_stat_service != cur_stat_service:
|
start_command = []
|
||||||
alert = "Try start HAProxy serivce at " + serv[0]
|
start_command.append(sql.get_setting('restart_command'))
|
||||||
#funct.telegram_send_mess(str(alert), ip=serv[2])
|
funct.ssh_command(serv[0], start_command)
|
||||||
funct.logging("localhost", " "+alert, keep_alive=1)
|
time.sleep(30)
|
||||||
start_command = []
|
|
||||||
start_command.append(sql.get_setting('restart_command'))
|
|
||||||
funct.ssh_command(serv[0], start_command)
|
|
||||||
|
|
||||||
firstrun = False
|
|
||||||
old_stat_service = cur_stat_service
|
|
||||||
continue
|
continue
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
print(e)
|
print(e)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
else:
|
else:
|
||||||
cur_stat_service = "Ok"
|
cur_stat_service = "Ok"
|
||||||
"""
|
|
||||||
|
|
||||||
if old_stat_service != cur_stat_service:
|
|
||||||
alert = "Now UP HAProxy service at " + serv
|
|
||||||
funct.telegram_send_mess(str(alert), ip=serv[2])
|
|
||||||
funct.logging("localhost", " "+alert, alerting=1)
|
|
||||||
|
|
||||||
time.sleep(5)
|
|
||||||
"""
|
|
||||||
if firstrun == False:
|
|
||||||
firstrun = True
|
|
||||||
old_stat_service = cur_stat_service
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
funct.logging("localhost", " Keep alive service started", keep_alive=1)
|
funct.logging("localhost", " Keep alive service started", keep_alive=1)
|
||||||
|
|
Loading…
Reference in New Issue