mirror of https://github.com/Aidaho12/haproxy-wi
parent
bc5bd94467
commit
9896fb1464
|
@ -42,6 +42,6 @@ if form.getvalue('serv') is not None and form.getvalue('open') is not None :
|
||||||
|
|
||||||
funct.show_config(cfg)
|
funct.show_config(cfg)
|
||||||
|
|
||||||
os.system("/bin/sudo /bin/rm -f " + cfg)
|
os.system("/bin/rm -f " + cfg)
|
||||||
|
|
||||||
funct.footer()
|
funct.footer()
|
|
@ -59,7 +59,7 @@ print('<option value=1 %s>Disable server</option>' % selected1)
|
||||||
print('<option value=2 %s>Enable server</option>' % selected2)
|
print('<option value=2 %s>Enable server</option>' % selected2)
|
||||||
print('<option value=3 %s>Show</option>' % selected3)
|
print('<option value=3 %s>Show</option>' % selected3)
|
||||||
print('</select></td>')
|
print('</select></td>')
|
||||||
print('<td><input type="text" name="servbackend" size=40 placeholder="Backend/Server, show info, pools or help" required>')
|
print('<td><input type="text" name="servbackend" size=40 placeholder="Backend/Server, show info, pools or help" required class="form-control">')
|
||||||
|
|
||||||
print('</td></tr>'
|
print('</td></tr>'
|
||||||
'<tr style="border:none;">'
|
'<tr style="border:none;">'
|
||||||
|
|
|
@ -125,7 +125,8 @@ def head(title):
|
||||||
print('Content-type: text/html\n')
|
print('Content-type: text/html\n')
|
||||||
print('<html><head><title>%s</title>' % title)
|
print('<html><head><title>%s</title>' % title)
|
||||||
print('<link href="/favicon.ico" rel="icon" type="image/png" />'
|
print('<link href="/favicon.ico" rel="icon" type="image/png" />'
|
||||||
'<link href="/style.css" rel="stylesheet"><meta charset="UTF-8">'
|
'<meta charset="UTF-8">'
|
||||||
|
'<link href="/style.css" rel="stylesheet">'
|
||||||
'<link rel="stylesheet" href="http://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">'
|
'<link rel="stylesheet" href="http://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">'
|
||||||
'<script src="https://code.jquery.com/jquery-1.12.4.js"></script>'
|
'<script src="https://code.jquery.com/jquery-1.12.4.js"></script>'
|
||||||
'<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>'
|
'<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>'
|
||||||
|
@ -142,12 +143,12 @@ def head(title):
|
||||||
print('</div></div><div class="conteiner">')
|
print('</div></div><div class="conteiner">')
|
||||||
|
|
||||||
def footer():
|
def footer():
|
||||||
print('<center>'
|
print('</center></div>'
|
||||||
|
'<center>'
|
||||||
'<h3>'
|
'<h3>'
|
||||||
'<a href="#top" title="UP">UP</a>'
|
'<a href="#top" title="UP">UP</a>'
|
||||||
'</h3>'
|
'</h3>'
|
||||||
'</center>'
|
'</center>'
|
||||||
'</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>'
|
||||||
|
@ -186,40 +187,42 @@ def get_config(serv, cfg):
|
||||||
print("!!! There was an issue, " + str(e))
|
print("!!! There was an issue, " + str(e))
|
||||||
|
|
||||||
def show_config(cfg):
|
def show_config(cfg):
|
||||||
print('</center><div class="configShow">')
|
print('</center><div style="margin-left: 16%" class="configShow">')
|
||||||
conf = open(cfg, "r")
|
conf = open(cfg, "r")
|
||||||
i = 0
|
i = 0
|
||||||
for line in conf:
|
for line in conf:
|
||||||
i = i + 1
|
i = i + 1
|
||||||
if not line.find("global"):
|
if not line.find("global"):
|
||||||
print('<div class="param">' + line + '</div>')
|
print('<span class="param">' + line + '</span><div>')
|
||||||
continue
|
continue
|
||||||
if not line.find("defaults"):
|
if not line.find("defaults"):
|
||||||
print('<div class="param">' + line + '</div>')
|
print('</div><span class="param">' + line + '</span><div>')
|
||||||
continue
|
continue
|
||||||
if not line.find("listen"):
|
if not line.find("listen"):
|
||||||
print('<div class="param">' + line + '</div>')
|
print('</div><span class="param">' + line + '</span><div>')
|
||||||
continue
|
continue
|
||||||
if not line.find("frontend"):
|
if not line.find("frontend"):
|
||||||
print('<div class="param">' + line + '</div>')
|
print('</div><span class="param">' + line + '</span><div>')
|
||||||
continue
|
continue
|
||||||
if not line.find("backend"):
|
if not line.find("backend"):
|
||||||
print('<div class="param">' + line + '</div>')
|
print('</div><span class="param">' + line + '</span><div>')
|
||||||
continue
|
continue
|
||||||
if "acl" in line or "option" in line or "server" in line:
|
if "acl" in line or "option" in line or "server" in line:
|
||||||
print('<div class="paramInSec"><span class="numRow">')
|
print('<span class="paramInSec"><span class="numRow">')
|
||||||
print(i)
|
print(i)
|
||||||
print('</span>' + line + '</div>')
|
print('</span>' + line + '</span><br />')
|
||||||
continue
|
continue
|
||||||
if "#" in line:
|
if "#" in line:
|
||||||
print('<div class="comment"><span class="numRow">')
|
print('<span class="comment"><span class="numRow">')
|
||||||
print(i)
|
print(i)
|
||||||
print(line + '</span></div>')
|
print(line + '</span></span><br />')
|
||||||
continue
|
continue
|
||||||
print('<div class="configLine"><span class="numRow">')
|
if line.__len__() < 1:
|
||||||
print(i)
|
|
||||||
print('</span>' + line + '</div>')
|
|
||||||
print('</div>')
|
print('</div>')
|
||||||
|
print('<span class="configLine"><span class="numRow">')
|
||||||
|
print(i)
|
||||||
|
print('</span>' + line + '</span><br />')
|
||||||
|
print('</div></div>')
|
||||||
conf.close
|
conf.close
|
||||||
|
|
||||||
def upload_and_restart(serv, cfg):
|
def upload_and_restart(serv, cfg):
|
||||||
|
@ -289,6 +292,7 @@ def compare(stdout):
|
||||||
print('</div></div>')
|
print('</div></div>')
|
||||||
|
|
||||||
def show_log(stdout):
|
def show_log(stdout):
|
||||||
|
#print('<input id="serv" value="%s" hidden><button id="stop" value="tailf_stop">Stop</button>' % serv)
|
||||||
i = 0
|
i = 0
|
||||||
for line in stdout:
|
for line in stdout:
|
||||||
i = i + 1
|
i = i + 1
|
||||||
|
@ -297,6 +301,21 @@ def show_log(stdout):
|
||||||
else:
|
else:
|
||||||
print('<div class="line">' + line + '</div>')
|
print('<div class="line">' + line + '</div>')
|
||||||
|
|
||||||
|
def show_log_tailf(channel, serv):
|
||||||
|
import select
|
||||||
|
print('<input id="serv" value="%s" hidden><button id="stop" value="tailf_stop">Stop</button>' % serv)
|
||||||
|
print('<pre>')
|
||||||
|
while 1:
|
||||||
|
rl, wl, xl = select.select([channel],[],[],0.0)
|
||||||
|
if len(rl) > 0:
|
||||||
|
print(channel.recv(200).decode(encoding='UTF-8'))
|
||||||
|
print('<input id="serv" value="%s" hidden><button id="stop" value="tailf_stop">Stop</button>' % serv)
|
||||||
|
#i = i + 1
|
||||||
|
#if i % 2 == 0:
|
||||||
|
# print('<div class="line3">' + line + '</div>')
|
||||||
|
#else:
|
||||||
|
# print('<div class="line">' + line + '</div>')
|
||||||
|
|
||||||
def show_ip(stdout):
|
def show_ip(stdout):
|
||||||
for line in stdout:
|
for line in stdout:
|
||||||
print(line)
|
print(line)
|
||||||
|
@ -310,6 +329,13 @@ def server_status(stdout):
|
||||||
def ssh_command(serv, commands, **kwargs):
|
def ssh_command(serv, commands, **kwargs):
|
||||||
ssh = ssh_connect(serv)
|
ssh = ssh_connect(serv)
|
||||||
|
|
||||||
|
if kwargs.get("tailf") == "1":
|
||||||
|
transport = ssh.get_transport()
|
||||||
|
channel = transport.open_session()
|
||||||
|
channel.exec_command('tail -f /var/log/haproxy.log')
|
||||||
|
show_log_tailf(channel, serv)
|
||||||
|
|
||||||
|
|
||||||
for command in commands:
|
for command in commands:
|
||||||
try:
|
try:
|
||||||
stdin, stdout, stderr = ssh.exec_command(command)
|
stdin, stdout, stderr = ssh.exec_command(command)
|
||||||
|
@ -325,7 +351,7 @@ def ssh_command(serv, commands, **kwargs):
|
||||||
if kwargs.get("server_status") == "1":
|
if kwargs.get("server_status") == "1":
|
||||||
server_status(stdout)
|
server_status(stdout)
|
||||||
else:
|
else:
|
||||||
print(stdout.read().decode(encoding='UTF-8'))
|
print('<div style="margin: -10px;">'+stdout.read().decode(encoding='UTF-8')+'</div>')
|
||||||
|
|
||||||
print(stderr.read().decode(encoding='UTF-8'))
|
print(stderr.read().decode(encoding='UTF-8'))
|
||||||
|
|
||||||
|
|
|
@ -54,10 +54,10 @@ else:
|
||||||
if form.getvalue('grep') is not None:
|
if form.getvalue('grep') is not None:
|
||||||
grep = 'value='+form.getvalue('grep')
|
grep = 'value='+form.getvalue('grep')
|
||||||
else:
|
else:
|
||||||
grep = 'value='
|
grep = ' '
|
||||||
|
|
||||||
print('</td><td><input type="text" name="rows" %s required></td>' % rows)
|
print('</td><td><input type="text" name="rows" %s class="form-control" required></td>' % rows)
|
||||||
print('<td><input type="text" name="grep" %s>' % grep)
|
print('<td><input type="text" name="grep" class="form-control" %s >' % grep)
|
||||||
print('</td></tr>'
|
print('</td></tr>'
|
||||||
'<tr style="border:none;">'
|
'<tr style="border:none;">'
|
||||||
'<th style="border:none;">'
|
'<th style="border:none;">'
|
||||||
|
@ -86,6 +86,6 @@ if form.getvalue('serv') is not None:
|
||||||
commands = [ 'sudo tail -%s /var/log/%s/syslog.log %s %s' % (rows, serv, grep_act, grep) ]
|
commands = [ 'sudo tail -%s /var/log/%s/syslog.log %s %s' % (rows, serv, grep_act, grep) ]
|
||||||
syslog_server = config.get('logs', 'syslog_server')
|
syslog_server = config.get('logs', 'syslog_server')
|
||||||
|
|
||||||
funct.ssh_command(syslog_server, commands, show_log="1")
|
funct.ssh_command(syslog_server, commands, show_log="1", tailf="0")
|
||||||
|
|
||||||
funct.footer()
|
funct.footer()
|
|
@ -53,3 +53,8 @@ if form.getvalue('name') is not None:
|
||||||
if s in line and name in line:
|
if s in line and name in line:
|
||||||
print("yes")
|
print("yes")
|
||||||
break
|
break
|
||||||
|
|
||||||
|
if form.getvalue('tailf_stop') is not None:
|
||||||
|
serv = form.getvalue('serv')
|
||||||
|
commands = [ "ps ax |grep python3 |grep -v grep |awk '{ print $1 }' |xargs kill" ]
|
||||||
|
funct.ssh_command(serv, commands)
|
|
@ -17,19 +17,37 @@ print('<h2>Quick Status </h2><table class="overview">')
|
||||||
|
|
||||||
commands = [ "ps -Af |grep [h]aproxy |wc -l" ]
|
commands = [ "ps -Af |grep [h]aproxy |wc -l" ]
|
||||||
|
|
||||||
print('<tr class="overviewHead"><td class="padding10">Server</td><td class="padding10">HAproxy status</td></tr>')
|
print('<tr class="overviewHead">'
|
||||||
|
'<td class="padding10">Server</td>'
|
||||||
|
'<td class="padding10">'
|
||||||
|
'HAproxy status'
|
||||||
|
'<span style="float: right; margin-left: 80&;">'
|
||||||
|
'<a href="" title="Update status" id="update">'
|
||||||
|
'<img alt="Update" src="/image/pic/update.png" style="max-width: 20px;">'
|
||||||
|
'</a>'
|
||||||
|
'</td>'
|
||||||
|
'</tr>')
|
||||||
for i in sorted(listhap.listhap):
|
for i in sorted(listhap.listhap):
|
||||||
print('<tr><td class="padding10">' + i + '</td><td>')
|
print('<tr><td class="padding10">' + i + '</td><td>')
|
||||||
funct.ssh_command(listhap.listhap.get(i), commands, server_status="1")
|
funct.ssh_command(listhap.listhap.get(i), commands, server_status="1")
|
||||||
print('</td></tr>')
|
print('</td></tr>')
|
||||||
print('<tr class="overviewHead"><td class="padding10">Server</td><td class="padding10">Server status</td></tr>')
|
print('<tr class="overviewHead">'
|
||||||
|
'<td class="padding10">Server</td>'
|
||||||
|
'<td class="padding10">'
|
||||||
|
'Server status'
|
||||||
|
'<span style="float: right; margin-left: 80&;">'
|
||||||
|
'<a href="" title="Update status" id="update">'
|
||||||
|
'<img alt="Update" src="/image/pic/update.png" style="max-width: 20px;">'
|
||||||
|
'</a>'
|
||||||
|
'</td>'
|
||||||
|
'</tr>')
|
||||||
print('</td></tr>')
|
print('</td></tr>')
|
||||||
commands = [ "cat /etc/haproxy/haproxy.cfg |grep -E '^listen|^backend|^frontend' |grep -v stats |wc -l", "haproxy -v |head -1", "top -u haproxy -b -n 1" ]
|
commands = [ "cat /etc/haproxy/haproxy.cfg |grep -E '^listen|^backend|^frontend' |grep -v stats |wc -l", "uname -smor", "haproxy -v |head -1", "top -u haproxy -b -n 1" ]
|
||||||
for i in sorted(listhap.listhap):
|
for i in sorted(listhap.listhap):
|
||||||
print('<tr><td class="overviewTr"><h3 title="IP ' + listhap.listhap.get(i) + '">' + i + ':</h3></td>')
|
print('<tr><td class="overviewTr"><h3 title="IP ' + listhap.listhap.get(i) + '">' + i + ':</h3></td>')
|
||||||
print('<td class="overviewTd">Total listen/frontend/backend:<pre>')
|
print('<td class="overviewTd"><span style="margin-left: -10px;">Total listen/frontend/backend:</span><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>')
|
||||||
|
|
||||||
print("</table>")
|
print('</table>')
|
||||||
funct.footer()
|
funct.footer()
|
Binary file not shown.
After Width: | Height: | Size: 71 KiB |
|
@ -7,6 +7,11 @@ $( function() {
|
||||||
//$( document ).tooltip();
|
//$( document ).tooltip();
|
||||||
$( "input[type=submit], button" ).button();
|
$( "input[type=submit], button" ).button();
|
||||||
$( "input[type=checkbox]" ).checkboxradio();
|
$( "input[type=checkbox]" ).checkboxradio();
|
||||||
|
$( ".configShow" ).accordion({
|
||||||
|
collapsible: true,
|
||||||
|
heightStyle: "content",
|
||||||
|
icons: { "header": "ui-icon-plus", "activeHeader": "ui-icon-minus" }
|
||||||
|
});
|
||||||
} );
|
} );
|
||||||
|
|
||||||
$( function() {
|
$( function() {
|
||||||
|
|
90
style.css
90
style.css
|
@ -26,6 +26,9 @@ h3 {
|
||||||
form {
|
form {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
iframe {
|
||||||
|
width: 33%;
|
||||||
|
}
|
||||||
.top-menu {
|
.top-menu {
|
||||||
background-color: #222;
|
background-color: #222;
|
||||||
min-height: 50px;
|
min-height: 50px;
|
||||||
|
@ -104,7 +107,7 @@ form {
|
||||||
}
|
}
|
||||||
.param {
|
.param {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
background-color: #DCDCDC;
|
//background-color: #DCDCDC;
|
||||||
padding-left: 13px;
|
padding-left: 13px;
|
||||||
}
|
}
|
||||||
.numRow {
|
.numRow {
|
||||||
|
@ -261,11 +264,41 @@ form {
|
||||||
.menu li:hover li{
|
.menu li:hover li{
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
@keyframes shadow {
|
||||||
|
from {box-shadow: 0px 0px 0px red inset;}
|
||||||
|
50% {text-shadow: 0 0 30px black;}
|
||||||
|
to {box-shadow: 0 -5px 5px -5px rgb(38, 137, 60) inset}
|
||||||
|
}
|
||||||
|
@keyframes shadow-red {
|
||||||
|
from {box-shadow: 0px 0px 0px red inset;}
|
||||||
|
50% {text-shadow: 0 0 30px black;}
|
||||||
|
to {box-shadow: 0 -5px 5px -5px #5D9CEB inset}
|
||||||
|
}
|
||||||
|
|
||||||
|
//.form-control:valid {
|
||||||
|
// animation: shadow 0.3s forwards;
|
||||||
|
//}
|
||||||
|
.form-control:hover {
|
||||||
|
animation: shadow-red 0.3s forwards;
|
||||||
|
}
|
||||||
|
.form-control:invalid, .form-control:valid {
|
||||||
|
background-image: linear-gradient(0deg,#d50000 2px,rgba(213,0,0,0) 0),linear-gradient(0deg,rgba(0,0,0,.26) 1px,transparent 0);
|
||||||
|
}
|
||||||
|
.form-control {
|
||||||
|
background: no-repeat bottom,50% calc(100% - 1px);
|
||||||
|
background-size: 0 100%,100% 100%;
|
||||||
|
border: 0;
|
||||||
|
transition: background 1s ease-out;
|
||||||
|
padding-left: 0;
|
||||||
|
padding-right: 0;
|
||||||
|
}
|
||||||
|
.ui-state-default {
|
||||||
|
background-color: #EBF1F1;
|
||||||
|
}
|
||||||
a {
|
a {
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
}
|
}
|
||||||
a:active,
|
a:active, a:hover {
|
||||||
a:hover {
|
|
||||||
outline: 0;
|
outline: 0;
|
||||||
}
|
}
|
||||||
abbr[title] {
|
abbr[title] {
|
||||||
|
@ -283,9 +316,8 @@ textarea {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font: inherit;
|
font: inherit;
|
||||||
color: inherit;
|
color: inherit;
|
||||||
//background-color: #ccc;
|
|
||||||
border-radius: 7px;
|
border-radius: 7px;
|
||||||
padding: 5px;
|
padding: 8px;
|
||||||
}
|
}
|
||||||
button {
|
button {
|
||||||
overflow: visible;
|
overflow: visible;
|
||||||
|
@ -293,9 +325,6 @@ button {
|
||||||
button,
|
button,
|
||||||
select {
|
select {
|
||||||
text-transform: none;
|
text-transform: none;
|
||||||
//background-color: #eee;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
select {
|
select {
|
||||||
color: #000;
|
color: #000;
|
||||||
|
@ -324,28 +353,17 @@ input::-moz-focus-inner {
|
||||||
input {
|
input {
|
||||||
line-height: normal;
|
line-height: normal;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
padding: 4px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fieldset {
|
|
||||||
padding: .35em .625em .75em;
|
|
||||||
margin: 0 2px;
|
|
||||||
border: 1px solid #c0c0c0;
|
|
||||||
}
|
|
||||||
legend {
|
|
||||||
padding: 0;
|
|
||||||
border: 0;
|
|
||||||
}
|
|
||||||
optgroup {
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
table {
|
table {
|
||||||
border-spacing: 0;
|
border-spacing: 0;
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
|
background-color: transparent;
|
||||||
}
|
}
|
||||||
td,
|
td,
|
||||||
th {
|
th {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
text-align: left;
|
||||||
}
|
}
|
||||||
a,
|
a,
|
||||||
a:visited {
|
a:visited {
|
||||||
|
@ -381,36 +399,6 @@ a:focus {
|
||||||
margin-left: -15px;
|
margin-left: -15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
table {
|
|
||||||
background-color: transparent;
|
|
||||||
}
|
|
||||||
caption {
|
|
||||||
padding-top: 8px;
|
|
||||||
padding-bottom: 8px;
|
|
||||||
color: #777;
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
th {
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
fieldset {
|
|
||||||
min-width: 0;
|
|
||||||
padding: 0;
|
|
||||||
margin: 0;
|
|
||||||
border: 0;
|
|
||||||
}
|
|
||||||
legend {
|
|
||||||
display: block;
|
|
||||||
width: 100%;
|
|
||||||
padding: 0;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
font-size: 21px;
|
|
||||||
line-height: inherit;
|
|
||||||
color: #333;
|
|
||||||
border: 0;
|
|
||||||
border-bottom: 1px solid #e5e5e5;
|
|
||||||
}
|
|
||||||
label {
|
label {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
|
|
Loading…
Reference in New Issue