mirror of https://github.com/Aidaho12/haproxy-wi
parent
d1ba6f1568
commit
8777d65598
33
README.md
33
README.md
|
@ -6,21 +6,22 @@ A simple web interface(user-frendly web GUI) for managing Haproxy servers. Leave
|
|||
# Features:
|
||||
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.
|
||||
3. View/Analyse HAproxy logs straight from the haproxy-wi web interface
|
||||
4. Create and visualise the HAproxy workflow from Web Ui.
|
||||
5. Push Your changes to your HAproxy servers with a single click through web interface.
|
||||
6. 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. Add/Edit Frontend or backend servers via web interface with a click of a button.
|
||||
8. Edit config of HAproxy and push changes to All Master/Slave server with a single click.
|
||||
9. Add Multiple server to ensure Config Sync between servers.
|
||||
10. Auto management of ports assigned to Fronted.
|
||||
11. Evaluate the changes of recent configs pushed to HAproxy instances straight from web ui
|
||||
12. Multiple User Roles support for privileged based Viewing and editing of Config.
|
||||
13. Create Groups and add /remove servers to ensure proper identification for your HAproxy Clusters
|
||||
14. Send notifications to telegram directly from haproxy-wi.
|
||||
15. haproxy-wi supports high Availability to ensure uptime to all Master slave servers configured.
|
||||
16. SSL certificate support.
|
||||
17. SSH Key support for managing multiple HAproxy Servers straight from haproxy-wi
|
||||
3. Enable/disable servers through stats page without rebooting HAProxy
|
||||
4. View/Analyse HAproxy logs straight from the haproxy-wi web interface
|
||||
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.
|
||||
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.
|
||||
8. Add/Edit Frontend or backend servers via web interface with a click of a button.
|
||||
9. Edit config of HAproxy and push changes to All Master/Slave server with a single click.
|
||||
10. Add Multiple server to ensure Config Sync between servers.
|
||||
11. Auto management of ports assigned to Fronted.
|
||||
12. Evaluate the changes of recent configs pushed to HAproxy instances straight from web ui
|
||||
13. Multiple User Roles support for privileged based Viewing and editing of Config.
|
||||
14. Create Groups and add /remove servers to ensure proper identification for your HAproxy Clusters
|
||||
15. Send notifications to telegram directly from haproxy-wi.
|
||||
16. haproxy-wi supports high Availability to ensure uptime to all Master slave servers configured.
|
||||
17. SSL certificate support.
|
||||
18. SSH Key support for managing multiple HAproxy Servers straight from haproxy-wi
|
||||
|
||||
|
||||
# Install
|
||||
|
@ -96,6 +97,8 @@ For Runtime API enable state file on HAproxt servers and need install socat on a
|
|||
server-state-file /etc/haproxy/haproxy/haproxy.state
|
||||
defaults
|
||||
load-server-state-from-file global
|
||||
listen stats
|
||||
stats admin if TRUE
|
||||
```
|
||||
![alt text](image/haproxy-wi-logs.jpeg "View logs page")
|
||||
|
||||
|
|
|
@ -101,9 +101,9 @@ if form.getvalue('showif'):
|
|||
commands = ["sudo ip link|grep 'UP' | awk '{print $2}' |awk -F':' '{print $1}'"]
|
||||
funct.ssh_command(serv, commands, ip="1")
|
||||
|
||||
if form.getvalue('action') is not None and serv is not None:
|
||||
if form.getvalue('action_hap') is not None and serv is not None:
|
||||
serv = form.getvalue('serv')
|
||||
action = form.getvalue('action')
|
||||
action = form.getvalue('action_hap')
|
||||
|
||||
if funct.check_haproxy_config(serv):
|
||||
commands = [ "sudo systemctl %s haproxy" % action ]
|
||||
|
@ -117,6 +117,31 @@ if act == "overview":
|
|||
if act == "overviewServers":
|
||||
ovw.get_overviewServers()
|
||||
|
||||
if form.getvalue('action'):
|
||||
import requests
|
||||
import json
|
||||
from requests_toolbelt.utils import dump
|
||||
|
||||
haproxy_user = config.get('haproxy', 'stats_user')
|
||||
haproxy_pass = config.get('haproxy', 'stats_password')
|
||||
stats_port = config.get('haproxy', 'stats_port')
|
||||
stats_page = config.get('haproxy', 'stats_page')
|
||||
|
||||
postdata = {
|
||||
'action' : form.getvalue('action'),
|
||||
's' : form.getvalue('s'),
|
||||
'b' : form.getvalue('b')
|
||||
}
|
||||
|
||||
headers = {
|
||||
'User-Agent' : 'Mozilla/5.0 (Windows NT 5.1; rv:20.0) Gecko/20100101 Firefox/20.0',
|
||||
'Accept' : 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
||||
'Accept-Language' : 'en-US,en;q=0.5',
|
||||
'Accept-Encoding' : 'gzip, deflate'
|
||||
}
|
||||
|
||||
q = requests.post('http://'+serv+':'+stats_port+'/'+stats_page, headers=headers, data=postdata, auth=(haproxy_user, haproxy_pass))
|
||||
|
||||
if serv is not None and act == "stats":
|
||||
import requests
|
||||
from requests_toolbelt.utils import dump
|
||||
|
@ -134,7 +159,7 @@ if serv is not None and act == "stats":
|
|||
except requests.exceptions.HTTPError as errh:
|
||||
print ("Http Error:",errh)
|
||||
except requests.exceptions.ConnectionError as errc:
|
||||
print ("Error Connecting:",errc)
|
||||
print ('<div class="alert alert-danger">Error Connecting: %s</div>' % errc)
|
||||
except requests.exceptions.Timeout as errt:
|
||||
print ("Timeout Error:",errt)
|
||||
except requests.exceptions.RequestException as err:
|
||||
|
@ -192,7 +217,7 @@ if form.getvalue('servaction') is not None:
|
|||
enable = form.getvalue('servaction')
|
||||
backend = form.getvalue('servbackend')
|
||||
|
||||
cmd='echo "%s %s" |sudo socat stdio %s | cut -d "," -f 1-2,5-10,34-36 | column -s, -t' % (enable, backend, haproxy_sock)
|
||||
cmd='echo "%s %s" |sudo socat stdio %s | cut -d "," -f 1-2,5-10,18,34-36 | column -s, -t' % (enable, backend, haproxy_sock)
|
||||
|
||||
if form.getvalue('save') == "on":
|
||||
save_command = 'echo "show servers state" | sudo socat stdio %s > %s' % (haproxy_sock, server_state_file)
|
||||
|
|
|
@ -98,7 +98,7 @@
|
|||
{% endif %}
|
||||
</ul>
|
||||
</nav>
|
||||
<div class="copyright-menu">HAproxy-WI v2.5.4.2</div>
|
||||
<div class="copyright-menu">HAproxy-WI v2.5.4.3</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
|
|
|
@ -15,6 +15,29 @@
|
|||
<a class="ui-button ui-widget ui-corner-all" id="show" title="Show stats" onclick="{{ onclick }}">Show</a>
|
||||
</form>
|
||||
<div id="ajax" style="margin-left: 10px;"></div>
|
||||
<script> window.onload = showStats()</script>
|
||||
<script>
|
||||
window.onload = showStats();
|
||||
function sleep(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
async function wait() {
|
||||
await sleep(2000);
|
||||
$('form').append('<input type="hidden" name="serv" value='+$("#serv").val()+'>');
|
||||
|
||||
$("form").submit(function() {
|
||||
$.ajax({
|
||||
type: "get",
|
||||
url: "options.py",
|
||||
dataType: "text",
|
||||
data: $(this).serialize(),
|
||||
success: function( data ) {
|
||||
//$("#ajax").html(data);
|
||||
showStats();
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<link href="/inc/style.css" rel="stylesheet">
|
||||
{% endblock %}
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python3
|
||||
import html, http, os
|
||||
import html, http.cookies, os
|
||||
import cgi
|
||||
import requests
|
||||
import funct
|
||||
import sql
|
||||
from requests_toolbelt.utils import dump
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
env = Environment(loader=FileSystemLoader('templates/'))
|
||||
template = env.get_template('viewstats.html')
|
||||
|
|
|
@ -5,7 +5,7 @@ function ajaxActionServers(action, id) {
|
|||
$.ajax( {
|
||||
url: "options.py",
|
||||
data: {
|
||||
action: action,
|
||||
action_hap: action,
|
||||
serv: id
|
||||
},
|
||||
success: function( data ) {
|
||||
|
|
|
@ -137,6 +137,7 @@ function showStats() {
|
|||
success: function( data ) {
|
||||
$("#ajax").html(data);
|
||||
window.history.pushState("Stats", "Stats", cur_url[0]+"?serv="+$("#serv").val());
|
||||
wait();
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue