mirror of https://github.com/Aidaho12/haproxy-wi
parent
89b0ec5fbe
commit
045f263767
|
@ -37,7 +37,7 @@ For install just clone:
|
|||
$ cd /var/www/
|
||||
$ git clone https://github.com/Aidaho12/haproxy-wi.git /var/www/haproxy-wi
|
||||
$ chown -R apache:apache haproxy-wi/
|
||||
$ pip install -r haproxy-wi/requirements.txt
|
||||
$ pip3 install -r haproxy-wi/requirements.txt
|
||||
$ chmod +x haproxy-wi/app/*.py
|
||||
```
|
||||
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
#!/usr/bin/env python3
|
||||
import os
|
||||
import sql
|
||||
import http
|
||||
import http.cookies, cgi
|
||||
import funct
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
env = Environment(loader=FileSystemLoader('templates/'))
|
||||
template = env.get_template('config.html')
|
||||
print('Content-type: text/html\n')
|
||||
funct.check_login()
|
||||
form = cgi.FieldStorage()
|
||||
serv = form.getvalue('serv')
|
||||
|
||||
try:
|
||||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||
|
@ -22,6 +24,7 @@ output_from_parsed_template = template.render(h2 = 1, title = "Show Runnig confi
|
|||
user = user,
|
||||
onclick = "showConfig()",
|
||||
select_id = "serv",
|
||||
serv = serv,
|
||||
selects = servers,
|
||||
note = 0)
|
||||
print(output_from_parsed_template)
|
|
@ -114,6 +114,9 @@ if form.getvalue('action') is not None and serv is not None:
|
|||
if act == "overview":
|
||||
ovw.get_overview()
|
||||
|
||||
if act == "overviewServers":
|
||||
ovw.get_overviewServers()
|
||||
|
||||
if serv is not None and act == "stats":
|
||||
import requests
|
||||
from requests_toolbelt.utils import dump
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
import funct, sql
|
||||
import create_db
|
||||
import os, http
|
||||
import os, http.cookies
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
env = Environment(loader=FileSystemLoader('templates/'))
|
||||
template = env.get_template('ovw.html')
|
||||
|
@ -14,7 +14,8 @@ try:
|
|||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||
user_id = cookie.get('uuid')
|
||||
user = sql.get_user_name_by_uuid(user_id.value)
|
||||
|
||||
users = sql.select_users()
|
||||
groups = sql.select_groups()
|
||||
except:
|
||||
pass
|
||||
|
||||
|
@ -22,5 +23,7 @@ output_from_parsed_template = template.render(h2 = 1,
|
|||
autorefresh = 1,
|
||||
title = "Overview",
|
||||
role = sql.get_user_role_by_uuid(user_id.value),
|
||||
user = user)
|
||||
user = user,
|
||||
users = users,
|
||||
groups = groups)
|
||||
print(output_from_parsed_template)
|
61
app/ovw.py
61
app/ovw.py
|
@ -18,53 +18,7 @@ hap_configs_dir = config.get('configs', 'haproxy_save_configs_dir')
|
|||
form = cgi.FieldStorage()
|
||||
|
||||
def get_overview():
|
||||
USERS = sql.select_users()
|
||||
listhap = sql.get_dick_permit()
|
||||
|
||||
if funct.is_admin():
|
||||
print('<table class="overview">'
|
||||
'<tr class="overviewHead">'
|
||||
'<td class="padding10 first-collumn">Login</td>'
|
||||
'<td class="padding10">Email</td>'
|
||||
'<td class="padding10">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 users in USERS:
|
||||
i = i + 1
|
||||
if i is 4:
|
||||
style = 'style="display: none;" class="show-users"'
|
||||
print('<tr ' + style + '><td class="padding10 first-collumn">' + users[1] +'</td><td class="second-collumn">')
|
||||
print(users[2]+'</td><td>')
|
||||
print(sql.select_user_name_group(users[5]))
|
||||
print('</td><td>')
|
||||
print(users[4])
|
||||
print('</td><td></td></tr>')
|
||||
print('</table>')
|
||||
|
||||
print('<table class="overview">'
|
||||
'<tr class="overviewHead">'
|
||||
'<td class="padding10 first-collumn"">Server</td>'
|
||||
'<td class="padding10">'
|
||||
'HAproxy status'
|
||||
'</td>'
|
||||
'<td class="padding10">'
|
||||
'Action'
|
||||
'</td>'
|
||||
'<td class="padding10">'
|
||||
'Last edit'
|
||||
'</td>'
|
||||
'<td></td>'
|
||||
'</tr>')
|
||||
|
||||
commands = [ "ps -Af |grep [h]aproxy |wc -l" ]
|
||||
commands1 = [ "ls -l %s |awk '{ print $6\" \"$7\" \"$8}'" % haproxy_config_path ]
|
||||
|
@ -86,17 +40,8 @@ def get_overview():
|
|||
funct.ssh_command(server[2], commands1)
|
||||
print('</td><td></td></tr>')
|
||||
|
||||
print('</table><table class="overview">'
|
||||
'<tr class="overviewHead">'
|
||||
'<td class="padding10 first-collumn" style="width: 15%;">Server</td>'
|
||||
'<td>'
|
||||
'HAproxy info'
|
||||
'</td>'
|
||||
'<td>'
|
||||
'Server status'
|
||||
'</td>'
|
||||
'</tr>')
|
||||
|
||||
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",
|
||||
"haproxy -v |head -1",
|
||||
|
@ -109,8 +54,6 @@ def get_overview():
|
|||
print('</pre></td><td class="overviewTd"><pre>')
|
||||
funct.ssh_command(server[2], commands1)
|
||||
print('</pre></td></tr>')
|
||||
|
||||
print('<tr></table>')
|
||||
|
||||
def get_map(serv):
|
||||
from datetime import datetime
|
||||
|
|
|
@ -98,7 +98,7 @@
|
|||
{% endif %}
|
||||
</ul>
|
||||
</nav>
|
||||
<div class="copyright-menu">HAproxy-WI v2.5.4</div>
|
||||
<div class="copyright-menu">HAproxy-WI v2.5.4.1</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
{% if role <= 1 %}
|
||||
<table class="overview">
|
||||
<tr class="overviewHead">
|
||||
<td class="padding10">Login</td>
|
||||
|
@ -14,16 +15,29 @@
|
|||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
{% set counter = 0 -%}
|
||||
{% for user in users %}
|
||||
<tr>
|
||||
<td class="padding10 first-collumn"> {{ user.1 }}</td>
|
||||
<td class="padding10"> {{ user.2 }}</td>
|
||||
<td class="second-collumn">{{ user.5 }}</td>
|
||||
<td>{{ user.4 }}</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
{% set counter = counter + 1 %}
|
||||
{% if counter < 4 %}
|
||||
<tr>
|
||||
<td class="padding10 first-collumn"> {{ user.1 }}</td>
|
||||
<td class="padding10"> {{ user.2 }}</td>
|
||||
<td class="second-collumn">{{ user.5 }}</td>
|
||||
<td>{{ user.4 }}</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr style="display: none;" class="show-users">
|
||||
<td class="padding10 first-collumn"> {{ user.1 }}</td>
|
||||
<td class="padding10"> {{ user.2 }}</td>
|
||||
<td class="second-collumn">{{ user.5 }}</td>
|
||||
<td>{{ user.4 }}</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% endif %}
|
||||
<table class="overview">
|
||||
<tr class="overviewHead">
|
||||
<td class="padding10">Server</td>
|
||||
|
|
|
@ -1,10 +1,91 @@
|
|||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
<script>
|
||||
if (cur_url[0] == 'overview.py') {
|
||||
$('#secIntervals').css('display', 'none');
|
||||
if (cur_url[0] == overview.py) {
|
||||
$(#secIntervals).css(display, none);
|
||||
}
|
||||
</script>
|
||||
{% if role <= 1 %}
|
||||
<table class="overview">
|
||||
<tr class="overviewHead">
|
||||
<td class="padding10 first-collumn">Login</td>
|
||||
<td class="padding10">Email</td>
|
||||
<td>Group</td>
|
||||
<td class="padding10">Role</td>
|
||||
<td style="width: 200px;">
|
||||
<span class="add-button">
|
||||
<a title="Show all users" id="show-all-users" style="color: #fff">
|
||||
Show all
|
||||
</a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
{% set counter = 0 -%}
|
||||
{% for USER in users %}
|
||||
{% set counter = counter + loop.index0 %}
|
||||
{% if counter <= 2 %}
|
||||
<tr>
|
||||
<td class="padding10 first-collumn"> {{ USER.1 }}</td>
|
||||
<td class="padding10"> {{ USER.2 }}</td>
|
||||
{% for group in groups %}
|
||||
{% if USER.5 == group.0|string() %}
|
||||
<td class="second-collumn">{{ group.1 }}</td>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<td>{{ USER.4 }}</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr style="display: none;" class="show-users">
|
||||
<td class="padding10 first-collumn"> {{ USER.1 }}</td>
|
||||
<td class="padding10"> {{ USER.2 }}</td>
|
||||
{% for group in groups %}
|
||||
{% if group.0|string() == USER.5 %}
|
||||
<td class="second-collumn">{{ group.1 }}</td>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<td>{{ USER.4 }}</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% endif %}
|
||||
<table class="overview">
|
||||
<tr class="overviewHead">
|
||||
<td class="padding10 first-collumn">
|
||||
Server
|
||||
</td>
|
||||
<td class="padding10">
|
||||
HAproxy status
|
||||
</td>
|
||||
<td class="padding10">
|
||||
Action
|
||||
</td>
|
||||
<td class="padding10">
|
||||
Last edit
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tbody id="ajaxstatus"></tbody>
|
||||
|
||||
</table>
|
||||
<table class="overview" >
|
||||
<tr class="overviewHead">
|
||||
<td class="padding10 first-collumn" style="width: 15%;">
|
||||
Server
|
||||
</td>
|
||||
<td>
|
||||
HAproxy info
|
||||
</td>
|
||||
<td>
|
||||
Server status
|
||||
</td>
|
||||
</tr>
|
||||
<tbody id="ajaxservers"></tbody>
|
||||
</table>
|
||||
<script>
|
||||
window.onload = showOverview()
|
||||
</script>
|
||||
<div id="ajax"></div>
|
||||
|
||||
{% endblock %}
|
|
@ -97,7 +97,8 @@ $( document ).ajaxSend(function( event, request, settings ) {
|
|||
$( document ).ajaxComplete(function( event, request, settings ) {
|
||||
NProgress.done();
|
||||
});
|
||||
function showOverview() {
|
||||
function showOverview() {
|
||||
showOverviewServers();
|
||||
$.ajax( {
|
||||
url: "options.py",
|
||||
data: {
|
||||
|
@ -105,7 +106,21 @@ function showOverview() {
|
|||
},
|
||||
type: "GET",
|
||||
success: function( data ) {
|
||||
$("#ajax").html(data);
|
||||
$("#ajaxstatus").empty();
|
||||
$("#ajaxstatus").html(data);
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
function showOverviewServers() {
|
||||
$.ajax( {
|
||||
url: "options.py",
|
||||
data: {
|
||||
act: "overviewServers",
|
||||
},
|
||||
type: "GET",
|
||||
success: function( data ) {
|
||||
$("#ajaxservers").html(data);
|
||||
$.getScript('/inc/overview.js');
|
||||
}
|
||||
} );
|
||||
|
@ -501,7 +516,7 @@ $( function() {
|
|||
}
|
||||
|
||||
var availableTags = [
|
||||
"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"
|
||||
"acl", "http-request", "http-response", "set-uri", "set-url", "set-header", "add-header", "del-header", "replace-header", "path_beg", "url_beg()", "urlp_sub()", "set cookie", "dynamic-cookie-key", "mysql-check", "tcpka", "tcplog", "forwardfor", "option"
|
||||
];
|
||||
|
||||
$( "#ip" ).autocomplete({
|
||||
|
|
Loading…
Reference in New Issue