Add fornentd/backend to Overview page
Bug fixed
pull/19/head
Aidaho12 2018-06-06 21:29:30 +06:00
parent 228bc5418a
commit c559c1cc9c
8 changed files with 62 additions and 51 deletions

View File

@ -456,4 +456,25 @@ def ssh_command(serv, commands, **kwargs):
pass
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>")

View File

@ -3,8 +3,6 @@
import html
import cgi
import os, sys
import json
import subprocess
import funct
import sql
import ovw
@ -14,7 +12,7 @@ req = form.getvalue('req')
serv = form.getvalue('serv')
act = form.getvalue('act')
backend = form.getvalue('backend')
print('Content-type: text/html\n')
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)
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:
commands = [ "sudo ip a |grep inet |egrep -v '::1' |awk '{ print $2 }' |awk -F'/' '{ print $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):
commands = [ "sudo systemctl %s haproxy" % action ]
funct.ssh_command(serv, commands)
print("HAproxy was %s" % action)
else:
print("Bad config, check please")
@ -209,9 +192,7 @@ if serv is not None and form.getvalue('rows1') is not None:
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)
stdout, stderr = p.communicate()
output = stdout.splitlines()
output, stderr = funct.subprocess_execute(cmd)
funct.show_log(output)
print(stderr)
@ -235,9 +216,7 @@ if form.getvalue('viewlogs') is not None:
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)
stdout, stderr = p.communicate()
output = stdout.splitlines()
output, stderr = funct.subprocess_execute(cmd)
funct.show_log(output)
print(stderr)

View File

@ -36,18 +36,19 @@ def get_overview():
def get_overviewServers():
listhap = sql.get_dick_permit()
commands = [ "cat " + haproxy_config_path + " |grep -E '^listen|^backend|^frontend' |grep -v stats |wc -l",
"uname -smor",
commands = [ "uname -smor",
"haproxy -v |head -1",
status_command + "|grep Active | sed 's/^[ \t]*//'" ]
commands1 = [ "top -u haproxy -b -n 1" ]
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('<td class="overviewTd"><span>Total listen/frontend/backend:</span><pre>')
print('<td class="overviewTd"><pre>')
funct.ssh_command(server[2], commands)
print('</pre></td><td><pre>')
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):
from datetime import datetime
@ -164,7 +165,7 @@ def show_compare_configs(serv):
os.chdir(hap_configs_dir)
for files in sorted(glob.glob('*.cfg')):
for files in sorted(glob.glob('*.cfg'), reverse=True):
ip = files.split("-")
if serv == ip[0]:
if left == files:
@ -178,7 +179,7 @@ def show_compare_configs(serv):
print('<select autofocus required name="right" id="right">')
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("-")
if serv == ip[0]:
if right == files:

View File

@ -44,12 +44,12 @@
<nav class="menu">
<ul id="menu">
<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/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/map.py title="View map" class="map head-submenu">Map</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/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/edit.py title="Runtime API" class="runtime head-submenu">Runtime API</a></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 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>
@ -100,7 +100,7 @@
</ul>
</nav>
<div class="copyright-menu">
HAproxy-WI v2.5.6
HAproxy-WI v2.5.6.1
<br>
<a href="https://www.patreon.com/haproxy_wi" title="Donate" target="_blank" style="color: #fff; margin-left: 40px;">Patreon</a>
</div>

View File

@ -9,10 +9,10 @@
<table class="overview">
<tr class="overviewHead">
<td class="padding10 first-collumn">Login</td>
<td class="padding10">Email</td>
<td>Group</td>
<td class="padding10 second-collumn">Email</td>
<td class="padding10 second-collumn">Group</td>
<td class="padding10">Role</td>
<td style="width: 200px;">
<td class="padding10">
<span class="add-button">
<a title="Show all users" id="show-all-users" style="color: #fff">
Show all
@ -56,15 +56,15 @@
<td class="padding10 first-collumn">
Server
</td>
<td class="padding10">
<td class="padding10 second-collumn">
HAproxy status
</td>
<td class="padding10">
<td class="padding10 second-collumn">
Action
</td>
<td class="padding10">
Last edit
</td>
</td class="padding10">
<td></td>
</tr>
<tbody id="ajaxstatus"></tbody>
@ -72,15 +72,20 @@
</table>
<table class="overview" >
<tr class="overviewHead">
<td class="padding10 first-collumn" style="width: 15%;">
<td class="padding10 first-collumn">
Server
</td>
<td>
<td class="padding10 second-collumn">
HAproxy info
</td>
<td>
<td class="padding10 second-collumn">
Server status
</td>
<td class="padding10">
Front/Back-ends
</td>
<td>
</td>
</tr>
<tbody id="ajaxservers"></tbody>
</table>

View File

@ -22,6 +22,7 @@
}
async function wait() {
$('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();
$('li').css('margin-top', '0');
$('table.tbl th.pxname').css('background-color', '#5d9ceb');

View File

@ -673,7 +673,7 @@ $( function() {
token: $('#token').val()
},
success: function( data ) {
response(data.split('"'));
response(data.split('<br>'));
}
} );
},

View File

@ -30,8 +30,8 @@ iframe {
width: 33%;
}
pre {
padding-left: 25px;
padding-top: 20px;
padding-left: 15px;
//padding-top: 20px;
}
.icon {
@ -312,6 +312,10 @@ pre {
}
.first-collumn {
padding-left: 15px;
width: 10%;
}
.second-collumn {
width: 30%;
}
.ro {
border: none;