Pavel Loginov 2020-04-06 18:38:58 +02:00
parent a073e7689c
commit 4258623548
6 changed files with 153 additions and 39 deletions

View File

@ -94,13 +94,15 @@
<td></td>
{% else %}
<td class="padding10 first-collumn">
<input type="text" id="name-{{ group.0 }}" value="{{ group.1 }}" class="form-control">
{% set id = 'name-' + group.0|string() %}
{{ input(id, value=group.1) }}
</td>
<td style="width: 100%;">
{% set id = 'descript-' + group.0|string() %}
{% if group.2 != "None" %}
<input type="text" id="descript-{{ group.0 }}" value="{{ group.2 }}" class="form-control" size="60">
{{ input(id, value=group.2, size='60') }}
{% else %}
<input type="text" id="descript-{{ group.0 }}" value="" class="form-control" size="60">
{{ input(id, value='', size='60') }}
{% endif %}
</td>
<td>
@ -158,13 +160,15 @@
{% for server in servers %}
<tr id="server-{{server.0}}" class="{{ loop.cycle('odd', 'even') }}">
<td class="padding10 first-collumn">
<input type="text" id="hostname-{{server.0}}" value="{{server.1}}" class="form-control">
{% set id = 'hostname-' + server.0|string() %}
{{ input(id, value=server.1, size='10') }}
</td>
<td>
<span id="ip-{{server.0}}" style="margin-right: 6px;">{{server.2}}</span>
</td>
<td>
<input type="text" id="port-{{server.0}}" value="{{server.10}}" size="1" class="form-control">
{% set id = 'port-' + server.0|string() %}
{{ input(id, value=server.10, size='2') }}
</td>
<td>
<select id="servergroup-{{server.0}}" name="servergroup-{{server.0}}">
@ -210,7 +214,8 @@
{% for ssh in sshs %}
<tr style="width: 50%;" id="ssh-table-{{ssh.0}}" class="{{ loop.cycle('odd', 'even') }}">
<td class="first-collumn">
<input type="text" id="ssh_name-{{ssh.0}}" class="form-control" value="{{ssh.1}}" style="margin-bottom: 23px;">
{% set id = 'ssh_name-' + ssh.0|string() %}
{{ input(id, value=ssh.1, size='10') }}
</td>
<td class="first-collumn" valign="top" style="padding-top: 15px;">
{% if ssh.2 == 1 %}
@ -232,12 +237,13 @@
</td>
<td style="padding-top: 15px;">
<p>
<input type="text" id="ssh_user-{{ssh.0}}" class="form-control" value="{{ssh.3}}">
{% set id = 'ssh_user-' + ssh.0|string() %}
{{ input(id, value=ssh.3, size='10') }}
</p>
{% if ssh.2 == 1 %}
<input type="password" id="ssh_pass-{{ssh.0}}" class="form-control" value="{{ssh.4}}" style="display: none;">
<input type="password" id="ssh_pass-{{ssh.0}}" class="form-control" value="{{ssh.4}}" style="display: none;" autocomplete="new-password">
{% else %}
<input type="password" id="ssh_pass-{{ssh.0}}" class="form-control" value="{{ssh.4}}">
<input type="password" id="ssh_pass-{{ssh.0}}" class="form-control" value="{{ssh.4}}" autocomplete="new-password">
{% endif %}
<br>
</td>
@ -328,10 +334,12 @@
{% for telegram in telegrams %}
<tr id="telegram-table-{{telegram.0}}" class="{{ loop.cycle('odd', 'even') }}">
<td class="first-collumn" style="padding-top: 20px;">
<input type="text" id="telegram-token-{{telegram.0}}" class="form-control" value="{{telegram.1}}" style="margin-bottom: 23px;">
{% set id = 'telegram-token-' + telegram.0|string() %}
{{ input(id, value=telegram.1, style="margin-bottom: 23px;") }}
</td>
<td>
<input type="text" id="telegram-chanel-{{telegram.0}}" class="form-control" value="{{telegram.2}}">
{% set id = 'telegram-token-' + telegram.0|string() %}
{{ input(id, value=telegram.2) }}
</td>
<td>
<select id="telegramgroup-{{telegram.0}}" name="telegramgroup-{{telegram.0}}">

View File

@ -2,7 +2,10 @@
{% if name == '' %}
{% set name = id %}
{% endif %}
<input type="{{ type }}" name="{{name}}" value="{{ value|e }}" id="{{ id }}" size="{{size}}" style="{{style}}" {{readonly}} {{required}} placeholder="{{placeholder}}" title="{{title}}" class="{{class}}" />
{% if readonly == '' %}
{% set readonly = 'readonly onfocus=this.removeAttribute(\'readonly\');' %}
{% endif %}
<input type="{{ type }}" name="{{name}}" value="{{ value|e }}" id="{{ id }}" size="{{size}}" style="{{style}}" {{readonly}} {{required}} placeholder="{{placeholder}}" title="{{title}}" class="{{class}}" autocomplete="off" />
{%- endmacro %}
{%- macro checkbox(id, name='', checked='', title='', value='', desc='') -%}

View File

@ -72,7 +72,7 @@
</td>
</tr>
</table>
<table class="overview-wi" style="height: 162;">
<table class="overview-wi" style="height: 160;">
<tr class="overviewHead" style="height: 40px;">
<th class="padding10 first-collumn-wi" colspan=4>
Tools status

View File

@ -87,14 +87,16 @@
{% do ssh_group.append(server.3) %}
<tr id="server-{{server.0}}" class="{{ loop.cycle('odd', 'even') }}">
<td class="padding10 first-collumn">
<input type="text" id="hostname-{{server.0}}" value="{{server.1}}" class="form-control">
{% set id = 'hostname-' + server.0|string() %}
{{ input(id, value=server.1, size='10') }}
</td>
<td>
<span id="ip-{{server.0}}" style="margin-right: 6px;">{{server.2}}</span>
<input type="hidden" id="servergroup-{{server.0}}" name="servergroup-{{server.0}}" value="{{ group }}" >
</td>
<td>
<input type="text" id="port-{{server.0}}" value="{{server.10}}" size="1" class="form-control">
{% set id = 'port-' + server.0|string() %}
{{ input(id, value=server.10, size='2') }}
</td>
{% include 'include/admin_servers.html' %}
</tr>
@ -127,7 +129,8 @@
{% if ssh.5|string() == group %}
<tr style="width: 50%;" id="ssh-table-{{ssh.0}}" class="{{ loop.cycle('odd', 'even') }}">
<td class="first-collumn">
<input type="text" id="ssh_name-{{ssh.0}}" class="form-control" value="{{ssh.1}}" style="margin-bottom: 23px;">
{% set id = 'ssh_name-' + ssh.0|string() %}
{{ input(id, value=ssh.1, size='10') }}
</td>
<td class="first-collumn" valign="top" style="padding-top: 15px;">
{% if ssh.2 == 1 %}
@ -138,12 +141,13 @@
</td>
<td style="padding-top: 15px;">
<p>
<input type="text" id="ssh_user-{{ssh.0}}" class="form-control" value="{{ssh.3}}">
{% set id = 'ssh_user-' + ssh.0|string() %}
{{ input(id, value=ssh.3, size='10') }}
</p>
{% if ssh.2 == 1 %}
<input type="password" id="ssh_pass-{{ssh.0}}" class="form-control" value="{{ssh.4}}" style="display: none;">
<input type="password" id="ssh_pass-{{ssh.0}}" class="form-control" value="{{ssh.4}}" style="display: none;" autocomplete="new-password">
{% else %}
<input type="password" id="ssh_pass-{{ssh.0}}" class="form-control" value="{{ssh.4}}">
<input type="password" id="ssh_pass-{{ssh.0}}" class="form-control" value="{{ssh.4}}" autocomplete="new-password">
{% endif %}
<br>
</td>
@ -228,10 +232,12 @@
{% if telegram.3|string() == group %}
<tr style="width: 50%;" id="telegram-table-{{telegram.0}}" class="{{ loop.cycle('odd', 'even') }}">
<td class="first-collumn" style="padding-top: 20px;">
<input type="text" id="telegram-token-{{telegram.0}}" class="form-control" value="{{telegram.1}}" style="margin-bottom: 23px;">
{% set id = 'telegram-token-' + telegram.0|string() %}
{{ input(id, value=telegram.1, style="margin-bottom: 23px;") }}
</td>
<td>
<input type="text" id="telegram-chanel-{{telegram.0}}" class="form-control" value="{{telegram.2}}">
{% set id = 'telegram-chanel-' + telegram.0|string() %}
{{ input(id, value=telegram.2) }}
</td>
<td>
<a class="delete" onclick="confirmDeleteSsh({{telegram.0}})" style="cursor: pointer;"></a>

View File

@ -30,7 +30,7 @@ def main():
try:
readstats = subprocess.check_output(["echo show stat | nc "+serv[0]+" "+port], shell=True)
except CalledProcessError as e:
alert = "Try start HAProxy serivce at " + serv[0]
alert = "Try to start HAProxy serivce on " + serv[0]
funct.logging("localhost", " "+alert, keep_alive=1)
start_command = []
@ -47,7 +47,7 @@ def main():
if __name__ == "__main__":
funct.logging("localhost", " Keep alive service started", keep_alive=1)
funct.logging("localhost", " Keep alive service is started", keep_alive=1)
killer = GracefulKiller()
while True:
@ -57,4 +57,4 @@ if __name__ == "__main__":
if killer.kill_now:
break
funct.logging("localhost", " Keep alive service shutdown", keep_alive=1)
funct.logging("localhost", " Keep alive service is shutdown", keep_alive=1)

View File

@ -50,6 +50,7 @@ $( function() {
autoFocus: true,
minLength: -1
});
var wait_mess = '<div class="alert alert-warning">Please don\'t close and don\'t represh page. Wait until the work is completed. This may take some time </div>'
var ipformat = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
$('#create').click(function() {
var hap = 0;
@ -73,7 +74,7 @@ $( function() {
} else if ($("#master").val() == $("#slave").val() ){
$("#ajax").html('<div class="alert alert-danger">Master and slave must be diff servers</div>')
} else {
$("#ajax").html('<div class="alert alert-warning">Please don\'t close and don\'t represh page. Wait until the work is completed. This may take some time </div>');
$("#ajax").html(wait_mess);
$.ajax( {
url: "options.py",
data: {
@ -119,7 +120,7 @@ $( function() {
} else if(! $("#vrrp-ip-add").val().match(ipformat)) {
$("#ajax").html('<div class="alert alert-danger">Please enter IP in "VRRP IP" field</div>')
} else {
$("#ajax").html('<div class="alert alert-warning">Please don\'t close and don\'t represh page. Wait until the work is completed. This may take some time </div>');
$("#ajax").html(wait_mess);
$.ajax( {
url: "options.py",
data: {
@ -153,7 +154,7 @@ $( function() {
if ($('#syn_flood').is(':checked')) {
syn_flood = '1';
}
$("#ajax").html('<div class="alert alert-warning">Please don\'t close and don\'t represh page. Wait until the work is completed. This may take some time </div>');
$("#ajax").html(wait_mess);
$.ajax( {
url: "options.py",
data: {
@ -164,6 +165,41 @@ $( function() {
},
type: "POST",
success: function( data ) {
data = data.replace(/\s+/g,' ');
if (data.indexOf('error') != '-1' || data.indexOf('FAILED') != '-1') {
$("#ajax").html('<div class="alert alert-danger">'+data+'</div>');
} else if (data.indexOf('success') != '-1' ){
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax").html('<div class="alert alert-success">'+data+'</div>');
} else if (data.indexOf('Info') != '-1' ){
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax").html('<div class="alert alert-info">'+data+'</div>');
} else {
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax").html('<div class="alert alert-info">'+data+'</div>');
}
}
} );
});
$('#nginx_install').click(function() {
$("#ajax").html('')
var syn_flood = 0;
if ($('#nginx_syn_flood').is(':checked')) {
syn_flood = '1';
}
$("#ajax").html(wait_mess);
$.ajax( {
url: "options.py",
data: {
install_nginx: $('#nginxaddserv').val(),
syn_flood: syn_flood,
token: $('#token').val()
},
type: "POST",
success: function( data ) {
data = data.replace(/\s+/g,' ');
if (data.indexOf('error') != '-1' || data.indexOf('FAILED') != '-1') {
$("#ajax").html('<div class="alert alert-danger">'+data+'</div>');
@ -183,18 +219,43 @@ $( function() {
}
} );
});
$('#nginx_install').click(function() {
$('#grafna_install').click(function() {
$("#ajax").html('')
var syn_flood = 0;
if ($('#nginx_syn_flood').is(':checked')) {
syn_flood = '1';
}
$("#ajax").html('<div class="alert alert-warning">Please don\'t close and don\'t represh page. Wait until the work is completed. This may take some time </div>');
$("#ajax").html(wait_mess);
$.ajax( {
url: "options.py",
data: {
install_nginx: $('#nginxaddserv').val(),
syn_flood: syn_flood,
install_grafana: '1',
token: $('#token').val()
},
type: "POST",
success: function( data ) {
data = data.replace(/\s+/g,' ');
if (data.indexOf('FAILED') != '-1') {
$("#ajax").html('<div class="alert alert-danger">'+data+'</div>');
} else if (data.indexOf('success') != '-1' ){
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax").html('<div class="alert alert-success">'+data+'</div>');
} else if (data.indexOf('Info') != '-1' ){
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax").html('<div class="alert alert-info">'+data+'</div>');
} else {
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax").html('<div class="alert alert-info">'+data+'</div>');
}
}
} );
});
$('#haproxy_exp_install').click(function() {
$("#ajax").html('')
$("#ajax").html(wait_mess);
$.ajax( {
url: "options.py",
data: {
haproxy_exp_install: $('#haproxy_exp_addserv').val(),
token: $('#token').val()
},
type: "POST",
@ -205,7 +266,41 @@ $( function() {
} else if (data.indexOf('success') != '-1' ){
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax").html('<div class="alert alert-success">'+data+'</div>');
$("#ajax").html('<div class="alert alert-success">'+data+'</div>');
$('#cur_haproxy_exp_ver').text('HAProxy expoter is installed');
$('#haproxy_exp_install').text('Update');
} else if (data.indexOf('Info') != '-1' ){
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax").html('<div class="alert alert-info">'+data+'</div>');
} else {
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax").html('<div class="alert alert-info">'+data+'</div>');
}
}
} );
});
$('#nginx_exp_install').click(function() {
$("#ajax").html('')
$("#ajax").html(wait_mess);
$.ajax( {
url: "options.py",
data: {
nginx_exp_install: $('#nginx_exp_addserv').val(),
token: $('#token').val()
},
type: "POST",
success: function( data ) {
data = data.replace(/\s+/g,' ');
if (data.indexOf('error') != '-1' || data.indexOf('FAILED') != '-1') {
$("#ajax").html('<div class="alert alert-danger">'+data+'</div>');
} else if (data.indexOf('success') != '-1' ){
$('.alert-danger').remove();
$('.alert-warning').remove();
$("#ajax").html('<div class="alert alert-success">'+data+'</div>');
$('#cur_nginx_exp_ver').text('Nginx expoter is installed');
$('#nginx_exp_install').text('Update');
} else if (data.indexOf('Info') != '-1' ){
$('.alert-danger').remove();
$('.alert-warning').remove();
@ -1206,10 +1301,8 @@ function updateServer(id) {
enable = '1';
}
var servergroup = $('#servergroup-'+id+' option:selected' ).val();
console.log(cur_url[0])
if (cur_url[0].split('#')[0] == "servers.py") {
servergroup = $('#new-server-group-add').val();
console.log('1')
}
console.log(servergroup)
$.ajax( {
@ -1280,12 +1373,16 @@ function updateSSH(id) {
if ($('#ssh_enable-'+id).is(':checked')) {
ssh_enable = '1';
}
var group = $('#sshgroup-'+id).val();
if (cur_url[0].split('#')[0] == "servers.py") {
group = $('#new-server-group-add').val();
}
$.ajax( {
url: "options.py",
data: {
updatessh: 1,
name: $('#ssh_name-'+id).val(),
group: $('#sshgroup-'+id).val(),
group: group,
ssh_enable: ssh_enable,
ssh_user: $('#ssh_user-'+id).val(),
ssh_pass: $('#ssh_pass-'+id).val(),