mirror of https://github.com/Aidaho12/haproxy-wi
v1.6.1
parent
f0d593df9e
commit
612a2a112f
|
@ -150,8 +150,9 @@ def footer():
|
||||||
'</center></div>'
|
'</center></div>'
|
||||||
'<div class="footer">'
|
'<div class="footer">'
|
||||||
'<div class="footer-link">'
|
'<div class="footer-link">'
|
||||||
'<span class="LogoText">HAproxy-WI</span>')
|
'<span class="LogoText">HAproxy-WI</span>'
|
||||||
print('</div></div></body></html>')
|
'</div>'
|
||||||
|
'</div></body></html>')
|
||||||
|
|
||||||
def ssh_connect(serv):
|
def ssh_connect(serv):
|
||||||
ssh = SSHClient()
|
ssh = SSHClient()
|
||||||
|
@ -173,7 +174,6 @@ def ssh_connect(serv):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e.args)
|
print(e.args)
|
||||||
|
|
||||||
|
|
||||||
def get_config(serv, cfg):
|
def get_config(serv, cfg):
|
||||||
os.chdir(hap_configs_dir)
|
os.chdir(hap_configs_dir)
|
||||||
ssh = ssh_connect(serv)
|
ssh = ssh_connect(serv)
|
||||||
|
@ -182,12 +182,8 @@ def get_config(serv, cfg):
|
||||||
sftp.get(haproxy_config_path, cfg)
|
sftp.get(haproxy_config_path, cfg)
|
||||||
sftp.close()
|
sftp.close()
|
||||||
ssh.close()
|
ssh.close()
|
||||||
except IOError as e:
|
|
||||||
flash(str(e)+" IOERROR")
|
|
||||||
return ["IOERROR: " + str(e),0,0]
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
flash(str(e)+" OTHER EXCEPTION")
|
print("!!! There was an issue, " + str(e))
|
||||||
return ["Error: " + str(e),0,0]
|
|
||||||
|
|
||||||
def show_config(cfg):
|
def show_config(cfg):
|
||||||
print('</center><div class="configShow">')
|
print('</center><div class="configShow">')
|
||||||
|
@ -321,7 +317,10 @@ def ssh_command(serv, commands, **kwargs):
|
||||||
show_log_funct = 1
|
show_log_funct = 1
|
||||||
|
|
||||||
for command in commands:
|
for command in commands:
|
||||||
stdin , stdout, stderr = ssh.exec_command(command)
|
try:
|
||||||
|
stdin, stdout, stderr = ssh.exec_command(command)
|
||||||
|
except:
|
||||||
|
continue
|
||||||
|
|
||||||
if ip is 1:
|
if ip is 1:
|
||||||
show_ip(stdout)
|
show_ip(stdout)
|
||||||
|
@ -333,7 +332,7 @@ def ssh_command(serv, commands, **kwargs):
|
||||||
print(stdout.read().decode(encoding='UTF-8'))
|
print(stdout.read().decode(encoding='UTF-8'))
|
||||||
|
|
||||||
print(stderr.read().decode(encoding='UTF-8'))
|
print(stderr.read().decode(encoding='UTF-8'))
|
||||||
ssh.close()
|
#ssh.close()
|
||||||
|
|
||||||
def chooseServer(formName, title, note):
|
def chooseServer(formName, title, note):
|
||||||
print('<center><h2>' + title + '</h2>')
|
print('<center><h2>' + title + '</h2>')
|
||||||
|
|
|
@ -13,12 +13,12 @@ path_config = "haproxy-webintarface.config"
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read(path_config)
|
config.read(path_config)
|
||||||
|
|
||||||
commands = [ "top -u haproxy -b -n 1" ]
|
commands = [ "cat /etc/haproxy/haproxy.cfg |grep -E '^listen|^backend|^frontend' |wc -l", "haproxy -v |head -1", "top -u haproxy -b -n 1" ]
|
||||||
print('<h2>Quick Status </h2><table class="overview">')
|
print('<h2>Quick Status </h2><table class="overview">')
|
||||||
|
|
||||||
for i in sorted(listhap.listhap):
|
for i in sorted(listhap.listhap):
|
||||||
print('<tr><td class="overviewTr"><h3 title="IP ' + listhap.listhap.get(i) + '">Server ' + i + ':</h3></td>')
|
print('<tr><td class="overviewTr"><h3 title="IP ' + listhap.listhap.get(i) + '">Server ' + i + ':</h3></td>')
|
||||||
print('<td class="overviewTd"><pre>')
|
print('<td class="overviewTd">Total listen/frontend/backend:<pre>')
|
||||||
funct.ssh_command(listhap.listhap.get(i), commands)
|
funct.ssh_command(listhap.listhap.get(i), commands)
|
||||||
print('</pre></td></tr>')
|
print('</pre></td></tr>')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue