mirror of https://github.com/Aidaho12/haproxy-wi
parent
19c22875eb
commit
d19eb8a3a3
|
@ -73,9 +73,9 @@ def create_table(**kwargs):
|
|||
`groups` VARCHAR ( 120 ),
|
||||
PRIMARY KEY(`id`)
|
||||
);
|
||||
INSERT INTO user (username, email, password, role, groups) VALUES ('admin','admin@localhost','admin','admin','1'),
|
||||
('editor','editor@localhost','editor','editor','1'),
|
||||
('guest','guest@localhost','guest','guest','1');
|
||||
INSERT INTO user (username, email, password, role, groups) VALUES ('admin','admin@localhost','21232f297a57a5a743894a0e4a801fc3','admin','1'),
|
||||
('editor','editor@localhost','5aee9dbd2a188839105073571bee1b1f','editor','1'),
|
||||
('guest','guest@localhost','084e0343a0486ff05530df6c705c8bb4','guest','1');
|
||||
CREATE TABLE IF NOT EXISTS `servers` (
|
||||
`id` INTEGER NOT NULL,
|
||||
`hostname` VARCHAR ( 64 ) UNIQUE,
|
||||
|
@ -467,34 +467,6 @@ def update_ver(**kwargs):
|
|||
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():
|
||||
update_db_v_31()
|
||||
update_db_v_3_2()
|
||||
|
@ -511,7 +483,6 @@ def update_all():
|
|||
update_db_v_3_4_9_5()
|
||||
update_db_v_3_5_3()
|
||||
update_db_v_3_8_1()
|
||||
update_to_hash()
|
||||
update_ver()
|
||||
|
||||
|
||||
|
@ -531,7 +502,6 @@ def update_all_silent():
|
|||
update_db_v_3_4_9_5(silent=1)
|
||||
update_db_v_3_5_3(silent=1)
|
||||
update_db_v_3_8_1(silent=1)
|
||||
update_to_hash()
|
||||
update_ver()
|
||||
|
||||
|
||||
|
|
|
@ -270,6 +270,7 @@ def get_sections(config):
|
|||
line.startswith('#HideBlockEnd') or
|
||||
line.startswith('#HideBlockStart') or
|
||||
line.startswith('peers') or
|
||||
line.startswith('resolvers') or
|
||||
line.startswith('userlist')
|
||||
):
|
||||
line = line.strip()
|
||||
|
@ -302,6 +303,7 @@ def get_section_from_config(config, section):
|
|||
line.startswith('#HideBlockEnd') or
|
||||
line.startswith('#HideBlockStart') or
|
||||
line.startswith('peers') or
|
||||
line.startswith('resolvers') or
|
||||
line.startswith('userlist')
|
||||
):
|
||||
record = False
|
||||
|
|
|
@ -234,7 +234,7 @@ if act == "overviewwaf":
|
|||
return server_status
|
||||
|
||||
|
||||
async def get_runner_overviewWaf(url):
|
||||
async def get_runner_overviewWaf():
|
||||
import http.cookies
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
env = Environment(loader=FileSystemLoader('templates/ajax'),extensions=['jinja2.ext.loopcontrols', 'jinja2.ext.do'])
|
||||
|
@ -243,16 +243,16 @@ if act == "overviewwaf":
|
|||
servers = []
|
||||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||
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)):
|
||||
result = await future
|
||||
servers.append(result)
|
||||
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)
|
||||
|
||||
ioloop = asyncio.get_event_loop()
|
||||
ioloop.run_until_complete(get_runner_overviewWaf(form.getvalue('page')))
|
||||
ioloop.run_until_complete(get_runner_overviewWaf())
|
||||
ioloop.close()
|
||||
|
||||
|
||||
|
|
|
@ -19,35 +19,23 @@
|
|||
https_proxy: "{{PROXY}}"
|
||||
|
||||
|
||||
- name: install HAProxy {{HAPVER}} on EL6
|
||||
- name: install HAProxy {{HAPVER}} on EL{{ansible_facts['distribution_major_version']}}
|
||||
yum:
|
||||
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
|
||||
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
|
||||
environment:
|
||||
http_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`
|
||||
set_fact:
|
||||
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
|
||||
|
@ -56,7 +44,7 @@
|
|||
- haproxy
|
||||
- socat
|
||||
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:
|
||||
http_proxy: "{{PROXY}}"
|
||||
https_proxy: "{{PROXY}}"
|
||||
|
|
|
@ -112,6 +112,16 @@
|
|||
</span><div>
|
||||
{% continue %}
|
||||
{% 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') %}
|
||||
</div><span class="param">{{ line }}
|
||||
{% if role %}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
{% for service in service_status %}
|
||||
{% if service.3 == "On" or service.3 == "Off" or service.3 == "DetectionOnly" or url == "waf.py" %}
|
||||
<tr class="{{ loop.cycle('odd', 'even') }}" id="{{service.0}}-select-line">
|
||||
{% if service.3 == "On" or service.3 == "Off" or service.3 == "DetectionOnly" %}
|
||||
<td class="padding10 first-collumn-wi">
|
||||
{% if service.2|int() >= 1 %}
|
||||
<span class="serverUp server-status" title="running {{service.2 }} processes"></span>
|
||||
|
@ -57,7 +56,13 @@
|
|||
{% endif %}
|
||||
</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 %}
|
||||
{% endfor %}
|
||||
<script>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{% from 'include/input_macros.html' import input %}
|
||||
<form action="diff.py#diff" method="post">
|
||||
<form action="diff.py#diff" method="get">
|
||||
<center>
|
||||
<h4>
|
||||
<span style="padding: 20px;">Choose left</span>
|
||||
|
|
|
@ -1,5 +1,22 @@
|
|||
{% extends "base.html" %}
|
||||
{% 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">
|
||||
<tr class="overviewHead">
|
||||
<td class="padding10 first-collumn">
|
||||
|
@ -15,16 +32,19 @@
|
|||
Metrics
|
||||
</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>
|
||||
</tr>
|
||||
<tbody id="ajaxwafstatus"></tbody>
|
||||
{% for s in servers_all %}
|
||||
<tr class="{{ loop.cycle('odd', 'even') }}" id="{{s[1]}}"></tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
<link href="/inc/chart.min.css" rel="stylesheet">
|
||||
<script src="/inc/overview.js"></script>
|
||||
<script src="/inc/metrics.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()">
|
||||
<img src="/inc/images/update.png" alt="Refresh" class="icon">
|
||||
</div>
|
||||
|
@ -43,6 +63,6 @@
|
|||
{% endfor %}
|
||||
}
|
||||
showWafMetrics()
|
||||
showOverviewWaf()
|
||||
showOverviewWaf(ip, hostnamea)
|
||||
</script>
|
||||
{% endblock %}
|
|
@ -134,7 +134,7 @@ function startSetInterval(interval) {
|
|||
if(interval < 60000) {
|
||||
interval = 60000;
|
||||
}
|
||||
intervalId = setInterval('showOverview()', interval);
|
||||
intervalId = setInterval('showOverview(ip, hostnamea)', interval);
|
||||
showOverview(ip, hostnamea);
|
||||
} else if (cur_url[0] == "viewlogs.py") {
|
||||
intervalId = setInterval('viewLogs()', interval);
|
||||
|
@ -149,8 +149,8 @@ function startSetInterval(interval) {
|
|||
if(interval < 60000) {
|
||||
interval = 60000;
|
||||
}
|
||||
intervalId = setInterval('showOverviewWaf()', interval);
|
||||
showOverviewWaf();
|
||||
intervalId = setInterval('showOverviewWaf(ip, hostnamea)', interval);
|
||||
showOverviewWaf(ip, hostnamea);
|
||||
showWafMetrics();
|
||||
} else if (cur_url[0] == "hapservers.py") {
|
||||
if(interval < 60000) {
|
||||
|
@ -192,41 +192,6 @@ $( document ).ajaxComplete(function( event, request, settings ) {
|
|||
$('#cover').fadeOut('fast');
|
||||
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() {
|
||||
$.ajax( {
|
||||
url: "options.py",
|
||||
|
|
31
inc/waf.js
31
inc/waf.js
|
@ -4,6 +4,37 @@ $( function() {
|
|||
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) {
|
||||
var enable = 0;
|
||||
if ($('#'+name).is(':checked')) {
|
||||
|
|
Loading…
Reference in New Issue