mirror of https://github.com/Aidaho12/haproxy-wi
parent
19c22875eb
commit
d19eb8a3a3
|
@ -73,9 +73,9 @@ def create_table(**kwargs):
|
||||||
`groups` VARCHAR ( 120 ),
|
`groups` VARCHAR ( 120 ),
|
||||||
PRIMARY KEY(`id`)
|
PRIMARY KEY(`id`)
|
||||||
);
|
);
|
||||||
INSERT INTO user (username, email, password, role, groups) VALUES ('admin','admin@localhost','admin','admin','1'),
|
INSERT INTO user (username, email, password, role, groups) VALUES ('admin','admin@localhost','21232f297a57a5a743894a0e4a801fc3','admin','1'),
|
||||||
('editor','editor@localhost','editor','editor','1'),
|
('editor','editor@localhost','5aee9dbd2a188839105073571bee1b1f','editor','1'),
|
||||||
('guest','guest@localhost','guest','guest','1');
|
('guest','guest@localhost','084e0343a0486ff05530df6c705c8bb4','guest','1');
|
||||||
CREATE TABLE IF NOT EXISTS `servers` (
|
CREATE TABLE IF NOT EXISTS `servers` (
|
||||||
`id` INTEGER NOT NULL,
|
`id` INTEGER NOT NULL,
|
||||||
`hostname` VARCHAR ( 64 ) UNIQUE,
|
`hostname` VARCHAR ( 64 ) UNIQUE,
|
||||||
|
@ -465,34 +465,6 @@ def update_ver(**kwargs):
|
||||||
print('Cannot update version')
|
print('Cannot update version')
|
||||||
cur.close()
|
cur.close()
|
||||||
con.close()
|
con.close()
|
||||||
|
|
||||||
|
|
||||||
def update_to_hash():
|
|
||||||
cur_ver = funct.check_ver()
|
|
||||||
cur_ver = cur_ver.replace('.','')
|
|
||||||
i = 1
|
|
||||||
ver = ''
|
|
||||||
for l in cur_ver:
|
|
||||||
ver += l
|
|
||||||
i += 1
|
|
||||||
if len(ver) < 4:
|
|
||||||
ver += '00'
|
|
||||||
if cur_ver <= '3.4.9':
|
|
||||||
con, cur = get_cur()
|
|
||||||
sql = """select id, password from user """
|
|
||||||
try:
|
|
||||||
cur.execute(sql)
|
|
||||||
except sqltool.Error as e:
|
|
||||||
out_error(e)
|
|
||||||
else:
|
|
||||||
for u in cur.fetchall():
|
|
||||||
sql = """ update user set password = '%s' where id = '%s' """ % (funct.get_hash(u[1]), u[0])
|
|
||||||
try:
|
|
||||||
cur.execute(sql)
|
|
||||||
con.commit()
|
|
||||||
except sqltool.Error as e:
|
|
||||||
if kwargs.get('silent') != 1:
|
|
||||||
print("An error occurred:", e)
|
|
||||||
|
|
||||||
|
|
||||||
def update_all():
|
def update_all():
|
||||||
|
@ -511,7 +483,6 @@ def update_all():
|
||||||
update_db_v_3_4_9_5()
|
update_db_v_3_4_9_5()
|
||||||
update_db_v_3_5_3()
|
update_db_v_3_5_3()
|
||||||
update_db_v_3_8_1()
|
update_db_v_3_8_1()
|
||||||
update_to_hash()
|
|
||||||
update_ver()
|
update_ver()
|
||||||
|
|
||||||
|
|
||||||
|
@ -531,7 +502,6 @@ def update_all_silent():
|
||||||
update_db_v_3_4_9_5(silent=1)
|
update_db_v_3_4_9_5(silent=1)
|
||||||
update_db_v_3_5_3(silent=1)
|
update_db_v_3_5_3(silent=1)
|
||||||
update_db_v_3_8_1(silent=1)
|
update_db_v_3_8_1(silent=1)
|
||||||
update_to_hash()
|
|
||||||
update_ver()
|
update_ver()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -270,6 +270,7 @@ def get_sections(config):
|
||||||
line.startswith('#HideBlockEnd') or
|
line.startswith('#HideBlockEnd') or
|
||||||
line.startswith('#HideBlockStart') or
|
line.startswith('#HideBlockStart') or
|
||||||
line.startswith('peers') or
|
line.startswith('peers') or
|
||||||
|
line.startswith('resolvers') or
|
||||||
line.startswith('userlist')
|
line.startswith('userlist')
|
||||||
):
|
):
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
|
@ -302,6 +303,7 @@ def get_section_from_config(config, section):
|
||||||
line.startswith('#HideBlockEnd') or
|
line.startswith('#HideBlockEnd') or
|
||||||
line.startswith('#HideBlockStart') or
|
line.startswith('#HideBlockStart') or
|
||||||
line.startswith('peers') or
|
line.startswith('peers') or
|
||||||
|
line.startswith('resolvers') or
|
||||||
line.startswith('userlist')
|
line.startswith('userlist')
|
||||||
):
|
):
|
||||||
record = False
|
record = False
|
||||||
|
|
|
@ -234,7 +234,7 @@ if act == "overviewwaf":
|
||||||
return server_status
|
return server_status
|
||||||
|
|
||||||
|
|
||||||
async def get_runner_overviewWaf(url):
|
async def get_runner_overviewWaf():
|
||||||
import http.cookies
|
import http.cookies
|
||||||
from jinja2 import Environment, FileSystemLoader
|
from jinja2 import Environment, FileSystemLoader
|
||||||
env = Environment(loader=FileSystemLoader('templates/ajax'),extensions=['jinja2.ext.loopcontrols', 'jinja2.ext.do'])
|
env = Environment(loader=FileSystemLoader('templates/ajax'),extensions=['jinja2.ext.loopcontrols', 'jinja2.ext.do'])
|
||||||
|
@ -243,16 +243,16 @@ if act == "overviewwaf":
|
||||||
servers = []
|
servers = []
|
||||||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||||
user_id = cookie.get('uuid')
|
user_id = cookie.get('uuid')
|
||||||
futures = [async_get_overviewWaf(server[1], server[2]) for server in sql.get_dick_permit()]
|
futures = [async_get_overviewWaf(server[1], server[2]) for server in sql.select_servers(server=serv)]
|
||||||
for i, future in enumerate(asyncio.as_completed(futures)):
|
for i, future in enumerate(asyncio.as_completed(futures)):
|
||||||
result = await future
|
result = await future
|
||||||
servers.append(result)
|
servers.append(result)
|
||||||
servers_sorted = sorted(servers, key=funct.get_key)
|
servers_sorted = sorted(servers, key=funct.get_key)
|
||||||
template = template.render(service_status=servers_sorted, role=sql.get_user_role_by_uuid(user_id.value), url=url)
|
template = template.render(service_status=servers_sorted, role=sql.get_user_role_by_uuid(user_id.value))
|
||||||
print(template)
|
print(template)
|
||||||
|
|
||||||
ioloop = asyncio.get_event_loop()
|
ioloop = asyncio.get_event_loop()
|
||||||
ioloop.run_until_complete(get_runner_overviewWaf(form.getvalue('page')))
|
ioloop.run_until_complete(get_runner_overviewWaf())
|
||||||
ioloop.close()
|
ioloop.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,35 +19,23 @@
|
||||||
https_proxy: "{{PROXY}}"
|
https_proxy: "{{PROXY}}"
|
||||||
|
|
||||||
|
|
||||||
- name: install HAProxy {{HAPVER}} on EL6
|
- name: install HAProxy {{HAPVER}} on EL{{ansible_facts['distribution_major_version']}}
|
||||||
yum:
|
yum:
|
||||||
name:
|
name:
|
||||||
- http://repo.haproxy-wi.org/haproxy-{{HAPVER}}.el6.x86_64.rpm
|
- http://repo.haproxy-wi.org/haproxy-{{HAPVER}}.el{{ansible_facts['distribution_major_version']}}.x86_64.rpm
|
||||||
- socat
|
- socat
|
||||||
state: present
|
state: present
|
||||||
when: (ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS') and ansible_facts['distribution_major_version']|int == 6 and HAPVER|length > 0
|
when: (ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS') and HAPVER|length > 0
|
||||||
register: install_result
|
register: install_result
|
||||||
environment:
|
environment:
|
||||||
http_proxy: "{{PROXY}}"
|
http_proxy: "{{PROXY}}"
|
||||||
https_proxy: "{{PROXY}}"
|
https_proxy: "{{PROXY}}"
|
||||||
|
|
||||||
|
|
||||||
- name: install HAProxy {{HAPVER}} on EL7
|
|
||||||
yum:
|
|
||||||
name:
|
|
||||||
- http://repo.haproxy-wi.org/haproxy-{{HAPVER}}.el7.x86_64.rpm
|
|
||||||
- socat
|
|
||||||
state: present
|
|
||||||
when: ((ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS') and ansible_facts['distribution_major_version']|int == 7) and HAPVER|length > 0
|
|
||||||
environment:
|
|
||||||
http_proxy: "{{PROXY}}"
|
|
||||||
https_proxy: "{{PROXY}}"
|
|
||||||
|
|
||||||
|
|
||||||
- name: set_fact from wi`
|
- name: set_fact from wi`
|
||||||
set_fact:
|
set_fact:
|
||||||
haproxy_from_wi: "yes"
|
haproxy_from_wi: "yes"
|
||||||
when: (ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS') and ansible_facts['distribution_major_version']|int == 7 and HAPVER|length > 0
|
when: (ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS') and HAPVER|length > 0
|
||||||
|
|
||||||
|
|
||||||
- name: install the latest version of HAProxy
|
- name: install the latest version of HAProxy
|
||||||
|
@ -56,7 +44,7 @@
|
||||||
- haproxy
|
- haproxy
|
||||||
- socat
|
- socat
|
||||||
state: latest
|
state: latest
|
||||||
when: ((ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS') and ansible_facts['distribution_major_version']|int != 7) or ("'FAILED' in install_result.stderr")
|
when: (ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS') and ("'FAILED' in install_result.stderr")
|
||||||
environment:
|
environment:
|
||||||
http_proxy: "{{PROXY}}"
|
http_proxy: "{{PROXY}}"
|
||||||
https_proxy: "{{PROXY}}"
|
https_proxy: "{{PROXY}}"
|
||||||
|
|
|
@ -112,6 +112,16 @@
|
||||||
</span><div>
|
</span><div>
|
||||||
{% continue %}
|
{% continue %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if line.startswith('resolvers') %}
|
||||||
|
</div><span class="param">{{ line }}
|
||||||
|
{% if role %}
|
||||||
|
<span class="accordion-link">
|
||||||
|
<a href="/app/sections.py?serv={{serv}}§ion={{ line }}">Edit</a>
|
||||||
|
</span>
|
||||||
|
{% endif %}
|
||||||
|
</span><div>
|
||||||
|
{% continue %}
|
||||||
|
{% endif %}
|
||||||
{% if line.startswith('userlist') %}
|
{% if line.startswith('userlist') %}
|
||||||
</div><span class="param">{{ line }}
|
</div><span class="param">{{ line }}
|
||||||
{% if role %}
|
{% if role %}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
{% for service in service_status %}
|
{% for service in service_status %}
|
||||||
{% if service.3 == "On" or service.3 == "Off" or service.3 == "DetectionOnly" or url == "waf.py" %}
|
{% if service.3 == "On" or service.3 == "Off" or service.3 == "DetectionOnly" %}
|
||||||
<tr class="{{ loop.cycle('odd', 'even') }}" id="{{service.0}}-select-line">
|
|
||||||
<td class="padding10 first-collumn-wi">
|
<td class="padding10 first-collumn-wi">
|
||||||
{% if service.2|int() >= 1 %}
|
{% if service.2|int() >= 1 %}
|
||||||
<span class="serverUp server-status" title="running {{service.2 }} processes"></span>
|
<span class="serverUp server-status" title="running {{service.2 }} processes"></span>
|
||||||
|
@ -57,7 +56,13 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
{% else %}
|
||||||
|
<td class="padding10 first-collumn-wi">
|
||||||
|
<span class="serverDown server-status"></span> {{ service.0 }}
|
||||||
|
</td>
|
||||||
|
<td colspan="3">
|
||||||
|
{{ service.3 }}
|
||||||
|
</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<script>
|
<script>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{% from 'include/input_macros.html' import input %}
|
{% from 'include/input_macros.html' import input %}
|
||||||
<form action="diff.py#diff" method="post">
|
<form action="diff.py#diff" method="get">
|
||||||
<center>
|
<center>
|
||||||
<h4>
|
<h4>
|
||||||
<span style="padding: 20px;">Choose left</span>
|
<span style="padding: 20px;">Choose left</span>
|
||||||
|
|
|
@ -1,5 +1,22 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
<style>
|
||||||
|
.alert-danger {
|
||||||
|
width: 450px;
|
||||||
|
display: inline-block;
|
||||||
|
height: 25px;
|
||||||
|
padding-top: 0px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<script>
|
||||||
|
$("#secIntervals").css("display", "none");
|
||||||
|
var ip = []
|
||||||
|
var hostnamea = []
|
||||||
|
{% for s in servers_all %}
|
||||||
|
ip.push("{{s[2]}}")
|
||||||
|
hostnamea.push("{{s[1]}}")
|
||||||
|
{% endfor %}
|
||||||
|
</script>
|
||||||
<table class="overview">
|
<table class="overview">
|
||||||
<tr class="overviewHead">
|
<tr class="overviewHead">
|
||||||
<td class="padding10 first-collumn">
|
<td class="padding10 first-collumn">
|
||||||
|
@ -15,16 +32,19 @@
|
||||||
Metrics
|
Metrics
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a onclick="showOverviewWaf()" title="Refresh" style="float: right; margin-right: 25px;"><img src="/inc/images/update.png" alt="Refresh" class="icon"></a>
|
<a onclick="showOverviewWaf(ip, hostnamea)" title="Refresh" style="float: right; margin-right: 25px;"><img src="/inc/images/update.png" alt="Refresh" class="icon"></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tbody id="ajaxwafstatus"></tbody>
|
{% for s in servers_all %}
|
||||||
|
<tr class="{{ loop.cycle('odd', 'even') }}" id="{{s[1]}}"></tr>
|
||||||
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<link href="/inc/chart.min.css" rel="stylesheet">
|
<link href="/inc/chart.min.css" rel="stylesheet">
|
||||||
<script src="/inc/overview.js"></script>
|
<script src="/inc/overview.js"></script>
|
||||||
<script src="/inc/metrics.js"></script>
|
<script src="/inc/metrics.js"></script>
|
||||||
<script src="/inc/chart.min.js"></script>
|
<script src="/inc/chart.min.js"></script>
|
||||||
|
<script src="/inc/waf.js"></script>
|
||||||
<div id="refresh" style="text-align: right;margin-top: 20px;margin-right: 20px;" title="Refresh metrics" onclick="showWafMetrics()">
|
<div id="refresh" style="text-align: right;margin-top: 20px;margin-right: 20px;" title="Refresh metrics" onclick="showWafMetrics()">
|
||||||
<img src="/inc/images/update.png" alt="Refresh" class="icon">
|
<img src="/inc/images/update.png" alt="Refresh" class="icon">
|
||||||
</div>
|
</div>
|
||||||
|
@ -43,6 +63,6 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
}
|
}
|
||||||
showWafMetrics()
|
showWafMetrics()
|
||||||
showOverviewWaf()
|
showOverviewWaf(ip, hostnamea)
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -134,7 +134,7 @@ function startSetInterval(interval) {
|
||||||
if(interval < 60000) {
|
if(interval < 60000) {
|
||||||
interval = 60000;
|
interval = 60000;
|
||||||
}
|
}
|
||||||
intervalId = setInterval('showOverview()', interval);
|
intervalId = setInterval('showOverview(ip, hostnamea)', interval);
|
||||||
showOverview(ip, hostnamea);
|
showOverview(ip, hostnamea);
|
||||||
} else if (cur_url[0] == "viewlogs.py") {
|
} else if (cur_url[0] == "viewlogs.py") {
|
||||||
intervalId = setInterval('viewLogs()', interval);
|
intervalId = setInterval('viewLogs()', interval);
|
||||||
|
@ -149,8 +149,8 @@ function startSetInterval(interval) {
|
||||||
if(interval < 60000) {
|
if(interval < 60000) {
|
||||||
interval = 60000;
|
interval = 60000;
|
||||||
}
|
}
|
||||||
intervalId = setInterval('showOverviewWaf()', interval);
|
intervalId = setInterval('showOverviewWaf(ip, hostnamea)', interval);
|
||||||
showOverviewWaf();
|
showOverviewWaf(ip, hostnamea);
|
||||||
showWafMetrics();
|
showWafMetrics();
|
||||||
} else if (cur_url[0] == "hapservers.py") {
|
} else if (cur_url[0] == "hapservers.py") {
|
||||||
if(interval < 60000) {
|
if(interval < 60000) {
|
||||||
|
@ -192,41 +192,6 @@ $( document ).ajaxComplete(function( event, request, settings ) {
|
||||||
$('#cover').fadeOut('fast');
|
$('#cover').fadeOut('fast');
|
||||||
NProgress.done();
|
NProgress.done();
|
||||||
});
|
});
|
||||||
function showOverviewWaf() {
|
|
||||||
if (cur_url[0] == "waf.py") {
|
|
||||||
$.getScript('/inc/chart.min.js');
|
|
||||||
showWafMetrics()
|
|
||||||
}
|
|
||||||
$.ajax( {
|
|
||||||
url: "options.py",
|
|
||||||
data: {
|
|
||||||
act: "overviewwaf",
|
|
||||||
page: cur_url[0],
|
|
||||||
token: $('#token').val()
|
|
||||||
},
|
|
||||||
beforeSend: function() {
|
|
||||||
if (cur_url[0] == "waf.py") {
|
|
||||||
var load_class = 'loading_full_page'
|
|
||||||
} else {
|
|
||||||
var load_class = 'loading'
|
|
||||||
}
|
|
||||||
$('#ajaxwafstatus').html('<img class="'+load_class+'" src="/inc/images/loading.gif" />')
|
|
||||||
},
|
|
||||||
type: "POST",
|
|
||||||
success: function( data ) {
|
|
||||||
$("#ajaxwafstatus").empty();
|
|
||||||
$("#ajaxwafstatus").html(data);
|
|
||||||
$.getScript('/inc/overview.js');
|
|
||||||
if (cur_url[0] == "waf.py") {
|
|
||||||
$.getScript('/inc/waf.js');
|
|
||||||
$( "input[type=submit], button" ).button();
|
|
||||||
$( "input[type=checkbox]" ).checkboxradio();
|
|
||||||
} else {
|
|
||||||
$('.first-collumn-wi').css('padding', '10px');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
function showStats() {
|
function showStats() {
|
||||||
$.ajax( {
|
$.ajax( {
|
||||||
url: "options.py",
|
url: "options.py",
|
||||||
|
|
31
inc/waf.js
31
inc/waf.js
|
@ -4,6 +4,37 @@ $( function() {
|
||||||
metrics_waf(id);
|
metrics_waf(id);
|
||||||
});
|
});
|
||||||
} );
|
} );
|
||||||
|
function showOverviewWaf(serv, hostnamea) {
|
||||||
|
$.getScript('/inc/chart.min.js');
|
||||||
|
showWafMetrics();
|
||||||
|
console.log(serv)
|
||||||
|
var i;
|
||||||
|
for (i = 0; i < serv.length; i++) {
|
||||||
|
showOverviewWafCallBack(serv[i], hostnamea[i])
|
||||||
|
}
|
||||||
|
$.getScript('/inc/overview.js');
|
||||||
|
$.getScript('/inc/waf.js');
|
||||||
|
}
|
||||||
|
function showOverviewWafCallBack(serv, hostnamea) {
|
||||||
|
$.ajax( {
|
||||||
|
url: "options.py",
|
||||||
|
data: {
|
||||||
|
act: "overviewwaf",
|
||||||
|
serv: serv,
|
||||||
|
token: $('#token').val()
|
||||||
|
},
|
||||||
|
beforeSend: function() {
|
||||||
|
$("#"+hostnamea).html('<img class="loading_small" src="/inc/images/loading.gif" />');
|
||||||
|
},
|
||||||
|
type: "POST",
|
||||||
|
success: function( data ) {
|
||||||
|
$("#"+hostnamea).empty();
|
||||||
|
$("#"+hostnamea).html(data)
|
||||||
|
$( "input[type=submit], button" ).button();
|
||||||
|
$( "input[type=checkbox]" ).checkboxradio();
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
function metrics_waf(name) {
|
function metrics_waf(name) {
|
||||||
var enable = 0;
|
var enable = 0;
|
||||||
if ($('#'+name).is(':checked')) {
|
if ($('#'+name).is(':checked')) {
|
||||||
|
|
Loading…
Reference in New Issue