Pavel Loginov 2020-01-05 23:47:35 +03:00
parent 0c489c9922
commit fde50d7069
5 changed files with 85 additions and 10 deletions

View File

@ -15,10 +15,10 @@ Web interface(user-friendly web GUI, alerting, monitoring and secure) for managi
![alt text](image/haproxy-wi-config-show.png "Show config page") ![alt text](image/haproxy-wi-config-show.png "Show config page")
# Features: # Features:
1. Configure HAProxy In a jiffy with haproxy-wi 1. Configure HAProxy In a jiffy with HAProxy-WI
2. View and analyse Status of all Frontend/backend server via haproxy-wi from a single control panel. 2. View and analyse Status of all Frontend/backend server via HAProxy-WI from a single control panel.
3. Enable/disable servers through stats page without rebooting HAProxy 3. Enable/disable servers through stats page without rebooting HAProxy
4. View/Analyse HAproxy logs straight from the haproxy-wi web interface 4. View/Analyse HAproxy logs straight from the HAProxy-WI web interface
5. Create and visualise the HAproxy workflow from Web Ui. 5. Create and visualise the HAproxy workflow from Web Ui.
6. Push Your changes to your HAproxy servers with a single click through web interface 6. Push Your changes to your HAproxy servers with a single click through web interface
7. Get info on past changes, Evaluate your config files and restore a previous stable config anytime with a single click straight from Web interface 7. Get info on past changes, Evaluate your config files and restore a previous stable config anytime with a single click straight from Web interface
@ -32,7 +32,7 @@ Web interface(user-friendly web GUI, alerting, monitoring and secure) for managi
15. Send notifications to telegram directly from HAProxy-WI 15. Send notifications to telegram directly from HAProxy-WI
16. HAProxy-WI supports high Availability to ensure uptime to all Master slave servers configured 16. HAProxy-WI supports high Availability to ensure uptime to all Master slave servers configured
17. SSL certificate support. 17. SSL certificate support.
18. SSH Key support for managing multiple HAproxy Servers straight from haproxy-wi 18. SSH Key support for managing multiple HAProxy Servers straight from HAProxy-WI
19. SYN flood protect 19. SYN flood protect
20. Alerting about changes backends state 20. Alerting about changes backends state
21. Alerting about HAProxy service state 21. Alerting about HAProxy service state
@ -45,6 +45,7 @@ Web interface(user-friendly web GUI, alerting, monitoring and secure) for managi
28. Mobile-ready desing 28. Mobile-ready desing
29. REST API 29. REST API
30. Installation and Upgrading HAProxy service via HAProxy-WI 30. Installation and Upgrading HAProxy service via HAProxy-WI
31. Backup HAProxy's config files through HAProxy-WI
![alt text](image/haproxy-wi-metrics.png "Merics") ![alt text](image/haproxy-wi-metrics.png "Merics")

View File

@ -8,7 +8,7 @@ if mysql_enable == '1':
mysql_password = funct.get_config_var('mysql', 'mysql_password') mysql_password = funct.get_config_var('mysql', 'mysql_password')
mysql_db = funct.get_config_var('mysql', 'mysql_db') mysql_db = funct.get_config_var('mysql', 'mysql_db')
mysql_host = funct.get_config_var('mysql', 'mysql_host') mysql_host = funct.get_config_var('mysql', 'mysql_host')
mysql_port = funct.get_config_var('mysql', 'mysql_port') mysql_port = funct.get_config_var('mysql', 'mysql_port')
import mysql.connector as sqltool import mysql.connector as sqltool
else: else:
db = "/var/www/haproxy-wi/app/haproxy-wi.db" db = "/var/www/haproxy-wi/app/haproxy-wi.db"
@ -123,6 +123,7 @@ def create_table(**kwargs):
CREATE TABLE IF NOT EXISTS `version` (`version` varchar(64)); CREATE TABLE IF NOT EXISTS `version` (`version` varchar(64));
CREATE TABLE IF NOT EXISTS `options` ( `id` INTEGER NOT NULL, `options` VARCHAR ( 64 ), `groups` VARCHAR ( 120 ), PRIMARY KEY(`id`)); CREATE TABLE IF NOT EXISTS `options` ( `id` INTEGER NOT NULL, `options` VARCHAR ( 64 ), `groups` VARCHAR ( 120 ), PRIMARY KEY(`id`));
CREATE TABLE IF NOT EXISTS `saved_servers` ( `id` INTEGER NOT NULL, `server` VARCHAR ( 64 ), `description` VARCHAR ( 120 ), `groups` VARCHAR ( 120 ), PRIMARY KEY(`id`)); CREATE TABLE IF NOT EXISTS `saved_servers` ( `id` INTEGER NOT NULL, `server` VARCHAR ( 64 ), `description` VARCHAR ( 120 ), `groups` VARCHAR ( 120 ), PRIMARY KEY(`id`));
CREATE TABLE IF NOT EXISTS `backups` ( `id` INTEGER NOT NULL, `server` VARCHAR ( 64 ), `rhost` VARCHAR ( 120 ), `rpath` VARCHAR ( 120 ), `type` VARCHAR ( 120 ), `time` VARCHAR ( 120 ), cred INTEGER, `description` VARCHAR ( 120 ), PRIMARY KEY(`id`));
""" """
try: try:
cur.executescript(sql) cur.executescript(sql)
@ -456,9 +457,10 @@ def update_db_v_3_8_1(**kwargs):
cur.close() cur.close()
con.close() con.close()
def update_ver(**kwargs): def update_ver(**kwargs):
con, cur = get_cur() con, cur = get_cur()
sql = """update version set version = '3.10.1.0'; """ sql = """update version set version = '3.11.0.0'; """
try: try:
cur.execute(sql) cur.execute(sql)
con.commit() con.commit()

View File

@ -18,3 +18,4 @@ CREATE TABLE IF NOT EXISTS `settings` (`param` varchar(64) UNIQUE, value varchar
CREATE TABLE IF NOT EXISTS `version` (`version` varchar(64)); CREATE TABLE IF NOT EXISTS `version` (`version` varchar(64));
CREATE TABLE IF NOT EXISTS `options` ( `id` INTEGER NOT NULL, `options` VARCHAR ( 64 ), `groups` VARCHAR ( 120 ), PRIMARY KEY(`id`)); CREATE TABLE IF NOT EXISTS `options` ( `id` INTEGER NOT NULL, `options` VARCHAR ( 64 ), `groups` VARCHAR ( 120 ), PRIMARY KEY(`id`));
CREATE TABLE IF NOT EXISTS `saved_servers` ( `id` INTEGER NOT NULL, `server` VARCHAR ( 64 ), `description` VARCHAR ( 120 ), `groups` VARCHAR ( 120 ), PRIMARY KEY(`id`)); CREATE TABLE IF NOT EXISTS `saved_servers` ( `id` INTEGER NOT NULL, `server` VARCHAR ( 64 ), `description` VARCHAR ( 120 ), `groups` VARCHAR ( 120 ), PRIMARY KEY(`id`));
CREATE TABLE IF NOT EXISTS `backups` ( `id` INTEGER NOT NULL, `server` VARCHAR ( 64 ), `rhost` VARCHAR ( 120 ), `rpath` VARCHAR ( 120 ), `time` VARCHAR ( 120 ), cred INTEGER, `description` VARCHAR ( 120 ), PRIMARY KEY(`id`));

View File

@ -350,7 +350,7 @@ def write_user_token(login, user_token):
try: try:
cur.execute(sql) cur.execute(sql)
except sqltool.Error as e: except sqltool.Error as e:
print('<span class="alert alert-danger" id="error">An error occurred: ' + e.args[0] + ' <a title="Close" id="errorMess"><b>X</b></a></span>') out_error(e)
for id in cur.fetchall(): for id in cur.fetchall():
if mysql_enable == '1': if mysql_enable == '1':
sql = """ insert into token (user_id, token, exp) values('%s', '%s', now()+ INTERVAL %s day) """ % (id[0], user_token, token_ttl) sql = """ insert into token (user_id, token, exp) values('%s', '%s', now()+ INTERVAL %s day) """ % (id[0], user_token, token_ttl)
@ -620,6 +620,7 @@ def update_ssh(id, name, enable, group, username, password):
cur.close() cur.close()
con.close() con.close()
def show_update_ssh(name, page): def show_update_ssh(name, page):
from jinja2 import Environment, FileSystemLoader from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('templates/ajax')) env = Environment(loader=FileSystemLoader('templates/ajax'))
@ -1501,7 +1502,7 @@ if form.getvalue('updateuser') is not None:
if check_group(group, role_id): if check_group(group, role_id):
if funct.is_admin(level=role_id): if funct.is_admin(level=role_id):
update_user(new_user, email, role, group, id, activeuser) update_user(new_user, email, role, group, id, activeuser)
funct.logging('user with id '+id, ' user '+user+' updated ', haproxywi=1, login=1) funct.logging('user with id '+id, ' user '+new_user+' updated ', haproxywi=1, login=1)
else: else:
funct.logging(new_user, ' tried to privilege escalation', haproxywi=1, login=1) funct.logging(new_user, ' tried to privilege escalation', haproxywi=1, login=1)
@ -1687,7 +1688,6 @@ if form.getvalue('sshdel') is not None:
pass pass
if delete_ssh(sshdel): if delete_ssh(sshdel):
print("Ok") print("Ok")
funct.logging('the ssh '+sshdel, ' deleted ', haproxywi=1, login=1)
if form.getvalue('newtelegram'): if form.getvalue('newtelegram'):

View File

@ -284,7 +284,7 @@
</td> </td>
<td class="padding10 first-collumn" style="width: 20%;"> <td class="padding10 first-collumn" style="width: 20%;">
{% set values = dict() %} {% set values = dict() %}
{% set values = {'2.0.5-1':'2.0.5-1','2.0.6-1':'2.0.6-1', '2.0.7-1':'2.0.7-1', '2.0.9-1':'2.0.9-1', '2.0.11-1':'2.0.11-1'} %} {% set values = {'2.0.5-1':'2.0.5-1','2.0.6-1':'2.0.6-1', '2.0.7-1':'2.0.7-1', '2.0.9-1':'2.0.9-1', '2.0.11-1':'2.0.11-1', '2.0.12-1':'2.0.12-1'} %}
{{ select('hapver', values=values, selected='2.0.11-1', required='required') }} {{ select('hapver', values=values, selected='2.0.11-1', required='required') }}
</td> </td>
<td class="padding10 first-collumn"> <td class="padding10 first-collumn">
@ -305,6 +305,7 @@
</table> </table>
<div id="ajax"></div> <div id="ajax"></div>
</div> </div>
</div> </div>
<div id="group_error" style="display: none;"> <div id="group_error" style="display: none;">
<div class="alert alert-danger"> <div class="alert alert-danger">
@ -354,6 +355,76 @@
</table> </table>
<input type="submit" tabindex="-1" style="position:absolute; top:-1000px"> <input type="submit" tabindex="-1" style="position:absolute; top:-1000px">
</form> </form>
<div id="backup-add-table" title="Add a new backup job " style="display: none;">
<table class="overview">
<tr>
<td class="padding20" style="width: 40%;">
Choose server for backup
<span class="need-field">*</span>
</td>
<td>
<select autofocus required name="backup-server" id="backup-server">
<option disabled>Choose server</option>
{% for s in servers %}}
<option value="{{ s.2 }}">{{ s.1 }}</option>
{% endfor %}
</select>
</td>
<tr>
<td class="padding20">
Enter backup server
<span class="need-field">*</span>
</td>
<td>
{{ input('rserver', size='30', placeholder="172.0.0.1", required="required") }}
</td>
<tr>
<tr>
<td class="padding20">
Enter remote folder
<span class="need-field">*</span>
</td>
<td>
{{ input('rpath', size='30', placeholder="/var/backups", required="required") }}
</td>
<tr>
<tr>
<td class="padding20">
Period time
<span class="need-field">*</span>
</td>
<td>
{% set values = {'hourly':'hourly','daily':'daily','weekly':'weekly', 'monthly':'monthly'} %}
{{ select('backup-time', values=values, selected='weekly', required='required', class='force_close') }}
</td>
</tr>
</tr>
<tr>
<td class="padding20">
Credentials for remote server
<span class="need-field">*</span>
</td>
<td>
<select id="backup-credentials" required>
<option disabled selected>Choose credentials</option>
{% for ssh in sshs %}
{% if ssh.2 == 1 and ssh.5|string() == group %}
<option value="{{ssh.0}}">{{ssh.1}}</option>
{% endif %}
{% endfor %}
</select>
</td>
</tr>
<tr>
<td class="padding20">
Description
</td>
<td>
{{ input('backup-description', size='30') }}
</td>
<tr>
</table>
</div>
</div> </div>
{% include 'include/change_pass_form.html' %} {% include 'include/change_pass_form.html' %}
<script> <script>