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('%s' % (server[1], server[1], server[1])) - funct.ssh_command(server[2], commands, server_status="1") + cmd = 'echo "show info" |nc %s 1999 |grep -e "Process_num"' % server[2] + funct.server_status(funct.subprocess_execute(cmd)) print('') if funct.is_admin(): print('start' % server[2]) @@ -31,22 +31,28 @@ def get_overview(): print('compare' % server[2]) print('map' % server[2]) print('') - funct.ssh_command(server[2], commands1) + funct.ssh_command(server[2], commands) print('') def get_overviewServers(): listhap = sql.get_dick_permit() - commands = [ "uname -smor", - "haproxy -v |head -1", - status_command + "|grep Active |awk -F':' '{print $2\":\"$3\":\"$4}' | sed 's/^[ \t]*//'" ] - commands1 = [ "top -u haproxy -b -n 1" ] + commands = [ "top -u haproxy -b -n 1" ] + for server in sorted(listhap): print('

' + server[1] + ':

') 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('')
+		print('')
 		funct.show_backends(server[2])
 		print('
') diff --git a/app/templates/base.html b/app/templates/base.html index 2ca1bb14..e7e0da7d 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -97,7 +97,7 @@ diff --git a/app/templates/ovw.html b/app/templates/ovw.html index 659a2145..4b8d6775 100644 --- a/app/templates/ovw.html +++ b/app/templates/ovw.html @@ -65,7 +65,9 @@ Last edit - + + restart + @@ -85,6 +87,7 @@ Front/Back-ends + restart diff --git a/image/haproxy-wi-overview.jpeg b/image/haproxy-wi-overview.jpeg index 5763f5c9..0b893465 100644 Binary files a/image/haproxy-wi-overview.jpeg and b/image/haproxy-wi-overview.jpeg differ