mirror of https://github.com/Aidaho12/haproxy-wi
parent
2caca917b7
commit
639fafd97d
|
@ -901,7 +901,13 @@ def haproxy_wi_log(**kwargs):
|
||||||
if log_file == value:
|
if log_file == value:
|
||||||
return key
|
return key
|
||||||
else:
|
else:
|
||||||
cmd = "find "+log_path+"/haproxy-wi-* -type f -exec stat --format '%Y :%y %n' '{}' \; | sort -nr | cut -d: -f2- | head -1 |awk '{print $4}' |xargs tail|sort -r"
|
user_group_id = get_user_group(id=1)
|
||||||
|
if user_group_id != 1:
|
||||||
|
user_group = get_user_group()
|
||||||
|
group_grep = '|grep "group: '+ user_group +'"'
|
||||||
|
else:
|
||||||
|
group_grep = ''
|
||||||
|
cmd = "find "+log_path+"/haproxy-wi-* -type f -exec stat --format '%Y :%y %n' '{}' \; | sort -nr | cut -d: -f2- | head -1 |awk '{print $4}' |xargs tail"+group_grep+"|sort -r"
|
||||||
output, stderr = subprocess_execute(cmd)
|
output, stderr = subprocess_execute(cmd)
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
|
@ -1910,7 +1910,7 @@ def insert_smon(server, port, enable, proto, uri, body, group, desc, telegram, u
|
||||||
def select_smon(user_group, **kwargs):
|
def select_smon(user_group, **kwargs):
|
||||||
con, cur = get_cur()
|
con, cur = get_cur()
|
||||||
|
|
||||||
if user_group == '1':
|
if user_group == 1:
|
||||||
user_group = ''
|
user_group = ''
|
||||||
else:
|
else:
|
||||||
if kwargs.get('ip'):
|
if kwargs.get('ip'):
|
||||||
|
@ -2133,7 +2133,7 @@ def response_time(time, id):
|
||||||
def smon_list(user_group):
|
def smon_list(user_group):
|
||||||
con, cur = get_cur()
|
con, cur = get_cur()
|
||||||
|
|
||||||
if user_group == '1':
|
if user_group == 1:
|
||||||
user_group = ''
|
user_group = ''
|
||||||
else:
|
else:
|
||||||
user_group = "where user_group='%s'" % user_group
|
user_group = "where user_group='%s'" % user_group
|
||||||
|
|
|
@ -176,93 +176,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="ssh">
|
<div id="ssh">
|
||||||
<table id="ssh_enable_table" class="overview">
|
{% include 'include/admin_ssh.html' %}
|
||||||
<tr class="overviewHead" style="width: 50%;">
|
|
||||||
<td class="padding10 first-collumn" style="width: 15%;">
|
|
||||||
<span title="It's just name alias. This alias will be use in 'Servers' page for choose credentials">Name<span>
|
|
||||||
</td>
|
|
||||||
<td class="padding10 first-collumn" style="width: 25%;">
|
|
||||||
<span title="If it is enabled, the key will be used, if turned off - the password. Do not forget to download the keys to all servers or install the sudo without a password">SSH key</span>
|
|
||||||
</td>
|
|
||||||
<td style="width: 25%;">Group</td>
|
|
||||||
<td style="width: 100%;">
|
|
||||||
<span title="Enter SSH user name. If SSH key disabled, enter password for SSH user">Credentials</span>
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
{% for ssh in sshs %}
|
|
||||||
<tr style="width: 50%;" id="ssh-table-{{ssh.0}}" class="{{ loop.cycle('odd', 'even') }}">
|
|
||||||
<td class="first-collumn">
|
|
||||||
{% 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 %}
|
|
||||||
<label for="ssh_enable-{{ssh.0}}">Enable SSH key</label><input type="checkbox" id="ssh_enable-{{ssh.0}}" checked>
|
|
||||||
{% else %}
|
|
||||||
<label for="ssh_enable-{{ssh.0}}">Enable SSH key</label><input type="checkbox" id="ssh_enable-{{ssh.0}}">
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<select id="sshgroup-{{ssh.0}}" name="sshgroup-{{ssh.0}}">
|
|
||||||
{% for group in groups %}
|
|
||||||
{% if ssh.5 == group.0 %}
|
|
||||||
<option value="{{ group.0 }}" selected>{{ group.1 }}</option>
|
|
||||||
{% else %}
|
|
||||||
<option value="{{ group.0 }}">{{ group.1 }}</option>
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
</select>
|
|
||||||
</td>
|
|
||||||
<td style="padding-top: 15px;">
|
|
||||||
<p>
|
|
||||||
{% set id = 'ssh_user-' + ssh.0|string() %}
|
|
||||||
{{ input(id, value=ssh.3, title='SSH user name') }}
|
|
||||||
</p>
|
|
||||||
{% if ssh.2 == 1 %}
|
|
||||||
<input type="password" id="ssh_pass-{{ssh.0}}" class="form-control" placeholder="*****" style="display: none;" autocomplete="new-password">
|
|
||||||
{% else %}
|
|
||||||
<input type="password" id="ssh_pass-{{ssh.0}}" class="form-control" placeholder="*****" autocomplete="new-password">
|
|
||||||
{% endif %}
|
|
||||||
<br>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<a class="delete" onclick="confirmDeleteSsh({{ssh.0}})" title="Delete SSH credentials {{ssh.1}}" style="cursor: pointer;"></a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</table>
|
|
||||||
<br /><span class="add-button" title="Add ssh" id="add-ssh-button">+ Add</span>
|
|
||||||
<br /><br />
|
|
||||||
<table id="ssh_key">
|
|
||||||
<tr class="overviewHead" style="width: 50%;">
|
|
||||||
<td class="padding10 first-collumn" style="width: 25%;">Upload SSH Key</td>
|
|
||||||
<td>
|
|
||||||
<span title="Private key. Note: The public key must be pre-installed on all servers to which you plan to connect">Key</span>
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
<tr style="width: 50%;">
|
|
||||||
<td class="first-collumn" valign="top" style="padding-top: 15px;">
|
|
||||||
<select id="ssh-key-name">
|
|
||||||
<option disabled selected>Choose credentials</option>
|
|
||||||
{% for ssh in sshs %}
|
|
||||||
<option value={{ssh.1}}>{{ssh.1}}</option>
|
|
||||||
{% endfor %}
|
|
||||||
</select>
|
|
||||||
</td>
|
|
||||||
<td style="padding-top: 15px;">
|
|
||||||
<textarea id="ssh_cert" cols="50" rows="5"></textarea><br /><br />
|
|
||||||
<a class="ui-button ui-widget ui-corner-all" id="ssh_key_upload" title="Upload ssh key" onclick="uploadSsh()">Upload</a>
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<div id="ajax-ssh"></div>
|
|
||||||
<div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;">
|
|
||||||
You can read the description of all parameters <a href="https://haproxy-wi.org/description.py?description=creds" title="Servers description" target="_blank">here</a>
|
|
||||||
or watch video <a href="https://haproxy-wi.org/description.py?description=setup" title="How to setup servers, group and SSH credentials" target="_blank">here</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="checker">
|
<div id="checker">
|
||||||
|
|
|
@ -0,0 +1,91 @@
|
||||||
|
<table id="ssh_enable_table" class="overview">
|
||||||
|
<tr class="overviewHead" style="width: 50%;">
|
||||||
|
<td class="padding10 first-collumn" style="width: 15%;">
|
||||||
|
<span title="It's just name alias. This alias will be use in 'Servers' page for choose credentials">Name<span>
|
||||||
|
</td>
|
||||||
|
<td class="padding10 first-collumn" style="width: 25%;">
|
||||||
|
<span title="If it is enabled, the key will be used, if turned off - the password. Do not forget to download the keys to all servers or install the sudo without a password">SSH key</span>
|
||||||
|
</td>
|
||||||
|
{% if page != "servers.py" %}
|
||||||
|
<td style="width: 25%;">Group</td>
|
||||||
|
{% endif %}
|
||||||
|
<td style="width: 100%;">
|
||||||
|
<span title="Enter SSH user name. If SSH key disabled, enter password for SSH user">Credentials</span>
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
{% for ssh in sshs %}
|
||||||
|
<tr style="width: 50%;" id="ssh-table-{{ssh.0}}" class="{{ loop.cycle('odd', 'even') }}">
|
||||||
|
<td class="first-collumn">
|
||||||
|
{% set id = 'ssh_name-' + ssh.0|string() %}
|
||||||
|
{{ input(id, value=ssh.1, size='15') }}
|
||||||
|
</td>
|
||||||
|
<td class="first-collumn" valign="top" style="padding-top: 15px;">
|
||||||
|
{% if ssh.2 == 1 %}
|
||||||
|
<label for="ssh_enable-{{ssh.0}}">Enable SSH key</label><input type="checkbox" id="ssh_enable-{{ssh.0}}" checked>
|
||||||
|
{% else %}
|
||||||
|
<label for="ssh_enable-{{ssh.0}}">Enable SSH key</label><input type="checkbox" id="ssh_enable-{{ssh.0}}">
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
{% if page != "servers.py" %}
|
||||||
|
<td>
|
||||||
|
<select id="sshgroup-{{ssh.0}}" name="sshgroup-{{ssh.0}}">
|
||||||
|
{% for group in groups %}
|
||||||
|
{% if ssh.5 == group.0 %}
|
||||||
|
<option value="{{ group.0 }}" selected>{{ group.1 }}</option>
|
||||||
|
{% else %}
|
||||||
|
<option value="{{ group.0 }}">{{ group.1 }}</option>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
{% endif %}
|
||||||
|
<td style="padding-top: 15px;">
|
||||||
|
<p>
|
||||||
|
{% set id = 'ssh_user-' + ssh.0|string() %}
|
||||||
|
{{ input(id, value=ssh.3, title='SSH user name') }}
|
||||||
|
</p>
|
||||||
|
{% if ssh.2 == 1 %}
|
||||||
|
<input type="password" id="ssh_pass-{{ssh.0}}" class="form-control" placeholder="*****" style="display: none;" autocomplete="new-password">
|
||||||
|
{% else %}
|
||||||
|
<input type="password" id="ssh_pass-{{ssh.0}}" class="form-control" placeholder="*****" autocomplete="new-password">
|
||||||
|
{% endif %}
|
||||||
|
<br>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a class="delete" onclick="confirmDeleteSsh({{ssh.0}})" title="Delete SSH credentials {{ssh.1}}" style="cursor: pointer;"></a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
<br /><span class="add-button" title="Add ssh" id="add-ssh-button">+ Add</span>
|
||||||
|
<br /><br />
|
||||||
|
<table id="ssh_key">
|
||||||
|
<tr class="overviewHead" style="width: 50%;">
|
||||||
|
<td class="padding10 first-collumn" style="width: 25%;">Upload SSH Key</td>
|
||||||
|
<td>
|
||||||
|
<span title="Private key. Note: The public key must be pre-installed on all servers to which you plan to connect">Key</span>
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr style="width: 50%;">
|
||||||
|
<td class="first-collumn" valign="top" style="padding-top: 15px;">
|
||||||
|
<select id="ssh-key-name">
|
||||||
|
<option disabled selected>Choose credentials</option>
|
||||||
|
{% for ssh in sshs %}
|
||||||
|
<option value={{ssh.1}}>{{ssh.1}}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
<td style="padding-top: 15px;">
|
||||||
|
<textarea id="ssh_cert" cols="50" rows="5"></textarea><br /><br />
|
||||||
|
<a class="ui-button ui-widget ui-corner-all" id="ssh_key_upload" title="Upload ssh key" onclick="uploadSsh()">Upload</a>
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<div id="ajax-ssh"></div>
|
||||||
|
<div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;">
|
||||||
|
You can read the description of all parameters <a href="https://haproxy-wi.org/description.py?description=creds" title="Servers description" target="_blank">here</a>
|
||||||
|
or watch video <a href="https://haproxy-wi.org/description.py?description=setup" title="How to setup servers, group and SSH credentials" target="_blank">here</a>
|
||||||
|
</div>
|
|
@ -331,7 +331,8 @@
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
{% endif %}
|
||||||
|
{% if role <= 2 %}
|
||||||
<table class="overview-wi">
|
<table class="overview-wi">
|
||||||
<tr class="overviewHead">
|
<tr class="overviewHead">
|
||||||
<td class="padding10 first-collumn-wi">
|
<td class="padding10 first-collumn-wi">
|
||||||
|
|
|
@ -65,8 +65,8 @@
|
||||||
</table>
|
</table>
|
||||||
<br /><span class="add-button" title="Add user" id="add-user-button">+ Add</span>
|
<br /><span class="add-button" title="Add user" id="add-user-button">+ Add</span>
|
||||||
<br /><br />
|
<br /><br />
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="servers">
|
<div id="servers">
|
||||||
<table class="overview" id="ajax-servers">
|
<table class="overview" id="ajax-servers">
|
||||||
<tr class="overviewHead">
|
<tr class="overviewHead">
|
||||||
|
@ -119,85 +119,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="ssh">
|
<div id="ssh">
|
||||||
<table id="ssh_enable_table" class="overview">
|
{% include 'include/admin_ssh.html' %}
|
||||||
<tr class="overviewHead" style="width: 50%;">
|
|
||||||
<td class="padding10 first-collumn" style="width: 15%;">
|
|
||||||
<span title="It's just name alias. This alias will be userd in 'Servers' page for choose credentials">Name</span>
|
|
||||||
</td>
|
|
||||||
<td class="padding10 first-collumn" style="width: 25%;">
|
|
||||||
<span title="If enabled, the key will be used, if turned off - the password. Do not forget to download the keys to all servers or install the sudo without a password">SSH key</span>
|
|
||||||
</td>
|
|
||||||
<td style="width: 100%;">
|
|
||||||
<span title="Enter SSH user name. If SSH key disabled, enter password for ssh user">Credentials</span>
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
{% for ssh in sshs %}
|
|
||||||
{% if ssh.5|string() == group|string() %}
|
|
||||||
<tr style="width: 50%;" id="ssh-table-{{ssh.0}}" class="{{ loop.cycle('odd', 'even') }}">
|
|
||||||
<td class="first-collumn">
|
|
||||||
{% 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 %}
|
|
||||||
<label for="ssh_enable-{{ssh.0}}">Enable SSH key</label><input type="checkbox" id="ssh_enable-{{ssh.0}}" checked>
|
|
||||||
{% else %}
|
|
||||||
<label for="ssh_enable-{{ssh.0}}">Enable SSH key</label><input type="checkbox" id="ssh_enable-{{ssh.0}}">
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
<td style="padding-top: 15px;">
|
|
||||||
<p>
|
|
||||||
{% set id = 'ssh_user-' + ssh.0|string() %}
|
|
||||||
{{ input(id, value=ssh.3, title='SSH user name') }}
|
|
||||||
</p>
|
|
||||||
{% if ssh.2 == 1 %}
|
|
||||||
<input type="password" id="ssh_pass-{{ssh.0}}" class="form-control" value="" placeholder="*****" style="display: none;" autocomplete="off" />
|
|
||||||
{% else %}
|
|
||||||
<input type="password" id="ssh_pass-{{ssh.0}}" class="form-control" value="" placeholder="*****" autocomplete="off" />
|
|
||||||
{% endif %}
|
|
||||||
<br>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<a class="delete" onclick="confirmDeleteSsh({{ssh.0}})" title="Delete this SSH credentials" style="cursor: pointer;"></a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
</table>
|
|
||||||
<br /><span class="add-button" title="Add ssh" id="add-ssh-button">+ Add</span>
|
|
||||||
<br /><br />
|
|
||||||
<table id="ssh_key">
|
|
||||||
<tr class="overviewHead" style="width: 50%;">
|
|
||||||
<td class="padding10 first-collumn" style="width: 25%;">Upload SSH Key</td>
|
|
||||||
<td>
|
|
||||||
<span title="Private key. Note: The public key must be pre-installed on all servers to which you plan to connect">Key</span>
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
<tr style="width: 50%;">
|
|
||||||
<td class="first-collumn" valign="top" style="padding-top: 15px;">
|
|
||||||
<select id="ssh-key-name">
|
|
||||||
<option disabled selected>Choose credentials</option>
|
|
||||||
{% for ssh in sshs %}
|
|
||||||
{% if ssh.5|string() == group %}
|
|
||||||
<option value={{ssh.1}}>{{ssh.1}}</option>
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
</select>
|
|
||||||
</td>
|
|
||||||
<td style="padding-top: 15px;">
|
|
||||||
<textarea id="ssh_cert" cols="50" rows="5"></textarea><br /><br />
|
|
||||||
<button id="ssh_key_upload" title="Upload ssh key" onclick="uploadSsh()">Upload</button>
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<div id="ajax-ssh"></div>
|
|
||||||
<div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;">
|
|
||||||
You can read the description of all parameters <a href="https://haproxy-wi.org/description.py?description=creds" title="Servers description" target="_blank">here</a>
|
|
||||||
or watch video <a href="https://haproxy-wi.org/description.py?description=setup" title="How to setup servers, group and SSH credentials" target="_blank">here</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="checker">
|
<div id="checker">
|
||||||
|
@ -333,7 +255,6 @@
|
||||||
$('#add-user-button').css('display', 'none');
|
$('#add-user-button').css('display', 'none');
|
||||||
$('#add-server-button').css('display', 'none');
|
$('#add-server-button').css('display', 'none');
|
||||||
$('.passwordChange').css('display', 'none');
|
$('.passwordChange').css('display', 'none');
|
||||||
$('.add').css('display', 'none');
|
|
||||||
$('#add-ssh-button').css('display', 'none');
|
$('#add-ssh-button').css('display', 'none');
|
||||||
$('#ssh_key_upload').css('display', 'none');
|
$('#ssh_key_upload').css('display', 'none');
|
||||||
$('#add-telegram-button').css('display', 'none');
|
$('#add-telegram-button').css('display', 'none');
|
||||||
|
|
|
@ -848,7 +848,7 @@ function addUser(dialog_id) {
|
||||||
newemail: $('#new-email').val(),
|
newemail: $('#new-email').val(),
|
||||||
newrole: $('#new-role').val(),
|
newrole: $('#new-role').val(),
|
||||||
activeuser: activeuser,
|
activeuser: activeuser,
|
||||||
page: cur_url[0],
|
page: cur_url[0].split('#')[0],
|
||||||
newgroupuser: $('#new-group').val(),
|
newgroupuser: $('#new-group').val(),
|
||||||
token: $('#token').val()
|
token: $('#token').val()
|
||||||
},
|
},
|
||||||
|
@ -939,7 +939,7 @@ function addServer(dialog_id) {
|
||||||
enable: enable,
|
enable: enable,
|
||||||
slave: $('#slavefor' ).val(),
|
slave: $('#slavefor' ).val(),
|
||||||
cred: cred,
|
cred: cred,
|
||||||
page: cur_url[0],
|
page: cur_url[0].split('#')[0],
|
||||||
desc: $('#desc').val(),
|
desc: $('#desc').val(),
|
||||||
token: $('#token').val()
|
token: $('#token').val()
|
||||||
},
|
},
|
||||||
|
@ -979,7 +979,7 @@ function addCreds(dialog_id) {
|
||||||
ssh_user: $('#ssh_user').val(),
|
ssh_user: $('#ssh_user').val(),
|
||||||
ssh_pass: $('#ssh_pass').val(),
|
ssh_pass: $('#ssh_pass').val(),
|
||||||
ssh_enable: ssh_enable,
|
ssh_enable: ssh_enable,
|
||||||
page: cur_url[0],
|
page: cur_url[0].split('#')[0],
|
||||||
token: $('#token').val()
|
token: $('#token').val()
|
||||||
},
|
},
|
||||||
type: "POST",
|
type: "POST",
|
||||||
|
@ -1016,7 +1016,7 @@ function addTelegram(dialog_id) {
|
||||||
newtelegram: $('#telegram-token-add').val(),
|
newtelegram: $('#telegram-token-add').val(),
|
||||||
chanel: $('#telegram-chanel-add').val(),
|
chanel: $('#telegram-chanel-add').val(),
|
||||||
telegramgroup: $('#new-telegram-group-add').val(),
|
telegramgroup: $('#new-telegram-group-add').val(),
|
||||||
page: cur_url[0],
|
page: cur_url[0].split('#')[0],
|
||||||
token: $('#token').val()
|
token: $('#token').val()
|
||||||
},
|
},
|
||||||
type: "POST",
|
type: "POST",
|
||||||
|
|
Loading…
Reference in New Issue