mirror of https://github.com/Aidaho12/haproxy-wi
parent
392485c046
commit
082467ce50
12
app/funct.py
12
app/funct.py
|
@ -144,11 +144,17 @@ def ssh_connect(serv, **kwargs):
|
|||
from paramiko import SSHClient
|
||||
import sql
|
||||
fullpath = get_config_var('main', 'fullpath')
|
||||
ssh_enable = ''
|
||||
ssh_port = ''
|
||||
ssh_user_name = ''
|
||||
ssh_user_password = ''
|
||||
|
||||
for sshs in sql.select_ssh(serv=serv):
|
||||
ssh_enable = sshs[3]
|
||||
ssh_user_name = sshs[4]
|
||||
ssh_user_password = sshs[5]
|
||||
ssh_key_name = fullpath+'/keys/%s.pem' % sshs[2]
|
||||
|
||||
servers = sql.select_servers(server=serv)
|
||||
for server in servers:
|
||||
ssh_port = server[10]
|
||||
|
@ -407,7 +413,7 @@ def ssh_command(serv, commands, **kwargs):
|
|||
|
||||
for command in commands:
|
||||
try:
|
||||
stdin, stdout, stderr = ssh.exec_command(command,get_pty=True)
|
||||
stdin, stdout, stderr = ssh.exec_command(command, get_pty=True)
|
||||
except:
|
||||
continue
|
||||
|
||||
|
@ -431,7 +437,7 @@ def ssh_command(serv, commands, **kwargs):
|
|||
try:
|
||||
ssh.close()
|
||||
except:
|
||||
print("<div class='alert alert-danger' style='margin: 0;'>"+str(ssh)+"</div>")
|
||||
print("<div class='alert alert-danger' style='margin: 0;'>"+str(ssh)+"<a title='Close' id='errorMess'><b>X</b></a></div>")
|
||||
pass
|
||||
|
||||
def escape_html(text):
|
||||
|
@ -485,4 +491,4 @@ def get_files(dir = get_config_var('configs', 'haproxy_save_configs_dir'), forma
|
|||
return files
|
||||
|
||||
def get_key(item):
|
||||
return item[0]
|
||||
return item[0]
|
|
@ -32,6 +32,12 @@ if form.getvalue('getcerts') is not None and serv is not None:
|
|||
funct.ssh_command(serv, commands, ip="1")
|
||||
except:
|
||||
print('<div class="alert alert-danger" style="margin:0">Can not connect to the server</div>')
|
||||
|
||||
if form.getvalue('checkSshConnect') is not None and serv is not None:
|
||||
try:
|
||||
funct.ssh_command(serv, ["ls -1t"])
|
||||
except:
|
||||
print('<div class="alert alert-danger" style="margin:0">Can not connect to the server</div>')
|
||||
|
||||
if form.getvalue('getcert') is not None and serv is not None:
|
||||
id = form.getvalue('getcert')
|
||||
|
@ -486,8 +492,7 @@ if form.getvalue('metrics'):
|
|||
for key, value in p.items():
|
||||
plots.append(value)
|
||||
|
||||
plots_sorted = sorted(plots, key=funct.get_key)
|
||||
grid = gridplot(plots_sorted, ncols=2, plot_width=800, plot_height=250, toolbar_location = "left", toolbar_options=dict(logo=None))
|
||||
grid = gridplot(plots, ncols=2, plot_width=800, plot_height=250, toolbar_location = "left", toolbar_options=dict(logo=None))
|
||||
show(grid)
|
||||
|
||||
if form.getvalue('waf_metrics'):
|
||||
|
@ -556,8 +561,8 @@ if form.getvalue('waf_metrics'):
|
|||
plots = []
|
||||
for key, value in p.items():
|
||||
plots.append(value)
|
||||
plots_sorted = sorted(plots, key=funct.get_key)
|
||||
grid = gridplot(plots_sorted, ncols=2, plot_width=800, plot_height=250, toolbar_location = "left", toolbar_options=dict(logo=None))
|
||||
|
||||
grid = gridplot(plots, ncols=2, plot_width=800, plot_height=250, toolbar_location = "left", toolbar_options=dict(logo=None))
|
||||
show(grid)
|
||||
|
||||
if form.getvalue('get_hap_v'):
|
||||
|
|
|
@ -250,6 +250,7 @@
|
|||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
<button onclick="checkSshConnect('{{server.2}}')">Check SSH</button>
|
||||
</td>
|
||||
<td>
|
||||
{% if server.11 != "None" %}
|
||||
|
|
|
@ -76,6 +76,7 @@
|
|||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
<button onclick="checkSshConnect('{{server.2}}')">Check SSH</button>
|
||||
</td>
|
||||
<td>
|
||||
{% if server.11 != "None" %}
|
||||
|
|
|
@ -56,10 +56,10 @@
|
|||
{% if user %}
|
||||
<li><a href=/app/config.py title="Working with Haproxy Configs" class="edit head-submenu">Configs</a> </li>
|
||||
{% if role <= 2 %}
|
||||
<li><a href=/app/add.py#listner title="Add single listen" class="add head-submenu">Add listen</a></li>
|
||||
<li><a href=/app/add.py#frontend title="Add single frontend" class="add head-submenu">Add frontend</a></li>
|
||||
<li><a href=/app/add.py#backend title="Add single backend" class="add head-submenu">Add backend</a></li>
|
||||
<li><a href=/app/add.py#ssl title="Upload SSL cert" class="cert head-submenu">SSL</a></li>
|
||||
<li><a href=/app/add.py#listner title="Add single listen" class="add head-submenu" id="add1">Add listen</a></li>
|
||||
<li><a href=/app/add.py#frontend title="Add single frontend" class="add head-submenu" id="add2">Add frontend</a></li>
|
||||
<li><a href=/app/add.py#backend title="Add single backend" class="add head-submenu" id="add3">Add backend</a></li>
|
||||
<li><a href=/app/add.py#ssl title="Upload SSL cert" class="cert head-submenu" id="add4">SSL</a></li>
|
||||
<li><a href=/app/lists.py title="Manage black and white lists" class="lists head-submenu">Lists</a> </li>
|
||||
<li><a href=/app/waf.py title="Web application firewall" class="waf head-submenu">WAF</a> </li>
|
||||
<li><a href=/app/ihap.py title="Installation HAProxy" class="hap head-submenu">Installation</a> </li>
|
||||
|
@ -99,7 +99,7 @@
|
|||
</ul>
|
||||
</nav>
|
||||
<div class="copyright-menu">
|
||||
HAproxy-WI v3.2.10
|
||||
HAproxy-WI v3.2.11
|
||||
<br>
|
||||
<a href="https://www.patreon.com/haproxy_wi" title="Donate" target="_blank" style="color: #fff; margin-left: 30px; color: red;" class="patreon"> Patreon</a>
|
||||
</div>
|
||||
|
|
|
@ -175,6 +175,7 @@
|
|||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
<button onclick="checkSshConnect('{{server.2}}')">Check SSH</button>
|
||||
</td>
|
||||
<td>
|
||||
{% if server.11 != "None" %}
|
||||
|
@ -431,6 +432,7 @@
|
|||
setTimeout(function() {
|
||||
$("input[type=checkbox]").checkboxradio( "disable" );
|
||||
$("select").selectmenu( "disable" );
|
||||
$("button").button( "disable" );
|
||||
$("input").attr( "readonly", "readonly" );
|
||||
$('.delete').remove()
|
||||
}, 500 );
|
||||
|
|
23
inc/users.js
23
inc/users.js
|
@ -880,4 +880,27 @@ function showApacheLog(serv) {
|
|||
window.history.pushState("Logs", "Logs", cur_url[0]+"?serv="+$("#serv").val()+"&rows1="+$('#rows').val()+"&grep="+$("#grep").val());
|
||||
}
|
||||
} );
|
||||
}
|
||||
function checkSshConnect(ip) {
|
||||
$.ajax( {
|
||||
url: "options.py",
|
||||
data: {
|
||||
checkSshConnect: 1,
|
||||
serv: ip,
|
||||
token: $('#token').val()
|
||||
},
|
||||
type: "GET",
|
||||
success: function( data ) {
|
||||
if (data.indexOf('danger') != '-1') {
|
||||
$("#ajax").html(data);
|
||||
} else {
|
||||
$("#ajax").html("<div class='alert alert-success' style='margin: 0;'>Connect accept<a title='Close' id='errorMess'><b>X</b></a></div>");
|
||||
}
|
||||
$('#errorMess').click(function() {
|
||||
$('#error').remove();
|
||||
$('.alert-danger').remove();
|
||||
$('.alert-success').remove();
|
||||
});
|
||||
}
|
||||
} );
|
||||
}
|
Loading…
Reference in New Issue