mirror of https://github.com/Aidaho12/haproxy-wi
parent
d9e6480169
commit
5d12901a5b
|
@ -41,7 +41,7 @@ if form.getvalue('serv') is not None and form.getvalue('open') is not None :
|
|||
conf = open(cfg, "r")
|
||||
print('<a name="conf"></a>')
|
||||
print("<h3>Config from %s</h3>" % serv)
|
||||
print('<form action="config.py#top" method="get">')
|
||||
print('<form action="config.py#top" method="post">')
|
||||
print('<input type="hidden" value="%s" name="serv">' % serv)
|
||||
print('<input type="hidden" value="%s.old" name="oldconfig">' % cfg)
|
||||
print('<textarea name="config" rows="35" cols="100">%s</textarea>' % conf.read())
|
||||
|
@ -70,6 +70,6 @@ if form.getvalue('serv') is not None and form.getvalue('config') is not None :
|
|||
os.system("/bin/diff -ub %s %s >> %slog/config_edit.log" % (oldcfg, cfg, fullpath))
|
||||
os.system("/bin/sudo /bin/rm -f " + hap_configs_dir + "*.old")
|
||||
|
||||
print('</br><a href="viewsttats.py" title="View stats">Go to view stats</a> <br />')
|
||||
print('</br><a href="viewsttats.py?serv=%s" target="_blank" title="View stats">Go to view stats</a> <br />' % serv)
|
||||
|
||||
funct.footer()
|
|
@ -60,7 +60,7 @@ if serv is not None and form.getvalue('open') is not None:
|
|||
funct.logging(serv, "open old config %s" % configver)
|
||||
|
||||
print("<h3>Config from %s, and version is: %s</h3>" % (serv, configver))
|
||||
print('<form action="configver.py#conf" method="get">')
|
||||
print('<form action="configver.py#conf" method="post">')
|
||||
print('<input type="hidden" value="%s" name="serv">' % serv)
|
||||
print('<input type="hidden" value="%s" name="configver">' % configver)
|
||||
print('<input type="hidden" value="1" name="config">')
|
||||
|
@ -81,6 +81,6 @@ if form.getvalue('serv') is not None and form.getvalue('config') is not None:
|
|||
|
||||
funct.upload_and_restart(serv, configver)
|
||||
|
||||
print('<center><br /><a href="viewsttats.py" title="View stats">Go to view stats</a> <br /></center>')
|
||||
print('</br><a href="viewsttats.py?serv=%s" target="_blank" title="View stats">Go to view stats</a> <br />' % serv)
|
||||
|
||||
funct.footer()
|
||||
|
|
|
@ -23,7 +23,7 @@ funct.chooseServer("delver.py#conf", "Delete Versions HAproxy config", "n")
|
|||
if serv is not None and form.getvalue('open') is not None:
|
||||
|
||||
print('<center><h3>Choose old version</h3>')
|
||||
print('<form action="delver.py#conf" method="get">')
|
||||
print('<form action="delver.py#conf" method="post">')
|
||||
|
||||
import glob
|
||||
|
||||
|
@ -51,9 +51,9 @@ if serv is not None and form.getvalue('open') is not None:
|
|||
try:
|
||||
os.remove(form.getvalue(get))
|
||||
print(form.getvalue(get) + "<br />")
|
||||
funct.logging(serv, "delver.py deleted config: %s" % form.getvalue(get))
|
||||
|
||||
funct.logging(serv, "delver.py deleted config: %s" % form.getvalue(get))
|
||||
except OSError:
|
||||
print ("Error: %s - %s." % (e.filename,e.strerror))
|
||||
print('<meta http-equiv="refresh" content="10; url=delver.py?serv=%s&open=open">' % form.getvalue('serv'))
|
||||
print('<meta http-equiv="refresh" content="10; url=delver.py?serv=%s&open=open">' % form.getvalue('serv'))
|
||||
|
||||
funct.footer()
|
|
@ -70,9 +70,9 @@ def show_login_links():
|
|||
login = cookie.get('login')
|
||||
|
||||
if login is None:
|
||||
print('<a style="margin-left: 40px;" href=/cgi-bin/login.py? title="Login" style="size:5">Login</a>')
|
||||
print('<li><a href=/cgi-bin/login.py? title="Login">Login</a></li>')
|
||||
else:
|
||||
print('<a style="margin-left: 40px;" href=/cgi-bin/login.py?logout=logout title="Logout" style="size:5">Logout</a>')
|
||||
print('<li><a href=/cgi-bin/login.py?logout=logout title="Logout">Logout</a></li>')
|
||||
|
||||
def mode_admin(button, **kwargs):
|
||||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||
|
@ -88,20 +88,38 @@ def mode_admin(button, **kwargs):
|
|||
print('<button type="submit">%s</button>' % button)
|
||||
|
||||
def links():
|
||||
print('<a href=/ title="Home Page" style="size:5">Home Page</a> ')
|
||||
print('<a href=/cgi-bin/viewsttats.py title="View Stats" style="size:5">Stats</a> ')
|
||||
print('<a href="http://172.28.5.106:3000/dashboard/db/haproxy" title="Mon" target="_blanck">Monitoring</a> ')
|
||||
print('<a href=/cgi-bin/logs.py title="View logs" style="size:6">Logs</a>')
|
||||
print('<a href=/cgi-bin/edit.py title="Edit settings" style="size:5">Edit settings</a> ')
|
||||
print('<span style="color: #fff"> | Configs: </span>')
|
||||
print('<a href=/cgi-bin/configshow.py title="Show Config">Show</a> ')
|
||||
print('<a href=/cgi-bin/diff.py title="Compare Configs">Compare</a> ')
|
||||
print('<a href=/cgi-bin/add.py title="Add single listen/frontend/backend" style="size:5">Add</a> ')
|
||||
print('<a href=/cgi-bin/config.py title="Edit Config" style="size:5">Edit</a> ')
|
||||
print('<span style="color: #fff"> | Versions: </span>')
|
||||
print('<a href=/cgi-bin/configver.py title="Upload old versions configs" style="size:5">Upload</a>')
|
||||
print('<a href=/cgi-bin/delver.py title="Delete old versions configs" style="size:5">Delete</a>')
|
||||
print('<nav class="menu">'
|
||||
'<ul>'
|
||||
'<li><a href=/ title="Home Page" style="size:5">Home Page</a></li>'
|
||||
'<li><a href="#" title="Statistics, monitoring and logs">Stats</a>'
|
||||
'<ul>'
|
||||
'<li><a href=/cgi-bin/overview.py title="Server and service status"">Overview</a> </li>'
|
||||
'<li><a href=/cgi-bin/viewsttats.py title="View Stats"">Stats</a> </li>'
|
||||
'<li><a href="http://172.28.5.106:3000/d/000000002/haproxy?refresh=1m&orgId=1" title="Mon" target="_blanck">Monitoring</a> </li>'
|
||||
'<li><a href=/cgi-bin/logs.py title="View logs">Logs</a></li>'
|
||||
'</ul>'
|
||||
'</li>'
|
||||
'<li><a href=/cgi-bin/edit.py title="Edit settings" style="size:5">Edit settings</a> </li>'
|
||||
'<li><a href="#">Configs</a>'
|
||||
'<ul>'
|
||||
'<li><a href=/cgi-bin/configshow.py title="Show Config">Show</a></li> '
|
||||
'<li><a href=/cgi-bin/diff.py title="Compare Configs">Compare</a></li>'
|
||||
'<li><a href=/cgi-bin/add.py#listner title="Add single listen">Add listen</a></li>'
|
||||
'<li><a href=/cgi-bin/add.py#frontend title="Add single frontend">Add frontend</a></li>'
|
||||
'<li><a href=/cgi-bin/add.py#backend title="Add single backend">Add backend</a></li>'
|
||||
'<li><a href=/cgi-bin/config.py title="Edit Config" style="size:5">Edit</a> </li>'
|
||||
'</ul>'
|
||||
'</li>'
|
||||
'<li><a href="#">Versions</a>'
|
||||
'<ul>'
|
||||
'<li><a href=/cgi-bin/configver.py title="Upload old versions configs" style="size:5">Upload</a></li>'
|
||||
'<li><a href=/cgi-bin/delver.py title="Delete old versions configs" style="size:5">Delete</a></li>'
|
||||
'</ul>'
|
||||
'</li>')
|
||||
show_login_links()
|
||||
print('</ul>'
|
||||
'</nav>')
|
||||
|
||||
|
||||
def head(title):
|
||||
print('Content-type: text/html\n')
|
||||
|
@ -132,7 +150,7 @@ def footer():
|
|||
'</center></div>'
|
||||
'<div class="footer">'
|
||||
'<div class="footer-link">')
|
||||
links()
|
||||
#links()
|
||||
print('</div></div></body></html>')
|
||||
|
||||
def ssh_connect(serv):
|
||||
|
@ -295,6 +313,8 @@ def ssh_command(serv, commands, **kwargs):
|
|||
compare(stdout)
|
||||
if show_log_funct is 1:
|
||||
show_log(stdout)
|
||||
else:
|
||||
print(stdout.read().decode(encoding='UTF-8'))
|
||||
|
||||
print(stderr.read().decode(encoding='UTF-8'))
|
||||
ssh.close()
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
#!/usr/bin/env python3
|
||||
import html
|
||||
import cgi
|
||||
import funct
|
||||
import configparser
|
||||
import listserv as listhap
|
||||
|
||||
funct.head("Overview")
|
||||
funct.check_config()
|
||||
funct.check_login()
|
||||
|
||||
path_config = "haproxy-webintarface.config"
|
||||
config = configparser.ConfigParser()
|
||||
config.read(path_config)
|
||||
|
||||
commands = [ "top -u haproxy -b -n 1" ]
|
||||
print('<h2>Quick Status </h2><table class="overview">')
|
||||
|
||||
for i in sorted(listhap.listhap):
|
||||
print('<tr><td class="overviewTr"><h3 title="IP ' + listhap.listhap.get(i) + '">Server ' + i + ':</h3></td>')
|
||||
print('<td class="overviewTd"><pre>')
|
||||
funct.ssh_command(listhap.listhap.get(i), commands)
|
||||
print('</pre></td></tr>')
|
||||
|
||||
print("</table>")
|
||||
funct.footer()
|
|
@ -12,9 +12,10 @@
|
|||
<div class="conteinerIndex">
|
||||
<h2>Welcome! HAproxy Web Interface</h2>
|
||||
<h3>Choose your destiny!</h3>
|
||||
<a href=/cgi-bin/overview.py title="Server and service status"">Overview</a> <br />
|
||||
<a href="cgi-bin/viewsttats.py" title="View stats">View stats</a> <br />
|
||||
<a href="cgi-bin/edit.py" title="Edit settings">Edit settings</a> <br />
|
||||
<a href="cgi-bin/logs.py" title="View logs">Logs</a> <br />
|
||||
<a href="cgi-bin/edit.py" title="Edit settings">Edit settings</a> <br />
|
||||
<a href="cgi-bin/diff.py" title="Compare Configs">Compare</a> <br />
|
||||
<a href="cgi-bin/configshow.py" title="Show Config">Show</a> <br />
|
||||
<a href=/cgi-bin/add.py title="Add single listen/frontend/backend">Add</a> <br />
|
||||
|
@ -22,7 +23,7 @@
|
|||
<a href="cgi-bin/configver.py" title="Upload old config">Upload old config</a> <br />
|
||||
<a href="cgi-bin/delver.py" title="Upload old config">Delete old config</a> <br />
|
||||
<div class="copyright">
|
||||
HAproxy Web Interface v1.6
|
||||
HAproxy Web Interface v1.6.1
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
|
110
style.css
110
style.css
|
@ -10,15 +10,22 @@ body {
|
|||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
h2 {
|
||||
border: 1px solid #aaa;
|
||||
padding: 10px;
|
||||
border-radius: 5px;
|
||||
background: #aaa;
|
||||
padding-left: 3%;
|
||||
}
|
||||
.top-menu {
|
||||
background-color: #222;
|
||||
min-height: 50px;
|
||||
margin-bottom: 20px;
|
||||
top: 0;
|
||||
position: fixed;
|
||||
right: 0;
|
||||
left: 0;
|
||||
z-index: 1000;
|
||||
background-color: #222;
|
||||
min-height: 50px;
|
||||
margin-bottom: 20px;
|
||||
top: 0;
|
||||
position: fixed;
|
||||
right: 0;
|
||||
left: 0;
|
||||
z-index: 1000;
|
||||
}
|
||||
.logoText {
|
||||
color: #fff;
|
||||
|
@ -40,26 +47,21 @@ body {
|
|||
padding-left: 7px;
|
||||
padding-right: 7px;
|
||||
}
|
||||
.top-menu a:focus, .footer a:focus {
|
||||
color: #000;
|
||||
}
|
||||
.top-menu a:hover, .footer a:hover {
|
||||
color: #fff;
|
||||
}
|
||||
.top-menu span, .footer span {
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
.top-link {
|
||||
margin-top: 15px;
|
||||
margin-left: 35%;
|
||||
margin-top: 15px;
|
||||
}
|
||||
.top-link, .footer-link {
|
||||
margin-left: 30%;
|
||||
}
|
||||
.conteiner {
|
||||
clear: both;
|
||||
margin-top: 65px;
|
||||
min-height: calc(100vh - 115px);
|
||||
width: 45%;
|
||||
max-width: 50%;
|
||||
min-width: 40%;
|
||||
background-color: #fff;
|
||||
margin-left: 27%;
|
||||
margin-left: 25%;
|
||||
}
|
||||
.configShow, .diff {
|
||||
margin-left: 16%;
|
||||
|
@ -159,13 +161,77 @@ body {
|
|||
right: 0;
|
||||
left: 0;
|
||||
}
|
||||
.overview {
|
||||
width: 100%;
|
||||
}
|
||||
.overview tr{
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.overviewTd {
|
||||
padding-left: 5%;
|
||||
padding-top: 20px;
|
||||
border-color: #ddd;
|
||||
}
|
||||
.overviewTr {
|
||||
margin: 0;
|
||||
background-color: #eee;
|
||||
padding-left: 15px;
|
||||
font-size: 15px;
|
||||
}
|
||||
.footer-link {
|
||||
padding-top: 15px;
|
||||
margin-left: 35%;
|
||||
}
|
||||
.ro {
|
||||
border: none;
|
||||
}
|
||||
.menu {
|
||||
margin-left: 13%;
|
||||
font-weight: bold;
|
||||
font-style: italic;
|
||||
margin-top: -10px;
|
||||
}
|
||||
.menu ul li{
|
||||
padding: 10px;
|
||||
}
|
||||
.menu ul > li:hover{
|
||||
background-color: #333;
|
||||
}
|
||||
.menu ul ul > li:hover{
|
||||
background-color: #69e;
|
||||
}
|
||||
.menu ul li, .menu ul{
|
||||
display: inline-block;
|
||||
}
|
||||
.menu ul{
|
||||
position: relative;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: #222222;
|
||||
}
|
||||
.menu ul ul{
|
||||
display: none;
|
||||
position: absolute;
|
||||
background-color: #007FFF;
|
||||
margin-top: 10px;
|
||||
margin-left: -10px;
|
||||
}
|
||||
.menu ul a{
|
||||
color: #fff;
|
||||
text-decoration: none;
|
||||
}
|
||||
.menu ul ul a{
|
||||
color: #fff;
|
||||
text-decoration: none;
|
||||
}
|
||||
.menu li:hover ul{
|
||||
display: block;
|
||||
}
|
||||
|
||||
.menu li:hover li{
|
||||
display: block;
|
||||
}
|
||||
a {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue