mirror of https://github.com/Aidaho12/haproxy-wi
parent
228bc5418a
commit
c559c1cc9c
23
app/funct.py
23
app/funct.py
|
@ -456,4 +456,25 @@ def ssh_command(serv, commands, **kwargs):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def escape_html(text):
|
def escape_html(text):
|
||||||
return cgi.escape(text, quote=True)
|
return cgi.escape(text, quote=True)
|
||||||
|
|
||||||
|
def subprocess_execute(cmd):
|
||||||
|
import subprocess
|
||||||
|
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, universal_newlines=True)
|
||||||
|
stdout, stderr = p.communicate()
|
||||||
|
output = stdout.splitlines()
|
||||||
|
|
||||||
|
return output, stderr
|
||||||
|
|
||||||
|
def show_backends(serv):
|
||||||
|
import json
|
||||||
|
cmd='echo "show backend" |nc %s 1999' % serv
|
||||||
|
output, stderr = subprocess_execute(cmd)
|
||||||
|
|
||||||
|
for line in output:
|
||||||
|
if "#" in line or "stats" in line:
|
||||||
|
continue
|
||||||
|
if line != "":
|
||||||
|
back = json.dumps(line).split("\"")
|
||||||
|
print(back[1]+"<br>")
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
import html
|
import html
|
||||||
import cgi
|
import cgi
|
||||||
import os, sys
|
import os, sys
|
||||||
import json
|
|
||||||
import subprocess
|
|
||||||
import funct
|
import funct
|
||||||
import sql
|
import sql
|
||||||
import ovw
|
import ovw
|
||||||
|
@ -14,7 +12,7 @@ req = form.getvalue('req')
|
||||||
serv = form.getvalue('serv')
|
serv = form.getvalue('serv')
|
||||||
act = form.getvalue('act')
|
act = form.getvalue('act')
|
||||||
backend = form.getvalue('backend')
|
backend = form.getvalue('backend')
|
||||||
|
|
||||||
print('Content-type: text/html\n')
|
print('Content-type: text/html\n')
|
||||||
|
|
||||||
if form.getvalue('token') is None:
|
if form.getvalue('token') is None:
|
||||||
|
@ -73,24 +71,8 @@ if serv and form.getvalue('ssl_cert'):
|
||||||
funct.logging(serv, "add.py#ssl upload new ssl cert %s" % name)
|
funct.logging(serv, "add.py#ssl upload new ssl cert %s" % name)
|
||||||
|
|
||||||
if backend is not None:
|
if backend is not None:
|
||||||
|
funct.show_backends(serv)
|
||||||
|
|
||||||
cmd='echo "show backend" |nc %s 1999' % serv
|
|
||||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, universal_newlines=True)
|
|
||||||
stdout, stderr = p.communicate()
|
|
||||||
output = stdout.splitlines()
|
|
||||||
|
|
||||||
for line in output:
|
|
||||||
if "#" in line or "stats" in line:
|
|
||||||
continue
|
|
||||||
if backend != "1":
|
|
||||||
if backend in line:
|
|
||||||
print(json.dumps(line))
|
|
||||||
continue
|
|
||||||
if backend == "1":
|
|
||||||
print(json.dumps(line))
|
|
||||||
continue
|
|
||||||
|
|
||||||
|
|
||||||
if form.getvalue('ip') is not None and serv is not None:
|
if form.getvalue('ip') is not None and serv is not None:
|
||||||
commands = [ "sudo ip a |grep inet |egrep -v '::1' |awk '{ print $2 }' |awk -F'/' '{ print $1 }'" ]
|
commands = [ "sudo ip a |grep inet |egrep -v '::1' |awk '{ print $2 }' |awk -F'/' '{ print $1 }'" ]
|
||||||
funct.ssh_command(serv, commands, ip="1")
|
funct.ssh_command(serv, commands, ip="1")
|
||||||
|
@ -106,6 +88,7 @@ if form.getvalue('action_hap') is not None and serv is not None:
|
||||||
if funct.check_haproxy_config(serv):
|
if funct.check_haproxy_config(serv):
|
||||||
commands = [ "sudo systemctl %s haproxy" % action ]
|
commands = [ "sudo systemctl %s haproxy" % action ]
|
||||||
funct.ssh_command(serv, commands)
|
funct.ssh_command(serv, commands)
|
||||||
|
print("HAproxy was %s" % action)
|
||||||
else:
|
else:
|
||||||
print("Bad config, check please")
|
print("Bad config, check please")
|
||||||
|
|
||||||
|
@ -209,9 +192,7 @@ if serv is not None and form.getvalue('rows1') is not None:
|
||||||
grep = ''
|
grep = ''
|
||||||
|
|
||||||
cmd="cat %s| awk -F\"/|:\" '$3>\"%s:00\" && $3<\"%s:00\"' |tail -%s %s %s" % ('/var/log/httpd/'+serv, date, date1, rows, grep_act, grep)
|
cmd="cat %s| awk -F\"/|:\" '$3>\"%s:00\" && $3<\"%s:00\"' |tail -%s %s %s" % ('/var/log/httpd/'+serv, date, date1, rows, grep_act, grep)
|
||||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, universal_newlines=True)
|
output, stderr = funct.subprocess_execute(cmd)
|
||||||
stdout, stderr = p.communicate()
|
|
||||||
output = stdout.splitlines()
|
|
||||||
|
|
||||||
funct.show_log(output)
|
funct.show_log(output)
|
||||||
print(stderr)
|
print(stderr)
|
||||||
|
@ -235,9 +216,7 @@ if form.getvalue('viewlogs') is not None:
|
||||||
grep = ''
|
grep = ''
|
||||||
|
|
||||||
cmd="cat %s| awk '$3>\"%s:00\" && $3<\"%s:00\"' |tail -%s %s %s" % (log_path + viewlog, date, date1, rows, grep_act, grep)
|
cmd="cat %s| awk '$3>\"%s:00\" && $3<\"%s:00\"' |tail -%s %s %s" % (log_path + viewlog, date, date1, rows, grep_act, grep)
|
||||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, universal_newlines=True)
|
output, stderr = funct.subprocess_execute(cmd)
|
||||||
stdout, stderr = p.communicate()
|
|
||||||
output = stdout.splitlines()
|
|
||||||
|
|
||||||
funct.show_log(output)
|
funct.show_log(output)
|
||||||
print(stderr)
|
print(stderr)
|
||||||
|
|
13
app/ovw.py
13
app/ovw.py
|
@ -36,18 +36,19 @@ def get_overview():
|
||||||
|
|
||||||
def get_overviewServers():
|
def get_overviewServers():
|
||||||
listhap = sql.get_dick_permit()
|
listhap = sql.get_dick_permit()
|
||||||
commands = [ "cat " + haproxy_config_path + " |grep -E '^listen|^backend|^frontend' |grep -v stats |wc -l",
|
commands = [ "uname -smor",
|
||||||
"uname -smor",
|
|
||||||
"haproxy -v |head -1",
|
"haproxy -v |head -1",
|
||||||
status_command + "|grep Active | sed 's/^[ \t]*//'" ]
|
status_command + "|grep Active | sed 's/^[ \t]*//'" ]
|
||||||
commands1 = [ "top -u haproxy -b -n 1" ]
|
commands1 = [ "top -u haproxy -b -n 1" ]
|
||||||
for server in sorted(listhap):
|
for server in sorted(listhap):
|
||||||
print('<tr><td class="overviewTr first-collumn"><a name="'+server[1]+'"></a><h3 title="IP ' + server[2] + '">' + server[1] + ':</h3></td>')
|
print('<tr><td class="overviewTr first-collumn"><a name="'+server[1]+'"></a><h3 title="IP ' + server[2] + '">' + server[1] + ':</h3></td>')
|
||||||
print('<td class="overviewTd"><span>Total listen/frontend/backend:</span><pre>')
|
print('<td class="overviewTd"><pre>')
|
||||||
funct.ssh_command(server[2], commands)
|
funct.ssh_command(server[2], commands)
|
||||||
print('</pre></td><td><pre>')
|
print('</pre></td><td><pre>')
|
||||||
funct.ssh_command(server[2], commands1)
|
funct.ssh_command(server[2], commands1)
|
||||||
print('</pre></td></tr>')
|
print('</td><td style="padding-top: 10px; padding-bottom: 10px;">')
|
||||||
|
funct.show_backends(server[2])
|
||||||
|
print('</pre></td><td></td></tr>')
|
||||||
|
|
||||||
def get_map(serv):
|
def get_map(serv):
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
@ -164,7 +165,7 @@ def show_compare_configs(serv):
|
||||||
|
|
||||||
os.chdir(hap_configs_dir)
|
os.chdir(hap_configs_dir)
|
||||||
|
|
||||||
for files in sorted(glob.glob('*.cfg')):
|
for files in sorted(glob.glob('*.cfg'), reverse=True):
|
||||||
ip = files.split("-")
|
ip = files.split("-")
|
||||||
if serv == ip[0]:
|
if serv == ip[0]:
|
||||||
if left == files:
|
if left == files:
|
||||||
|
@ -178,7 +179,7 @@ def show_compare_configs(serv):
|
||||||
print('<select autofocus required name="right" id="right">')
|
print('<select autofocus required name="right" id="right">')
|
||||||
print('<option disabled selected>Choose version</option>')
|
print('<option disabled selected>Choose version</option>')
|
||||||
|
|
||||||
for files in sorted(glob.glob('*.cfg')):
|
for files in sorted(glob.glob('*.cfg'), reverse=True):
|
||||||
ip = files.split("-")
|
ip = files.split("-")
|
||||||
if serv == ip[0]:
|
if serv == ip[0]:
|
||||||
if right == files:
|
if right == files:
|
||||||
|
|
|
@ -44,12 +44,12 @@
|
||||||
<nav class="menu">
|
<nav class="menu">
|
||||||
<ul id="menu">
|
<ul id="menu">
|
||||||
<li><a title="Statistics, monitoring and logs" class="stats">Stats</a>
|
<li><a title="Statistics, monitoring and logs" class="stats">Stats</a>
|
||||||
<li><a href=/app/overview.py title="Server and service status" class="overview-link head-submenu">Overview</a> </li>
|
<li><a href=/app/overview.py title="Server and service status" class="overview-link head-submenu">Overview</a> </li>
|
||||||
<li><a href=/app/viewsttats.py title"Show stats" class="stats head-submenu">Stats</a> </li>
|
<li><a href=/app/viewsttats.py title"Show stats" class="stats head-submenu">Stats</a> </li>
|
||||||
<li><a href=/app/logs.py title="View logs" class="logs head-submenu">Logs</a></li>
|
<li><a href=/app/logs.py title="View logs" class="logs head-submenu">Logs</a></li>
|
||||||
<li><a href=/app/map.py title="View map" class="map head-submenu">Map</a></li>
|
<li><a href=/app/map.py title="View map" class="map head-submenu">Map</a></li>
|
||||||
|
<li><a href=/app/edit.py title="Runtime API" class="runtime head-submenu">Runtime API</a></li>
|
||||||
</li>
|
</li>
|
||||||
<li><a href=/app/edit.py title="Runtime API" class="runtime">Runtime API</a> </li>
|
|
||||||
<li><a title="Actions with Haproxy configs" class="config-show">Haproxy</a>
|
<li><a title="Actions with Haproxy configs" class="config-show">Haproxy</a>
|
||||||
<li><a href=/app/configshow.py title="Show Haproxy Config" class="config-show head-submenu">Show config</a></li>
|
<li><a href=/app/configshow.py title="Show Haproxy Config" class="config-show head-submenu">Show config</a></li>
|
||||||
<li><a href=/app/diff.py title="Compare Haproxy Configs" class="compare head-submenu">Compare configs</a></li>
|
<li><a href=/app/diff.py title="Compare Haproxy Configs" class="compare head-submenu">Compare configs</a></li>
|
||||||
|
@ -100,7 +100,7 @@
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
<div class="copyright-menu">
|
<div class="copyright-menu">
|
||||||
HAproxy-WI v2.5.6
|
HAproxy-WI v2.5.6.1
|
||||||
<br>
|
<br>
|
||||||
<a href="https://www.patreon.com/haproxy_wi" title="Donate" target="_blank" style="color: #fff; margin-left: 40px;">Patreon</a>
|
<a href="https://www.patreon.com/haproxy_wi" title="Donate" target="_blank" style="color: #fff; margin-left: 40px;">Patreon</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -9,10 +9,10 @@
|
||||||
<table class="overview">
|
<table class="overview">
|
||||||
<tr class="overviewHead">
|
<tr class="overviewHead">
|
||||||
<td class="padding10 first-collumn">Login</td>
|
<td class="padding10 first-collumn">Login</td>
|
||||||
<td class="padding10">Email</td>
|
<td class="padding10 second-collumn">Email</td>
|
||||||
<td>Group</td>
|
<td class="padding10 second-collumn">Group</td>
|
||||||
<td class="padding10">Role</td>
|
<td class="padding10">Role</td>
|
||||||
<td style="width: 200px;">
|
<td class="padding10">
|
||||||
<span class="add-button">
|
<span class="add-button">
|
||||||
<a title="Show all users" id="show-all-users" style="color: #fff">
|
<a title="Show all users" id="show-all-users" style="color: #fff">
|
||||||
Show all
|
Show all
|
||||||
|
@ -56,15 +56,15 @@
|
||||||
<td class="padding10 first-collumn">
|
<td class="padding10 first-collumn">
|
||||||
Server
|
Server
|
||||||
</td>
|
</td>
|
||||||
<td class="padding10">
|
<td class="padding10 second-collumn">
|
||||||
HAproxy status
|
HAproxy status
|
||||||
</td>
|
</td>
|
||||||
<td class="padding10">
|
<td class="padding10 second-collumn">
|
||||||
Action
|
Action
|
||||||
</td>
|
</td>
|
||||||
<td class="padding10">
|
<td class="padding10">
|
||||||
Last edit
|
Last edit
|
||||||
</td>
|
</td class="padding10">
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tbody id="ajaxstatus"></tbody>
|
<tbody id="ajaxstatus"></tbody>
|
||||||
|
@ -72,15 +72,20 @@
|
||||||
</table>
|
</table>
|
||||||
<table class="overview" >
|
<table class="overview" >
|
||||||
<tr class="overviewHead">
|
<tr class="overviewHead">
|
||||||
<td class="padding10 first-collumn" style="width: 15%;">
|
<td class="padding10 first-collumn">
|
||||||
Server
|
Server
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td class="padding10 second-collumn">
|
||||||
HAproxy info
|
HAproxy info
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td class="padding10 second-collumn">
|
||||||
Server status
|
Server status
|
||||||
</td>
|
</td>
|
||||||
|
<td class="padding10">
|
||||||
|
Front/Back-ends
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tbody id="ajaxservers"></tbody>
|
<tbody id="ajaxservers"></tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
}
|
}
|
||||||
async function wait() {
|
async function wait() {
|
||||||
$('form').append('<input type="hidden" name="serv" value='+$("#serv").val()+'>');
|
$('form').append('<input type="hidden" name="serv" value='+$("#serv").val()+'>');
|
||||||
|
$('form').append('<input type="hidden" name="token" value='+$('#token').val()+'>');
|
||||||
$( "input[type=submit], button" ).button();
|
$( "input[type=submit], button" ).button();
|
||||||
$('li').css('margin-top', '0');
|
$('li').css('margin-top', '0');
|
||||||
$('table.tbl th.pxname').css('background-color', '#5d9ceb');
|
$('table.tbl th.pxname').css('background-color', '#5d9ceb');
|
||||||
|
|
|
@ -673,7 +673,7 @@ $( function() {
|
||||||
token: $('#token').val()
|
token: $('#token').val()
|
||||||
},
|
},
|
||||||
success: function( data ) {
|
success: function( data ) {
|
||||||
response(data.split('"'));
|
response(data.split('<br>'));
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
},
|
},
|
||||||
|
|
|
@ -30,8 +30,8 @@ iframe {
|
||||||
width: 33%;
|
width: 33%;
|
||||||
}
|
}
|
||||||
pre {
|
pre {
|
||||||
padding-left: 25px;
|
padding-left: 15px;
|
||||||
padding-top: 20px;
|
//padding-top: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon {
|
.icon {
|
||||||
|
@ -312,6 +312,10 @@ pre {
|
||||||
}
|
}
|
||||||
.first-collumn {
|
.first-collumn {
|
||||||
padding-left: 15px;
|
padding-left: 15px;
|
||||||
|
width: 10%;
|
||||||
|
}
|
||||||
|
.second-collumn {
|
||||||
|
width: 30%;
|
||||||
}
|
}
|
||||||
.ro {
|
.ro {
|
||||||
border: none;
|
border: none;
|
||||||
|
|
Loading…
Reference in New Issue