Pavel Loginov 4 years ago
parent 6cb81369ae
commit e286b40998

@ -182,18 +182,18 @@ if form.getvalue('mode') is not None:
filter = ""
if compression == "1" or cache == "2":
filter = " filter compression\n"
if compression == "1":
compression_s = " compression algo gzip\n compression type text/html text/plain text/css\n"
if cache == "2":
cache_s = " http-request cache-use "+end_name+"\n http-response cache-store "+end_name+"\n"
cache_set = "cache "+end_name+"\n total-max-size 4\n max-age 240\n"
if compression == "1":
compression_s = " compression algo gzip\n compression type text/html text/plain text/css\n"
waf = ""
if form.getvalue('waf') is not None:
waf = " filter spoe engine modsecurity config "+haproxy_dir+"/waf.conf\n"
waf += " http-request deny if { var(txn.modsec.code) -m int gt 0 }\n"
config_add = "\n" + name + "\n" + bind + mode + maxconn + balance + options_split + filter + compression_s + cache_s + waf + backend + servers_split + "\n" + cache_set
config_add = "\n" + name + "\n" + bind + mode + maxconn + balance + options_split + cache_s + filter + compression_s + waf + backend + servers_split + "\n" + cache_set + "\n"
if form.getvalue('new_userlist') is not None:
name = "userlist "+form.getvalue('new_userlist')+ "\n"
@ -231,7 +231,7 @@ try:
with open(cfg, "a") as conf:
conf.write(config_add)
except IOError:
print("Can't read import config file")
print("error: Can't read import config file")
funct.logging(serv, "add.py add new %s" % name)
print('<div class="line3" style="position: absolute;top: 35px;left: 200px;">')
@ -243,7 +243,7 @@ try:
stderr = funct.upload_and_restart(serv, cfg, just_save="save")
if stderr:
print('<div class="alert alert-danger">%s</div><div id="close"><span title="Close" style="cursor: pointer; float: right;">X</span></div>' % stderr)
print('<div class="alert alert-danger">%s</div><div id="close"><span title="Close" style="cursor: pointer; float: right;">X</span></div><script>$("#errorMess").click(function(){$("#error").remove();});</script>' % stderr)
else:
print('<meta http-equiv="refresh" content="0; url=add.py?add=%s&conf=%s&serv=%s">' % (name, config_add, serv))

@ -610,7 +610,7 @@ def update_db_v_4_4_2(**kwargs):
def update_ver(**kwargs):
con, cur = get_cur()
sql = """update version set version = '4.4.0.0'; """
sql = """update version set version = '4.4.1.0'; """
try:
cur.execute(sql)
con.commit()

@ -864,7 +864,10 @@ def haproxy_wi_log(**kwargs):
def show_ip(stdout):
for line in stdout:
print(line)
if "Permission denied" in line:
print('error: '+line)
else:
print(line)
def server_status(stdout):

@ -49,7 +49,7 @@ for s in servers:
servers_with_status.append(s[2])
servers_with_status.append(s[11])
if service == 'nginx':
cmd = [ "/usr/sbin/nginx -v && systemctl status nginx |grep -e 'Active\|Tasks' |awk '{print $2, $9$10$11$12$13}'" ]
cmd = [ "/usr/sbin/nginx -v && systemctl status nginx |grep -e 'Active' |awk '{print $2, $9$10$11$12$13}' && ps ax |grep nginx:|grep -v grep |wc -l" ]
out = funct.ssh_command(s[2], cmd)
h = ()
out1 = []

@ -1852,16 +1852,16 @@ if form.getvalue('newsmon') is not None:
try:
port = int(port)
except:
print('error: port must number')
print('SMON error: port must number')
sys.exit()
if port > 65535 or port < 0:
print('error: port must be 0-65535')
print('SMON error: port must be 0-65535')
sys.exit()
if port == 80 and http == 'https':
print('error: Cannot be HTTPS with 80 port')
print('SMON error: Cannot be HTTPS with 80 port')
sys.exit()
if port == 443 and http == 'http':
print('error: Cannot be HTTP with 443 port')
print('SMON error: Cannot be HTTP with 443 port')
sys.exit()
if sql.insert_smon(server, port, enable, http, uri, body, group, desc, telegram, user_group):
@ -1870,7 +1870,7 @@ if form.getvalue('newsmon') is not None:
template = env.get_template('ajax/show_new_smon.html')
template = template.render(smon=sql.select_smon(user_group,ip=server,port=port,proto=http,uri=uri,body=body), telegrams=sql.get_user_telegram_by_group(user_group))
print(template)
funct.logging('SMON','Has been add a new server '+server+' to SMON ', haproxywi=1, login=1)
funct.logging('SMON', ' Has been add a new server '+server+' to SMON ', haproxywi=1, login=1)
if form.getvalue('smondel') is not None:
@ -1882,7 +1882,7 @@ if form.getvalue('smondel') is not None:
if sql.delete_smon(id, user_group):
print('Ok')
funct.logging('SMON','Has been delete server from SMON ', haproxywi=1, login=1)
funct.logging('SMON', ' Has been delete server from SMON ', haproxywi=1, login=1)
if form.getvalue('showsmon') is not None:
@ -1913,21 +1913,21 @@ if form.getvalue('updateSmonIp') is not None:
try:
port = int(port)
except:
print('error: port must number')
print('SMON error: port must number')
sys.exit()
if port > 65535 or port < 0:
print('error: port must be 0-65535')
print('SMON error: port must be 0-65535')
sys.exit()
if port == 80 and http == 'https':
print('error: Cannot be https with 80 port')
print('SMON error: Cannot be https with 80 port')
sys.exit()
if port == 443 and http == 'http':
print('error: Cannot be HTTP with 443 port')
print('SMON error: Cannot be HTTP with 443 port')
sys.exit()
if sql.update_smon(id, ip, port, body, telegram, group, desc, en):
print("Ok")
funct.logging('SMON','Has been update the server '+ip+' to SMON ', haproxywi=1, login=1)
funct.logging('SMON', ' Has been update the server '+ip+' to SMON ', haproxywi=1, login=1)
if form.getvalue('showBytes') is not None:

@ -80,6 +80,7 @@
<li><a href="/app/config.py?service=nginx" title="Edit Nginx config" class="edit head-submenu">Configs</a></li>
<li><a href="/app/viewsttats.py?service=nginx" title="Show stats" class="stats head-submenu">Stats</a></li>
<li><a href="/app/versions.py?service=nginx" title="Actions with Nginx configs versions" class="version head-submenu">Versions</a></li>
<li><a href="/app/add.py?service=nginx#ssl" title="Upload SSL cert" class="cert head-submenu" id="add3">SSL</a></li>
</ul>
</li>
<li class="p_menu">

@ -49,7 +49,11 @@
});
});
</script>
<div id="up-pannel" class="sortable">
{% if serv %}
<div id="up-pannel">
{% else %}
<div id="up-pannel" class="sortable">
{% endif %}
{% if servers|length == 0 %}
{% include 'include/getstarted.html' %}
{% endif %}
@ -67,6 +71,7 @@
{% endfor %}
{% endif %}
showOverviewServer('{{s.1}}', '{{s.2}}', '{{s.0}}', '{{service}}');
showBytes('{{ s.2 }}')
}
showMetrics();
</script>
@ -126,11 +131,17 @@
</span>
{% endif %}
</div>
<div class="server-desc">
{% if service == 'nginx' %}
<div class="server-desc" style="height: 110px;">
{% else %}
<div class="server-desc">
{% endif %}
{{s.3}}
<br />
{% if service == 'nginx' %}
Version: {{s.5.0.2}} Process_num: {{s.5.0.5}} {% if s.5.0.3 == 'active' %} Uptime: {% else %} Downtime: {% endif %} {{s.5.0.4}}
Version: {{s.5.0.2}} Process_num: {{s.5.0.5}} {% if s.5.0.3 == 'active' %}
<br />
Uptime: {% else %} Downtime: {% endif %} {{s.5.0.4}}
{% else %}
{% if s.5.0 is defined %}
{{s.5.0.0}} {{s.5.0.1}} {{s.5.0.2}}
@ -187,28 +198,29 @@
</div>
</div>
{% if serv %}
{% if service == 'haproxy' %}
<div id="bin_bout"></div>
{% endif %}
<div id="ajax-server-{{s.0}}" class="ajax-server"></div>
<div class="div-server div-backends">
<div class="server-name backends">
<div class="div-server div-backends">
<div class="server-name backends">
{% if service == 'haproxy' %}
Backends:
{% else %}
Virtual hosts:
{% endif %}
</div>
</div>
<div style="margin-top: 10px;" id="top-{{s.1}}"></div>
</div>
{% endif %}
{% endfor %}
</div>
{% if serv and service == 'haproxy' %}
<div id="refresh" style="text-align: right;margin-right: 105px;clear: both;display: block;padding-top: 20px;margin-bottom: -25px;" title="Refresh metrics" onclick="showMetrics()">
<div id="refresh" style="text-align: right;margin-right: 105px;clear: both;display: block;margin-bottom: -25px;" title="Refresh metrics" onclick="showMetrics()">
<span class="service-reload"></span>
</div>
{% for s in servers %}
<div class="chart-container" style="display: block; width: 90%; height: 300px;">
<div class="chart-container" style="display: block; width: 91.3%; height: 300px;">
<canvas id="{{s.2}}" role="img"></canvas>
</div>
<div class="chart-container" style="display: block; width: 90%; height: 300px;">

@ -6,6 +6,11 @@
<h3>{{ add }} was success added</h3>
{{ conf_add }}
</div>
<script>
$('#close').click(function(){
$('.alert-success').remove();
});
</script>
{% endif %}
<div id="create" style="height: 95%; margin-top: 20px;">
<div id="left-collumn">

@ -660,7 +660,54 @@ $( function() {
$( "#serv3" ).on('selectmenuchange',function() {
change_select_acceleration("3");
});
$('#compression').on( "click", function() {
if ($('#compression').is(':checked')) {
$("#cache").checkboxradio( "disable" );
$("#cache").prop('checked', false);
} else {
change_select_acceleration("");
}
});
$('#compression2').on( "click", function() {
if ($('#compression2').is(':checked')) {
$("#cache2").checkboxradio( "disable" );
$("#cache2").prop('checked', false);
} else {
change_select_acceleration('2');
}
});
$('#compression3').on( "click", function() {
if ($('#compression3').is(':checked')) {
$("#cache3").checkboxradio( "disable" );
$("#cache3").prop('checked', false);
} else {
change_select_acceleration('3');
}
});
$('#cache').on( "click", function() {
if ($('#cache').is(':checked')) {
$("#compression").checkboxradio( "disable" );
$("#compression").prop('checked', false);
} else {
$("#compression").checkboxradio( "enable" );
}
});
$('#cache2').on( "click", function() {
if ($('#cache2').is(':checked')) {
$("#compression2").checkboxradio( "disable" );
$("#compression2").prop('checked', false);
} else {
$("#compression2").checkboxradio( "enable" );
}
});
$('#cache3').on( "click", function() {
if ($('#cache3').is(':checked')) {
$("#compression3").checkboxradio( "disable" );
$("#compression3").prop('checked', false);
} else {
$("#compression3").checkboxradio( "enable" );
}
});
$( "#add1" ).on( "click", function() {
$('.menu li ul li').each(function () {
$(this).find('a').css('padding-left', '20px')
@ -896,6 +943,8 @@ function resetProxySettings() {
$('[id^=https-hide]').hide();
$('[name=mode').val('http');
$('select').selectmenu('refresh');
$("#path-cert-listen" ).attr('required',false);
$("#path-cert-frontend" ).attr('required',false);
replace_text("#optionsInput", ssl_offloading_var);
replace_text("#optionsInput1", ssl_offloading_var);
replace_text("#optionsInput2", ssl_offloading_var);
@ -914,7 +963,8 @@ function createSsl(TabId, proxy) {
$( "#tabs" ).tabs( "option", "active", TabId );
$( "#https-hide-"+proxy).show("fast");
$('#https-'+proxy).prop( "checked", true );
$('#https-'+proxy).checkboxradio("refresh")
$('#https-'+proxy).checkboxradio("refresh");
$("#path-cert-"+proxy ).attr('required',true);
history.pushState('Add'+proxy, 'Add'+proxy, 'add.py#'+proxy)
}
function createHttps(TabId, proxy) {
@ -1083,8 +1133,10 @@ function change_select_acceleration(id) {
token: $('#token').val()
},
type: "POST",
success: function( data ) {
if(parseFloat(data) < parseFloat('1.8')) {
success: function( data ) {
data = data.replace(/\s+/g,' ');
console.log('"'+data+'"');
if(parseFloat(data) < parseFloat('1.8') || data == ' ') {
$("#cache"+id).checkboxradio( "disable" );
} else {
$("#cache"+id).checkboxradio( "enable" );

@ -91,6 +91,15 @@ $( function() {
$(this).parent().find('a').css('padding-left', '20px');
$(this).find('a').css('padding-left', '30px');
$(this).find('a').css('border-left', '4px solid #5D9CEB');
} else if(cur_url[0] == 'add.py' && cur_url[1].split('&')[0] == 'service=nginx#ssl' && link2 == 'add.py?service=nginx#ssl'){
$(this).parent().css('display', 'contents');
$(this).parent().css('font-size', '13px');
$(this).parent().css('top', '0');
$(this).parent().css('left', '0');
$(this).parent().children().css('margin-left', '-20px');
$(this).parent().find('a').css('padding-left', '20px');
$(this).find('a').css('padding-left', '30px');
$(this).find('a').css('border-left', '4px solid #5D9CEB');
}
});
});

@ -822,7 +822,7 @@ label {
}
.ajax-server {
margin: 25px;
margin-left: 440px;
margin-left: 757px;
margin-bottom: 0;
width: 778px;
display: none;

Loading…
Cancel
Save