mirror of https://github.com/Aidaho12/haproxy-wi
parent
608910e7ef
commit
48d5a681ef
|
@ -111,20 +111,22 @@ def get_button(button, **kwargs):
|
||||||
def head(title):
|
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="/image/pic/favicon.ico" rel="icon" type="image/png" />'
|
||||||
'<script>'
|
'<script>'
|
||||||
'FontAwesomeConfig = { searchPseudoElements: true, observeMutations: false };'
|
'FontAwesomeConfig = { searchPseudoElements: true, observeMutations: false };'
|
||||||
'</script>'
|
'</script>'
|
||||||
'<script defer src="/inc/fa-solid.min.js"></script>'
|
'<script defer src="/inc/fa-solid.min.js"></script>'
|
||||||
'<script defer src="/inc/fontawesome.min.js"></script>'
|
'<script defer src="/inc/fontawesome.min.js"></script>'
|
||||||
'<meta charset="UTF-8">'
|
'<meta charset="UTF-8">'
|
||||||
'<link href="/inc/style.css" rel="stylesheet">'
|
|
||||||
'<link href="/inc/awesome.css" rel="stylesheet">'
|
'<link href="/inc/awesome.css" rel="stylesheet">'
|
||||||
|
'<link href="/inc/vertical_scrol/custom_scrollbar.css" rel="stylesheet">'
|
||||||
|
'<link href="/inc/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>'
|
||||||
'<script src="/inc/js-cookie.js"></script>'
|
'<script src="/inc/js-cookie.js"></script>'
|
||||||
'<script src="/inc/script.js"></script>'
|
'<script src="/inc/script.js"></script>'
|
||||||
|
'<script src="/inc/vertical_scrol/custom_scrollbar.min.js"></script>'
|
||||||
'</head>'
|
'</head>'
|
||||||
'<body>'
|
'<body>'
|
||||||
'<a name="top"></a>'
|
'<a name="top"></a>'
|
||||||
|
@ -184,7 +186,7 @@ def links():
|
||||||
show_login_links()
|
show_login_links()
|
||||||
print('</ul>'
|
print('</ul>'
|
||||||
'</nav>'
|
'</nav>'
|
||||||
'<div class="copyright-menu">HAproxy-WI v1.10.2</div>')
|
'<div class="copyright-menu">HAproxy-WI v1.10.2.1</div>')
|
||||||
|
|
||||||
def show_login_links():
|
def show_login_links():
|
||||||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||||
|
@ -202,11 +204,7 @@ def footer():
|
||||||
'<a class="ui-button ui-widget ui-corner-all" href="#top" title="Move up">UP</a>'
|
'<a class="ui-button ui-widget ui-corner-all" href="#top" title="Move up">UP</a>'
|
||||||
'</h3><br />'
|
'</h3><br />'
|
||||||
'</center>'
|
'</center>'
|
||||||
'<!--<div class="footer">'
|
'</body></html>')
|
||||||
'<div class="footer-link">'
|
|
||||||
'<span class="LogoText">HAproxy-WI</span>'
|
|
||||||
'</div>'
|
|
||||||
'</div>--></body></html>')
|
|
||||||
def get_auto_refresh(h2):
|
def get_auto_refresh(h2):
|
||||||
print('<h2>')
|
print('<h2>')
|
||||||
print('<span>%s</span>' % h2)
|
print('<span>%s</span>' % h2)
|
||||||
|
|
|
@ -46,11 +46,12 @@ if form.getvalue('grep') is not None:
|
||||||
else:
|
else:
|
||||||
grep = ' '
|
grep = ' '
|
||||||
|
|
||||||
print('</td><td><input type="number" name="rows" %s class="form-control" required></td>' % rows)
|
print('</td><td><input type="number" name="rows" id="rows" %s class="form-control" required></td>' % rows)
|
||||||
print('<td><input type="text" name="grep" class="form-control" %s >' % grep)
|
print('<td><input type="text" name="grep" id="grep" class="form-control" %s >' % grep)
|
||||||
print('</td>'
|
print('</td>'
|
||||||
'<td class="padding10" >'
|
'<td class="padding10" >'
|
||||||
'<button type="submit">Show</button>')
|
'<span id="loading" class="fa fa-spinner fa-spin"></span>'
|
||||||
|
'<a class="ui-button ui-widget ui-corner-all" id="show" title="Show logs" onclick="showLog()">Show</a>')
|
||||||
if form.getvalue('serv') is not None:
|
if form.getvalue('serv') is not None:
|
||||||
print('<span style="float: right; margin-top: 8px;">'
|
print('<span style="float: right; margin-top: 8px;">'
|
||||||
'<a href="" title="Update logs" id="update">'
|
'<a href="" title="Update logs" id="update">'
|
||||||
|
@ -59,27 +60,7 @@ if form.getvalue('serv') is not None:
|
||||||
'</span>')
|
'</span>')
|
||||||
print('</td>'
|
print('</td>'
|
||||||
'</form>'
|
'</form>'
|
||||||
'</tr></table>')
|
'</tr></table>'
|
||||||
|
'<div id="ajax">'
|
||||||
if form.getvalue('serv') is not None:
|
'</div>')
|
||||||
rows = form.getvalue('rows')
|
|
||||||
grep = form.getvalue('grep')
|
|
||||||
|
|
||||||
if grep is not None:
|
|
||||||
grep_act = '|grep'
|
|
||||||
else:
|
|
||||||
grep_act = ''
|
|
||||||
grep = ''
|
|
||||||
|
|
||||||
syslog_server_enable = config.get('logs', 'syslog_server_enable')
|
|
||||||
if syslog_server_enable is None or syslog_server_enable == "0":
|
|
||||||
local_path_logs = config.get('logs', 'local_path_logs')
|
|
||||||
syslog_server = serv
|
|
||||||
commands = [ 'sudo tail -%s %s %s %s' % (rows, local_path_logs, grep_act, grep) ]
|
|
||||||
else:
|
|
||||||
commands = [ 'sudo tail -%s /var/log/%s/syslog.log %s %s' % (rows, serv, grep_act, grep) ]
|
|
||||||
syslog_server = config.get('logs', 'syslog_server')
|
|
||||||
|
|
||||||
funct.ssh_command(syslog_server, commands, show_log="1")
|
|
||||||
|
|
||||||
funct.footer()
|
funct.footer()
|
|
@ -4,8 +4,14 @@ import cgi
|
||||||
import json
|
import json
|
||||||
import subprocess
|
import subprocess
|
||||||
import funct
|
import funct
|
||||||
|
import configparser
|
||||||
|
|
||||||
options = [ "acl", "http-request", "http-response", "set-uri", "set-url", "set-header", "add-header", "del-header", "replace-header", "path_beg", "url_beg()", "urlp_sub()", "tcpka", "tcplog", "forwardfor", "option" ]
|
options = [ "acl", "http-request", "http-response", "set-uri", "set-url", "set-header", "add-header", "del-header", "replace-header", "path_beg", "url_beg()", "urlp_sub()", "tcpka", "tcplog", "forwardfor", "option" ]
|
||||||
|
|
||||||
|
path_config = "haproxy-webintarface.config"
|
||||||
|
config = configparser.ConfigParser()
|
||||||
|
config.read(path_config)
|
||||||
|
|
||||||
form = cgi.FieldStorage()
|
form = cgi.FieldStorage()
|
||||||
req = form.getvalue('req')
|
req = form.getvalue('req')
|
||||||
serv = form.getvalue('serv')
|
serv = form.getvalue('serv')
|
||||||
|
@ -64,6 +70,58 @@ if form.getvalue('action') is not None and serv is not None:
|
||||||
else:
|
else:
|
||||||
print("Bad config, check please")
|
print("Bad config, check please")
|
||||||
|
|
||||||
|
if serv is not None and form.getvalue('rows') is not None:
|
||||||
|
rows = form.getvalue('rows')
|
||||||
|
grep = form.getvalue('grep')
|
||||||
|
|
||||||
|
if grep is not None:
|
||||||
|
grep_act = '|grep'
|
||||||
|
else:
|
||||||
|
grep_act = ''
|
||||||
|
grep = ''
|
||||||
|
|
||||||
|
syslog_server_enable = config.get('logs', 'syslog_server_enable')
|
||||||
|
if syslog_server_enable is None or syslog_server_enable == "0":
|
||||||
|
local_path_logs = config.get('logs', 'local_path_logs')
|
||||||
|
syslog_server = serv
|
||||||
|
commands = [ 'sudo tail -%s %s %s %s' % (rows, local_path_logs, grep_act, grep) ]
|
||||||
|
else:
|
||||||
|
commands = [ 'sudo tail -%s /var/log/%s/syslog.log %s %s' % (rows, serv, grep_act, grep) ]
|
||||||
|
syslog_server = config.get('logs', 'syslog_server')
|
||||||
|
print('<div id"logs">')
|
||||||
|
funct.ssh_command(syslog_server, commands, show_log="1")
|
||||||
|
print('</div>')
|
||||||
|
|
||||||
|
if serv is not None and form.getvalue('act') is not None:
|
||||||
|
import requests
|
||||||
|
from requests_toolbelt.utils import dump
|
||||||
|
|
||||||
|
haproxy_user = config.get('haproxy', 'user')
|
||||||
|
haproxy_pass = config.get('haproxy', 'password')
|
||||||
|
stats_port = config.get('haproxy', 'stats_port')
|
||||||
|
stats_page = config.get('haproxy', 'stats_page')
|
||||||
|
try:
|
||||||
|
response = requests.get('http://%s:%s/%s' % (serv, stats_port, stats_page), auth=(haproxy_user, haproxy_pass))
|
||||||
|
except requests.exceptions.ConnectTimeout:
|
||||||
|
print('Oops. Connection timeout occured!')
|
||||||
|
except requests.exceptions.ReadTimeout:
|
||||||
|
print('Oops. Read timeout occured')
|
||||||
|
except requests.exceptions.HTTPError as errh:
|
||||||
|
print ("Http Error:",errh)
|
||||||
|
except requests.exceptions.ConnectionError as errc:
|
||||||
|
print ("Error Connecting:",errc)
|
||||||
|
except requests.exceptions.Timeout as errt:
|
||||||
|
print ("Timeout Error:",errt)
|
||||||
|
except requests.exceptions.RequestException as err:
|
||||||
|
print ("OOps: Something Else",err)
|
||||||
|
|
||||||
|
data = response.content
|
||||||
|
print(data.decode('utf-8'))
|
||||||
|
|
||||||
|
if form.getvalue('act') == "overview":
|
||||||
|
import ovw
|
||||||
|
ovw.get_overview()
|
||||||
|
|
||||||
if form.getvalue('tailf_stop') is not None:
|
if form.getvalue('tailf_stop') is not None:
|
||||||
serv = form.getvalue('serv')
|
serv = form.getvalue('serv')
|
||||||
commands = [ "ps ax |grep python3 |grep -v grep |awk '{ print $1 }' |xargs kill" ]
|
commands = [ "ps ax |grep python3 |grep -v grep |awk '{ print $1 }' |xargs kill" ]
|
||||||
|
|
|
@ -5,122 +5,17 @@ import funct
|
||||||
import configparser
|
import configparser
|
||||||
import json
|
import json
|
||||||
import listserv as listhap
|
import listserv as listhap
|
||||||
|
import ovw
|
||||||
|
|
||||||
funct.head("Overview")
|
funct.head("Overview")
|
||||||
funct.check_config()
|
funct.check_config()
|
||||||
funct.check_login()
|
funct.check_login()
|
||||||
|
|
||||||
path_config = "haproxy-webintarface.config"
|
|
||||||
config = configparser.ConfigParser()
|
|
||||||
config.read(path_config)
|
|
||||||
haproxy_config_path = config.get('haproxy', 'haproxy_config_path')
|
|
||||||
status_command = config.get('haproxy', 'status_command')
|
|
||||||
USERS = '/var/www/haproxy-wi/cgi-bin/users'
|
|
||||||
|
|
||||||
try:
|
|
||||||
with open(USERS, "r") as user:
|
|
||||||
pass
|
|
||||||
except IOError:
|
|
||||||
print("Can't load users DB")
|
|
||||||
|
|
||||||
funct.get_auto_refresh("Overview")
|
funct.get_auto_refresh("Overview")
|
||||||
|
|
||||||
print('<table class="overview">')
|
print('<div id="ajax">')
|
||||||
|
|
||||||
if funct.is_admin():
|
ovw.get_overview()
|
||||||
print('<tr class="overviewHead">'
|
|
||||||
'<td class="padding10">Login</td>'
|
|
||||||
'<td>Group</td>'
|
|
||||||
'<td class="padding10">'
|
|
||||||
'Role'
|
|
||||||
'</td><td style="width: 200px;">'
|
|
||||||
'<span class="add-button">'
|
|
||||||
'<a href="#" title="Show all users" id="show-all-users" style="color: #fff">'
|
|
||||||
'Show all'
|
|
||||||
'</a>'
|
|
||||||
'</span>'
|
|
||||||
'</td>'
|
|
||||||
'</tr>')
|
|
||||||
|
|
||||||
i = 0
|
print('</div>')
|
||||||
style = ""
|
|
||||||
for f in open(USERS, 'r'):
|
|
||||||
i = i + 1
|
|
||||||
users = json.loads(f)
|
|
||||||
if i is 4:
|
|
||||||
style = 'style="display: none;" class="show-users"'
|
|
||||||
print('<tr ' + style + '><td class="padding10 first-collumn">' + users['login'] +'</td><td class="second-collumn">')
|
|
||||||
print(users['group']+'</td><td>')
|
|
||||||
print(users['role'])
|
|
||||||
print('</td><td></td></tr>')
|
|
||||||
print('</table>')
|
|
||||||
print('<table class="overview">'
|
|
||||||
'<tr class="overviewHead">'
|
|
||||||
'<td class="padding10">Server</td>'
|
|
||||||
'<td class="padding10">'
|
|
||||||
'HAproxy status'
|
|
||||||
'</td>'
|
|
||||||
'<td class="padding10">'
|
|
||||||
'Action'
|
|
||||||
'</td>'
|
|
||||||
'<td>'
|
|
||||||
'Last edit'
|
|
||||||
'</td>'
|
|
||||||
'<td>'
|
|
||||||
'<a href="" title="Update status" id="update">'
|
|
||||||
'<img alt="Update" src="/image/pic/update.png" class="icon" style="padding-right: 8px; float: right">'
|
|
||||||
'</a></span>'
|
|
||||||
'</td>'
|
|
||||||
'</tr>')
|
|
||||||
|
|
||||||
listhap = funct.get_dick_after_permit()
|
|
||||||
|
|
||||||
commands = [ "ps -Af |grep [h]aproxy |wc -l" ]
|
|
||||||
commands1 = [ "ls -l %s |awk '{ print $6\" \"$7\" \"$8}'" % haproxy_config_path ]
|
|
||||||
|
|
||||||
for i in sorted(listhap):
|
|
||||||
print('<tr><td class="padding10 first-collumn"><a href="#%s" title="Go to %s status" style="color: #000">%s</a></td><td class="second-collumn">' % (i, i, i))
|
|
||||||
funct.ssh_command(listhap.get(i), commands, server_status="1")
|
|
||||||
print('</td><td>')
|
|
||||||
if funct.is_admin():
|
|
||||||
print('<a id="%s" title="Start HAproxy service" onclick = "if (! confirm(\'Start service?\')) return false;"><img src=/image/pic/start.png alt="start" class="icon"></a>' % listhap.get(i))
|
|
||||||
print('<a id="%s" title="Stop HAproxy service" onclick = "if (! confirm(\'Stop service?\')) return false;"><img src=/image/pic/stop.png alt="start" class="icon"></a>' % listhap.get(i))
|
|
||||||
print('<a id="%s" title="Restart HAproxy service" onclick = "if (! confirm(\'Restart service?\')) return false;"><img src=/image/pic/update.png alt="restart" class="icon"></a>' % listhap.get(i))
|
|
||||||
print('<a href="/cgi-bin/configshow.py?serv=%s&open=open#conf" title="Show config"><img src=/image/pic/show.png alt="show" class="icon"></a>' % listhap.get(i))
|
|
||||||
print('<a href="/cgi-bin/config.py?serv=%s&open=open#conf" title="Edit config"><img src=/image/pic/edit.png alt="edit" class="icon"></a>' % listhap.get(i))
|
|
||||||
print('<a href="/cgi-bin/diff.py?serv=%s&open=open#diff" title="Compare config"><img src=/image/pic/compare.png alt="compare" class="icon"></a>' % listhap.get(i))
|
|
||||||
print('<a href="/cgi-bin/map.py?serv=%s&open=open#map" title="Map listen/frontend/backend"><img src=/image/pic/map.png alt="map" class="icon"></a>' % listhap.get(i))
|
|
||||||
print('</td><td>')
|
|
||||||
funct.ssh_command(listhap.get(i), commands1)
|
|
||||||
print('</td><td></td></tr>')
|
|
||||||
|
|
||||||
print('</table><table class="overview"><tr class="overviewHead">'
|
|
||||||
'<td class="padding10">Server</td>'
|
|
||||||
'<td class="padding10">'
|
|
||||||
'HAproxy info'
|
|
||||||
'</td>'
|
|
||||||
'<td>'
|
|
||||||
'Server status'
|
|
||||||
'<span style="float: right; margin-left: 80&;">'
|
|
||||||
'<a href="" title="Update status" id="update">'
|
|
||||||
'<img alt="Update" src="/image/pic/update.png" class="icon" style="padding-right: 8px; float: right">'
|
|
||||||
'</a>'
|
|
||||||
'</span>'
|
|
||||||
'</td>'
|
|
||||||
'</tr>')
|
|
||||||
print('</td></tr>')
|
|
||||||
commands = [ "cat " + haproxy_config_path + " |grep -E '^listen|^backend|^frontend' |grep -v stats |wc -l",
|
|
||||||
"uname -smor",
|
|
||||||
"haproxy -v |head -1",
|
|
||||||
status_command + "|grep Active | sed 's/^[ \t]*//'" ]
|
|
||||||
commands1 = [ "top -u haproxy -b -n 1" ]
|
|
||||||
for i in sorted(listhap):
|
|
||||||
print('<tr><td class="overviewTr first-collumn"><a name="'+i+'"></a><h3 title="IP ' + listhap.get(i) + '">' + i + ':</h3></td>')
|
|
||||||
print('<td class="overviewTd"><span>Total listen/frontend/backend:</span><pre>')
|
|
||||||
funct.ssh_command(listhap.get(i), commands)
|
|
||||||
print('</pre></td><td class="overviewTd"><pre>')
|
|
||||||
funct.ssh_command(listhap.get(i), commands1)
|
|
||||||
print('</pre></td></tr>')
|
|
||||||
|
|
||||||
print('<tr></table>')
|
|
||||||
funct.footer()
|
funct.footer()
|
|
@ -0,0 +1,118 @@
|
||||||
|
import funct
|
||||||
|
import configparser
|
||||||
|
import json
|
||||||
|
|
||||||
|
def get_overview():
|
||||||
|
path_config = "haproxy-webintarface.config"
|
||||||
|
config = configparser.ConfigParser()
|
||||||
|
config.read(path_config)
|
||||||
|
haproxy_config_path = config.get('haproxy', 'haproxy_config_path')
|
||||||
|
status_command = config.get('haproxy', 'status_command')
|
||||||
|
cgi_path = config.get('main', 'cgi_path')
|
||||||
|
USERS = cgi_path + '/users'
|
||||||
|
|
||||||
|
try:
|
||||||
|
with open(USERS, "r") as user:
|
||||||
|
pass
|
||||||
|
except IOError:
|
||||||
|
print("Can't load users DB")
|
||||||
|
|
||||||
|
print('<table class="overview">')
|
||||||
|
|
||||||
|
if funct.is_admin():
|
||||||
|
print('<tr class="overviewHead">'
|
||||||
|
'<td class="padding10">Login</td>'
|
||||||
|
'<td>Group</td>'
|
||||||
|
'<td class="padding10">'
|
||||||
|
'Role'
|
||||||
|
'</td><td style="width: 200px;">'
|
||||||
|
'<span class="add-button">'
|
||||||
|
'<a href="#" title="Show all users" id="show-all-users" style="color: #fff">'
|
||||||
|
'Show all'
|
||||||
|
'</a>'
|
||||||
|
'</span>'
|
||||||
|
'</td>'
|
||||||
|
'</tr>')
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
style = ""
|
||||||
|
for f in open(USERS, 'r'):
|
||||||
|
i = i + 1
|
||||||
|
users = json.loads(f)
|
||||||
|
if i is 4:
|
||||||
|
style = 'style="display: none;" class="show-users"'
|
||||||
|
print('<tr ' + style + '><td class="padding10 first-collumn">' + users['login'] +'</td><td class="second-collumn">')
|
||||||
|
print(users['group']+'</td><td>')
|
||||||
|
print(users['role'])
|
||||||
|
print('</td><td></td></tr>')
|
||||||
|
print('</table>')
|
||||||
|
|
||||||
|
print('<table class="overview">'
|
||||||
|
'<tr class="overviewHead">'
|
||||||
|
'<td class="padding10">Server</td>'
|
||||||
|
'<td class="padding10">'
|
||||||
|
'HAproxy status'
|
||||||
|
'</td>'
|
||||||
|
'<td class="padding10">'
|
||||||
|
'Action'
|
||||||
|
'</td>'
|
||||||
|
'<td>'
|
||||||
|
'Last edit'
|
||||||
|
'</td>'
|
||||||
|
'<td>'
|
||||||
|
'<a href="" title="Update status" id="update">'
|
||||||
|
'<img alt="Update" src="/image/pic/update.png" class="icon" style="padding-right: 8px; float: right">'
|
||||||
|
'</a></span>'
|
||||||
|
'</td>'
|
||||||
|
'</tr>')
|
||||||
|
|
||||||
|
listhap = funct.get_dick_after_permit()
|
||||||
|
|
||||||
|
commands = [ "ps -Af |grep [h]aproxy |wc -l" ]
|
||||||
|
commands1 = [ "ls -l %s |awk '{ print $6\" \"$7\" \"$8}'" % haproxy_config_path ]
|
||||||
|
|
||||||
|
for i in sorted(listhap):
|
||||||
|
print('<tr><td class="padding10 first-collumn"><a href="#%s" title="Go to %s status" style="color: #000">%s</a></td><td class="second-collumn">' % (i, i, i))
|
||||||
|
funct.ssh_command(listhap.get(i), commands, server_status="1")
|
||||||
|
print('</td><td>')
|
||||||
|
if funct.is_admin():
|
||||||
|
print('<a id="%s" title="Start HAproxy service" onclick = "if (! confirm(\'Start service?\')) return false;"><img src=/image/pic/start.png alt="start" class="icon"></a>' % listhap.get(i))
|
||||||
|
print('<a id="%s" title="Stop HAproxy service" onclick = "if (! confirm(\'Stop service?\')) return false;"><img src=/image/pic/stop.png alt="start" class="icon"></a>' % listhap.get(i))
|
||||||
|
print('<a id="%s" title="Restart HAproxy service" onclick = "if (! confirm(\'Restart service?\')) return false;"><img src=/image/pic/update.png alt="restart" class="icon"></a>' % listhap.get(i))
|
||||||
|
print('<a href="/cgi-bin/configshow.py?serv=%s&open=open#conf" title="Show config"><img src=/image/pic/show.png alt="show" class="icon"></a>' % listhap.get(i))
|
||||||
|
print('<a href="/cgi-bin/config.py?serv=%s&open=open#conf" title="Edit config"><img src=/image/pic/edit.png alt="edit" class="icon"></a>' % listhap.get(i))
|
||||||
|
print('<a href="/cgi-bin/diff.py?serv=%s&open=open#diff" title="Compare config"><img src=/image/pic/compare.png alt="compare" class="icon"></a>' % listhap.get(i))
|
||||||
|
print('<a href="/cgi-bin/map.py?serv=%s&open=open#map" title="Map listen/frontend/backend"><img src=/image/pic/map.png alt="map" class="icon"></a>' % listhap.get(i))
|
||||||
|
print('</td><td>')
|
||||||
|
funct.ssh_command(listhap.get(i), commands1)
|
||||||
|
print('</td><td></td></tr>')
|
||||||
|
|
||||||
|
print('</table><table class="overview"><tr class="overviewHead">'
|
||||||
|
'<td class="padding10">Server</td>'
|
||||||
|
'<td class="padding10">'
|
||||||
|
'HAproxy info'
|
||||||
|
'</td>'
|
||||||
|
'<td>'
|
||||||
|
'Server status'
|
||||||
|
'<span style="float: right; margin-left: 80&;">'
|
||||||
|
'<a href="" title="Update status" id="update">'
|
||||||
|
'<img alt="Update" src="/image/pic/update.png" class="icon" style="padding-right: 8px; float: right">'
|
||||||
|
'</a>'
|
||||||
|
'</span>'
|
||||||
|
'</td>'
|
||||||
|
'</tr>')
|
||||||
|
print('</td></tr>')
|
||||||
|
commands = [ "cat " + haproxy_config_path + " |grep -E '^listen|^backend|^frontend' |grep -v stats |wc -l",
|
||||||
|
"uname -smor",
|
||||||
|
"haproxy -v |head -1",
|
||||||
|
status_command + "|grep Active | sed 's/^[ \t]*//'" ]
|
||||||
|
commands1 = [ "top -u haproxy -b -n 1" ]
|
||||||
|
for i in sorted(listhap):
|
||||||
|
print('<tr><td class="overviewTr first-collumn"><a name="'+i+'"></a><h3 title="IP ' + listhap.get(i) + '">' + i + ':</h3></td>')
|
||||||
|
print('<td class="overviewTd"><span>Total listen/frontend/backend:</span><pre>')
|
||||||
|
funct.ssh_command(listhap.get(i), commands)
|
||||||
|
print('</pre></td><td class="overviewTd"><pre>')
|
||||||
|
funct.ssh_command(listhap.get(i), commands1)
|
||||||
|
print('</pre></td></tr>')
|
||||||
|
|
||||||
|
print('<tr></table>')
|
|
@ -42,8 +42,6 @@ except requests.exceptions.Timeout as errt:
|
||||||
except requests.exceptions.RequestException as err:
|
except requests.exceptions.RequestException as err:
|
||||||
print ("OOps: Something Else",err)
|
print ("OOps: Something Else",err)
|
||||||
|
|
||||||
#print('<meta http-equiv="refresh" content="%s; url=viewsttats.py?serv=%s">' % (config.get('haproxy', 'refresh_time') ,serv))
|
|
||||||
|
|
||||||
for i in listhap.listhap:
|
for i in listhap.listhap:
|
||||||
if listhap.listhap.get(i) == serv:
|
if listhap.listhap.get(i) == serv:
|
||||||
servname = i
|
servname = i
|
||||||
|
@ -54,16 +52,21 @@ funct.get_auto_refresh("HAproxy statistics")
|
||||||
|
|
||||||
print('<br />'
|
print('<br />'
|
||||||
'<form style="padding-left: 20px;" action="viewsttats.py" method="get">'
|
'<form style="padding-left: 20px;" action="viewsttats.py" method="get">'
|
||||||
'<select autofocus required name="serv">'
|
'<select autofocus required name="serv" id="serv">'
|
||||||
'<option disabled>Choose server</option>')
|
'<option disabled>Choose server</option>')
|
||||||
|
|
||||||
funct.choose_server_with_vip(serv)
|
funct.choose_server_with_vip(serv)
|
||||||
|
|
||||||
print('</select><input type="submit" value="Show stats"></form>')
|
print('</select>'
|
||||||
|
'<span id="loading" class="fa fa-spinner fa-spin"></span>'
|
||||||
|
'<a class="ui-button ui-widget ui-corner-all" id="show" title="Show logs" onclick="showStats()">Show</a>'
|
||||||
|
'</form>')
|
||||||
|
|
||||||
data = response.content
|
data = response.content
|
||||||
print('<a name="conf"></a><div style="margin-left: 10px;">')
|
print('<a name="conf"></a><div id="ajax" style="margin-left: 10px;">')
|
||||||
print(data.decode('utf-8'))
|
print(data.decode('utf-8'))
|
||||||
|
print('</div>')
|
||||||
|
|
||||||
funct.head("Stats HAproxy configs")
|
funct.head("Stats HAproxy configs")
|
||||||
print('</div>')
|
print('</div>')
|
||||||
|
|
||||||
|
|
Before Width: | Height: | Size: 932 B After Width: | Height: | Size: 932 B |
147
inc/script.js
147
inc/script.js
|
@ -1,3 +1,29 @@
|
||||||
|
function autoRefreshStyle(autoRefresh) {
|
||||||
|
var margin;
|
||||||
|
autoRefresh = autoRefresh / 1000;
|
||||||
|
if ( autoRefresh == 60) {
|
||||||
|
timeRange = " minute"
|
||||||
|
autoRefresh = autoRefresh / 60;
|
||||||
|
margin = '-80px';
|
||||||
|
} else if ( autoRefresh > 60 && autoRefresh < 3600 ) {
|
||||||
|
timeRange = " minutes"
|
||||||
|
autoRefresh = autoRefresh / 60;
|
||||||
|
margin = '-93px';
|
||||||
|
} else if ( autoRefresh >= 3600 && autoRefresh < 86401 ) {
|
||||||
|
timeRange = " hours"
|
||||||
|
autoRefresh = autoRefresh / 3600;
|
||||||
|
margin = '-80px';
|
||||||
|
} else {
|
||||||
|
timeRange = " seconds";
|
||||||
|
margin = '-100px';
|
||||||
|
}
|
||||||
|
$('#1').text(autoRefresh + timeRange);
|
||||||
|
$('#0').text(autoRefresh + timeRange);
|
||||||
|
$('.auto-refresh-pause').css('display', 'inline');
|
||||||
|
$('.auto-refresh-pause').css('margin-left', margin);
|
||||||
|
$('.auto-refresh img').remove();
|
||||||
|
}
|
||||||
|
|
||||||
function setRefreshInterval(interval) {
|
function setRefreshInterval(interval) {
|
||||||
if (interval == "0") {
|
if (interval == "0") {
|
||||||
Cookies.remove('auto-refresh');
|
Cookies.remove('auto-refresh');
|
||||||
|
@ -9,15 +35,27 @@ function setRefreshInterval(interval) {
|
||||||
$('.auto-refresh-resume').css('display', 'none');
|
$('.auto-refresh-resume').css('display', 'none');
|
||||||
hideAutoRefreshDiv();
|
hideAutoRefreshDiv();
|
||||||
} else {
|
} else {
|
||||||
|
clearInterval(intervalId);
|
||||||
Cookies.set('auto-refresh', interval, { expires: 365 });
|
Cookies.set('auto-refresh', interval, { expires: 365 });
|
||||||
startSetInterval(interval);
|
startSetInterval(interval);
|
||||||
hideAutoRefreshDiv();
|
hideAutoRefreshDiv();
|
||||||
document.location.reload();
|
autoRefreshStyle(interval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var cur_url = window.location.href.split('/').pop();
|
||||||
|
cur_url = cur_url.split('?');
|
||||||
var intervalId;
|
var intervalId;
|
||||||
function startSetInterval(interval) {
|
function startSetInterval(interval) {
|
||||||
intervalId = setInterval('document.location.reload()', interval);
|
if (cur_url[0] == "logs.py") {
|
||||||
|
intervalId = setInterval('showLog()', interval);
|
||||||
|
} else if (cur_url[0] == "viewsttats.py") {
|
||||||
|
intervalId = setInterval('showStats()', interval);
|
||||||
|
} else if (cur_url[0] == "overview.py") {
|
||||||
|
intervalId = setInterval('showOverview()', interval);
|
||||||
|
} else {
|
||||||
|
intervalId = setInterval('document.location.reload()', interval);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
function pauseAutoRefresh() {
|
function pauseAutoRefresh() {
|
||||||
clearInterval(intervalId);
|
clearInterval(intervalId);
|
||||||
|
@ -39,7 +77,80 @@ function hideAutoRefreshDiv() {
|
||||||
$('#0').css("display", "inline");
|
$('#0').css("display", "inline");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
function showOverview() {
|
||||||
|
$.ajax( {
|
||||||
|
url: "options.py",
|
||||||
|
data: {
|
||||||
|
act: "overview",
|
||||||
|
},
|
||||||
|
type: "GET",
|
||||||
|
success: function( data ) {
|
||||||
|
var form = $("#ajax").html();
|
||||||
|
$("#ajax").html(data);
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
function showStats() {
|
||||||
|
$.ajax( {
|
||||||
|
url: "options.py",
|
||||||
|
data: {
|
||||||
|
act: "stats",
|
||||||
|
serv: $("#serv").val()
|
||||||
|
},
|
||||||
|
type: "GET",
|
||||||
|
beforeSend: function () {
|
||||||
|
$('#loading').show();
|
||||||
|
},
|
||||||
|
complete: function () {
|
||||||
|
$("#loading").hide();
|
||||||
|
},
|
||||||
|
success: function( data ) {
|
||||||
|
var form = $("#ajax").html();
|
||||||
|
$("#ajax").html(data);
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
function showLog() {
|
||||||
|
$.ajax( {
|
||||||
|
url: "options.py",
|
||||||
|
data: {
|
||||||
|
rows: $('#rows').val(),
|
||||||
|
serv: $("#serv").val(),
|
||||||
|
grep: $("#grep").val(),
|
||||||
|
},
|
||||||
|
type: "GET",
|
||||||
|
beforeSend: function () {
|
||||||
|
$('#loading').show();
|
||||||
|
},
|
||||||
|
complete: function () {
|
||||||
|
$("#loading").hide();
|
||||||
|
},
|
||||||
|
success: function( data ) {
|
||||||
|
var form = $("#ajax").html();
|
||||||
|
$("#ajax").html(data);
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
$( function() {
|
$( function() {
|
||||||
|
var pause = '<a onclick="pauseAutoRefresh()" title="Pause auto-refresh" class="auto-refresh-pause"></a>'
|
||||||
|
var autoRefresh = Cookies.get('auto-refresh');
|
||||||
|
|
||||||
|
if ($('.auto-refresh')) {
|
||||||
|
if(autoRefresh) {
|
||||||
|
startSetInterval(autoRefresh);
|
||||||
|
autoRefreshStyle(autoRefresh);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$("body").mCustomScrollbar({
|
||||||
|
theme:"minimal-dark",
|
||||||
|
scrollInertia:30
|
||||||
|
});
|
||||||
|
$(".diff").mCustomScrollbar({
|
||||||
|
theme:"minimal-dark",
|
||||||
|
scrollInertia:30
|
||||||
|
});
|
||||||
$( "#tabs" ).tabs();
|
$( "#tabs" ).tabs();
|
||||||
$( "#redirectBackend" ).on( "click", function() {
|
$( "#redirectBackend" ).on( "click", function() {
|
||||||
$( "#tabs" ).tabs( "option", "active", 2 );
|
$( "#tabs" ).tabs( "option", "active", 2 );
|
||||||
|
@ -150,38 +261,6 @@ $( function() {
|
||||||
$('#0').css("display", "inline");
|
$('#0').css("display", "inline");
|
||||||
});
|
});
|
||||||
|
|
||||||
var autoRefresh = Cookies.get('auto-refresh');
|
|
||||||
var pause = '<a onclick="pauseAutoRefresh()" title="Pause auto-refresh" class="auto-refresh-pause"></a>'
|
|
||||||
|
|
||||||
if ($('.auto-refresh')) {
|
|
||||||
var margin;
|
|
||||||
if(autoRefresh) {
|
|
||||||
startSetInterval(autoRefresh)
|
|
||||||
autoRefresh = autoRefresh / 1000;
|
|
||||||
|
|
||||||
if ( autoRefresh == 60) {
|
|
||||||
timeRange = " minute"
|
|
||||||
autoRefresh = autoRefresh / 60;
|
|
||||||
margin = '-80px';
|
|
||||||
} else if ( autoRefresh > 60 && autoRefresh < 3600 ) {
|
|
||||||
timeRange = " minutes"
|
|
||||||
autoRefresh = autoRefresh / 60;
|
|
||||||
margin = '-93px';
|
|
||||||
} else if ( autoRefresh >= 3600 && autoRefresh < 86401 ) {
|
|
||||||
timeRange = " hours"
|
|
||||||
autoRefresh = autoRefresh / 3600;
|
|
||||||
margin = '-80px';
|
|
||||||
} else {
|
|
||||||
timeRange = " seconds";
|
|
||||||
margin = '-100px';
|
|
||||||
}
|
|
||||||
$('#1').text(autoRefresh + timeRange);
|
|
||||||
$('#0').text(autoRefresh + timeRange);
|
|
||||||
$('.auto-refresh-pause').css('display', 'inline');
|
|
||||||
$('.auto-refresh-pause').css('margin-left', margin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$('#select_all').click(function(){
|
$('#select_all').click(function(){
|
||||||
var checkboxes = $(this).closest('form').find(':checkbox');
|
var checkboxes = $(this).closest('form').find(':checkbox');
|
||||||
if($(this).prop('checked')) {
|
if($(this).prop('checked')) {
|
||||||
|
|
|
@ -13,8 +13,8 @@ body {
|
||||||
h2 {
|
h2 {
|
||||||
background: #5D9CEB;
|
background: #5D9CEB;
|
||||||
border: 1px solid #5D9CEB;
|
border: 1px solid #5D9CEB;
|
||||||
padding: 10px;
|
padding: 5px;
|
||||||
padding-left: 3%;
|
padding-left: 2%;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
margin-top: 0px;
|
margin-top: 0px;
|
||||||
margin-bottom: 0px;
|
margin-bottom: 0px;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue