diff --git a/app/funct.py b/app/funct.py index 059c5aff..a76ead4d 100644 --- a/app/funct.py +++ b/app/funct.py @@ -415,17 +415,17 @@ def show_ip(stdout): for line in stdout: print(line) -def server_status(stdout): +def server_status(stdout): proc_count = "" - i = 0 - for line in stdout.read().decode(encoding='UTF-8'): - i = i + 1 - if i == 1: - proc_count += line - if line.find("0"): - err = 1 - else: - err = 0 + + for line in stdout: + if "Ncat: Connection refused." not in line: + for k in line: + proc_count = k.split(":")[1] + err = 1 + else: + err = 0 + proc_count = 0 if err != 0: print(' UP running %s processes' % proc_count) diff --git a/app/ovw.py b/app/ovw.py index 9b93a62d..aed5fb40 100644 --- a/app/ovw.py +++ b/app/ovw.py @@ -14,12 +14,12 @@ form = cgi.FieldStorage() def get_overview(): listhap = sql.get_dick_permit() - commands = [ "ps -Af |grep [h]aproxy |wc -l" ] - commands1 = [ "ls -l %s |awk '{ print $6\" \"$7\" \"$8}'" % haproxy_config_path ] + commands = [ "ls -l %s |awk '{ print $6\" \"$7\" \"$8}'" % haproxy_config_path ] for server in listhap: print('
') + cmd = 'echo "show info" |nc %s 1999 |grep -e "Ver\|CurrConns\|SessRate\|Maxco\|MB\|Uptime:"' % server[2] + out = funct.subprocess_execute(cmd) + + for k in out: + if "Ncat: Connection refused." not in k: + for r in k: + print(r) + else: + print("Can\'t connect to HAproxy") + print('
') funct.ssh_command(server[2], commands) - print('
') - funct.ssh_command(server[2], commands1) - print('