Changelog: https://roxy-wi.org/changelog.py#5_5_0
pull/321/head v5.5.0.0
Pavel Loginov 2022-04-01 21:22:06 +03:00
parent 3cd81d1ae6
commit b7476c7d55
2 changed files with 22 additions and 22 deletions

View File

@ -1336,35 +1336,35 @@ def ssh_command(server_ip, commands, **kwargs):
stdin, stdout, stderr = ssh.exec_command(command, get_pty=True) stdin, stdout, stderr = ssh.exec_command(command, get_pty=True)
except Exception as e: except Exception as e:
logging('localhost', ' ' + str(e), haproxywi=1) logging('localhost', ' ' + str(e), haproxywi=1)
ssh.close()
return str(e) return str(e)
if kwargs.get("ip") == "1": try:
show_ip(stdout) if kwargs.get("ip") == "1":
elif kwargs.get("show_log") == "1": show_ip(stdout)
return show_log(stdout, grep=kwargs.get("grep")) elif kwargs.get("show_log") == "1":
elif kwargs.get("server_status") == "1": return show_log(stdout, grep=kwargs.get("grep"))
server_status(stdout) elif kwargs.get("server_status") == "1":
elif kwargs.get('print_out'): server_status(stdout)
print(stdout.read().decode(encoding='UTF-8')) elif kwargs.get('print_out'):
return stdout.read().decode(encoding='UTF-8') print(stdout.read().decode(encoding='UTF-8'))
elif kwargs.get('return_err') == 1: return stdout.read().decode(encoding='UTF-8')
return stderr.read().decode(encoding='UTF-8') elif kwargs.get('return_err') == 1:
elif kwargs.get('raw'): return stderr.read().decode(encoding='UTF-8')
return stdout elif kwargs.get('raw'):
else: return stdout
return stdout.read().decode(encoding='UTF-8') else:
return stdout.read().decode(encoding='UTF-8')
except Exception as e:
logging('localhost', str(e), haproxywi=1)
finally:
ssh.close()
for line in stderr.read().decode(encoding='UTF-8'): for line in stderr.read().decode(encoding='UTF-8'):
if line: if line:
print("<div class='alert alert-warning'>"+line+"</div>") print("<div class='alert alert-warning'>"+line+"</div>")
logging('localhost', ' '+line, haproxywi=1) logging('localhost', ' '+line, haproxywi=1)
try:
ssh.close()
except Exception:
logging('localhost', ' '+str(ssh), haproxywi=1)
return "error: "+str(ssh)
def subprocess_execute(cmd): def subprocess_execute(cmd):
import subprocess import subprocess

View File

@ -3,7 +3,7 @@ global_defs {
} }
#health-check for keepalive #health-check for keepalive
vrrp_script chk_haproxy { vrrp_script chk_haproxy {
script "/usr/bin/pgrep haproxy" script "/usr/bin/pgrep -f 'haproxy '"
interval 2 interval 2
weight 3 weight 3
} }