diff --git a/app/funct.py b/app/funct.py
index 842a700d..c62cd0ea 100644
--- a/app/funct.py
+++ b/app/funct.py
@@ -95,8 +95,11 @@ def telegram_send_mess(mess, **kwargs):
import telebot
from telebot import apihelper
import sql
-
- telegrams = sql.get_telegram_by_ip(kwargs.get('ip'))
+
+ if kwargs.get('telegram_channel_id'):
+ telegrams = sql.get_telegram_by_id(kwargs.get('telegram_channel_id'))
+ else:
+ telegrams = sql.get_telegram_by_ip(kwargs.get('ip'))
proxy = sql.get_setting('proxy')
for telegram in telegrams:
@@ -115,7 +118,7 @@ def telegram_send_mess(mess, **kwargs):
bot = telebot.TeleBot(token=token_bot)
bot.send_message(chat_id=channel_name, text=mess)
except Exception as e:
- print(str(e).decode(encoding='UTF-8'))
+ print(str(e))
logging('localhost', str(e).decode(encoding='UTF-8'), haproxywi=1)
sys.exit()
@@ -1044,7 +1047,7 @@ def out_error(e):
error = e
else:
error = e.args[0]
- print(error)
+ print('error: '+error)
def get_users_params(**kwargs):
diff --git a/app/templates/base.html b/app/templates/base.html
index 893a4448..37264d78 100644
--- a/app/templates/base.html
+++ b/app/templates/base.html
@@ -133,8 +133,8 @@
- Auto-refresh
- Auto-refresh
+ Auto-refresh
+ Auto-refresh
{% endif %}
@@ -146,14 +146,14 @@
-
+
-
1 hour
diff --git a/app/templates/ovw.html b/app/templates/ovw.html
index 7a0ac964..60095c7b 100644
--- a/app/templates/ovw.html
+++ b/app/templates/ovw.html
@@ -51,9 +51,9 @@
{% endfor %}
-
+
-
-
+
+
Tools status
|
diff --git a/inc/script.js b/inc/script.js
index 65cf8c16..98d9b6cb 100644
--- a/inc/script.js
+++ b/inc/script.js
@@ -157,20 +157,24 @@ function autoRefreshStyle(autoRefresh) {
$('.auto-refresh-resume').css('display', 'none');
$('.auto-refresh-pause').css('margin-left', "-25px");
$('.auto-refresh-resume').css('margin-left', "-25px");
+ $('#browse_histroy').css("border-bottom", "none");
$('.auto-refresh img').remove();
}
function setRefreshInterval(interval) {
if (interval == "0") {
- Cookies.remove('auto-refresh');
- pauseAutoRefresh();
- $('.auto-refresh').prepend('');
- $('.auto-refresh').css('margin-top', '-3px');
- $('#1').text('Auto-refresh');
- $('#0').text('Auto-refresh');
- $('.auto-refresh-pause').css('display', 'none');
- $('.auto-refresh-resume').css('display', 'none');
+ var autoRefresh = Cookies.get('auto-refresh');
+ if (autoRefresh !== undefined) {
+ Cookies.remove('auto-refresh');
+ pauseAutoRefresh();
+ $('.auto-refresh').prepend('');
+ $('.auto-refresh').css('font-size', '15px');
+ $('#1').text('Auto-refresh');
+ $('#0').text('Auto-refresh');
+ $('.auto-refresh-pause').css('display', 'none');
+ $('.auto-refresh-resume').css('display', 'none');
+ $.getScript("/inc/fontawesome.min.js")
+ }
hideAutoRefreshDiv();
- $.getScript("/inc/fontawesome.min.js")
} else {
clearInterval(intervalId);
Cookies.set('auto-refresh', interval, { expires: 365 });
@@ -302,6 +306,9 @@ function showLog() {
var hour1 = $('#time_range_out_hour1').val()
var minut1 = $('#time_range_out_minut1').val()
var service = $('#service').val()
+ if (service == 'None') {
+ service = 'haproxy';
+ }
$.ajax( {
url: "options.py",
data: {
@@ -917,11 +924,11 @@ function listHistroy() {
if (i == 2) {
browse_history[2] = cur_url[0]
}
- $( function() {
+ $( function() {
$('.menu li ul li').each(function () {
var link1 = $(this).find('a').attr('href');
var link2 = link1.split('/')[2]
- if (browse_history[i] == link2) {
+ if (browse_history[i] == link2) {
title[i] = $(this).find('a').attr('title');
link_text[i] = $(this).find('a').text();
history_link = '- '+link_text[i]+'
'
@@ -939,4 +946,4 @@ function changeCurrentGroupF(){
Cookies.remove('group');
Cookies.set('group', $('#newCurrentGroup').val(), { path: '/app', sameSite: 'Strict', Secure: 'True' });
location.reload();
-}
\ No newline at end of file
+}
diff --git a/inc/style.css b/inc/style.css
index ffb96953..095cf702 100644
--- a/inc/style.css
+++ b/inc/style.css
@@ -31,10 +31,12 @@ h3 {
}
ul#browse_histroy {
padding-left: 10px;
- margin-bottom: 5px;
display: block;
margin-top: 1px;
list-style: none;
+ border-bottom: 1px solid #D9D9D9;
+ padding-bottom: 5px;
+ clear: both;
}
ul#browse_histroy li {
display: inline;
@@ -197,7 +199,7 @@ pre {
position: relative;
padding: 10px;
background-color: #F5F5F5;
- border-bottom: solid 1px #D9D9D9;
+ //border-bottom: solid 1px #D9D9D9;
border-top: solid 1px #D9D9D9;
margin-bottom: 10px;
line-height: 20px;
@@ -217,8 +219,7 @@ pre {
padding: 0px 15px;
margin-top: 5px;
margin-bottom: 10px;
- margin-left: 70%;
- border-bottom: solid 1px #D9D9D9;
+ margin-left: 60%;
}
.auto-refresh-ul{
float: left;
@@ -243,6 +244,12 @@ pre {
font-size: 12px;
height: 15;
}
+.auto-refresh-reload-icon {
+ margin-top: 3px;
+ display: block;
+ float: left;
+ margin-right: 5px;
+}
.configShow, .diff {
margin-left: 16%;
overflow: auto;
@@ -371,6 +378,7 @@ pre {
min-height: 160px;
float: left;
margin: 20px;
+ margin-top: 0;
}
.overviewHead {
border-radius: 5px;
@@ -866,6 +874,74 @@ label {
.restart, .reload, .stop, .stop-waf, .restart-waf {
padding-left: 4px;
}
+.main {
+ margin: 20px;
+}
+.sort_menu {
+ clear: both;
+ margin-bottom: 20px;
+}
+.smon_group {
+ clear: both;
+}
+.group_name {
+ font-size: 18px;
+ padding: 20px;
+ padding-left:15px;
+ padding-bottom: 0px;
+}
+.smon_services {
+ width: 190px;
+ height: 160px;
+ float: left;
+ background-color: #fbfbfb;;
+ margin: 10px;
+ padding-left: 15px;
+ border: 1px solid #A4C7F5;
+}
+#good_services {
+ clear: both;
+ margin-bottom: 30px;
+}
+#err_services {
+ clear: both;
+ margin-bottom: 30px;
+}
+.ip {
+ font-size: 18px;
+ padding-top: 5px;
+ padding-bottom: 3px;
+ color: #5d9ceb;
+ border-bottom: 1px solid #A4C7F5;
+ width: 93%;
+ margin-bottom: 5px;
+}
+.desc, .res_time {
+ color: #999;
+}
+.desc {
+ height: 20px;
+}
+.res_time {
+ height: 25px;
+}
+.up, .down, .disable {
+ height: 45px;
+ width: 177px;
+ font-size: 30px;
+ color: #fff;
+}
+.up {
+ background-color: #5CB85C;
+}
+.down {
+ background-color: red;
+ font-size: 22px;
+}
+.disable {
+ background-color: grey;
+ color: #aaa;
+}
@media (max-width: 1920px) {
#logo_span {
margin-left: 17%;
diff --git a/inc/users.js b/inc/users.js
index 32421db8..508ca560 100644
--- a/inc/users.js
+++ b/inc/users.js
@@ -478,7 +478,7 @@ $( function() {
type: "POST",
success: function( data ) {
if (data.indexOf('error') != '-1') {
- $("#ajax-group").append(data);
+ $("#ajax-group").append(''+data+'
');
$('#errorMess').click(function() {
$('#error').remove();
$('.alert-danger').remove();
@@ -515,7 +515,7 @@ $( function() {
type: "POST",
success: function( data ) {
if (data.indexOf('error') != '-1') {
- $("#ajax-ssh").append(data);
+ $("#ajax-ssh").append(''+data+'
');
$('#errorMess').click(function() {
$('#error').remove();
$('.alert-danger').remove();
@@ -554,7 +554,7 @@ $( function() {
type: "POST",
success: function( data ) {
if (data.indexOf('error') != '-1') {
- $("#ajax-telegram").append(data);
+ $("#ajax-telegram").append(''+data+'
');
$('#errorMess').click(function() {
$('#error').remove();
$('.alert-danger').remove();
@@ -677,6 +677,34 @@ $( function() {
$('#add-backup-button').click(function() {
addBackupDialog.dialog('open');
});
+ var addSmonServer = $( "#smon-add-table" ).dialog({
+ autoOpen: false,
+ resizable: false,
+ height: "auto",
+ width: 600,
+ modal: true,
+ title: "Create a new server for monitoring",
+ show: {
+ effect: "fade",
+ duration: 200
+ },
+ hide: {
+ effect: "fade",
+ duration: 200
+ },
+ buttons: {
+ "Add": function() {
+ addNewSmonServer();
+ },
+ Cancel: function() {
+ $( this ).dialog( "close" );
+ clearTips();
+ }
+ }
+ });
+ $('#add-smon-button').click(function() {
+ addSmonServer.dialog('open');
+ });
$( "#ajax-users input" ).change(function() {
var id = $(this).attr('id').split('-');
updateUser(id[1])
@@ -791,12 +819,84 @@ function clearTips() {
function checkLength( o, n, min ) {
if ( o.val().length < min ) {
o.addClass( "ui-state-error" );
- updateTips("Filed "+n+" required");
+ updateTips("Filed "+n+" is required");
return false;
} else {
return true;
}
}
+function addNewSmonServer() {
+ var valid = true;
+ $('#error').remove();
+ allFields = $( [] ).add( $('#new-smon-ip') ).add( $('#new-smon-port') )
+ allFields.removeClass( "ui-state-error" );
+ valid = valid && checkLength( $('#new-smon-ip'), "IP", 1 );
+ valid = valid && checkLength( $('#new-smon-port'), "Port", 1 );
+ if ($('#new-smon-proto').val() != '' || $('#new-smon-uri').val() != '') {
+ allFields = $( [] ).add( $('#new-smon-ip') ).add( $('#new-smon-port') )
+ .add( $('#new-smon-proto') ).add( $('#new-smon-uri') );
+ allFields.removeClass( "ui-state-error" );
+ valid = valid && checkLength( $('#new-smon-ip'), "IP", 1 );
+ valid = valid && checkLength( $('#new-smon-port'), "Port", 1 );
+ valid = valid && checkLength( $('#new-smon-proto'), "Protocol", 1 );
+ valid = valid && checkLength( $('#new-smon-uri'), "URI", 1 );
+ }
+ if( $('#new-smon-body').val() != '') {
+ allFields = $( [] ).add( $('#new-smon-ip') ).add( $('#new-smon-port') )
+ .add( $('#new-smon-proto') ).add( $('#new-smon-uri') );
+ allFields.removeClass( "ui-state-error" );
+ valid = valid && checkLength( $('#new-smon-ip'), "IP", 1 );
+ valid = valid && checkLength( $('#new-smon-port'), "Port", 1 );
+ valid = valid && checkLength( $('#new-smon-proto'), "Protocol", 1 );
+ valid = valid && checkLength( $('#new-smon-uri'), "URI", 1 );
+ valid = valid && checkLength( $('#new-smon-body'), "Body", 1 );
+ }
+ var enable = 0;
+ if ($('#new-smon-enable').is(':checked')) {
+ enable = '1';
+ }
+ if (valid) {
+ $.ajax( {
+ url: "options.py",
+ data: {
+ newsmon: $('#new-smon-ip').val(),
+ newsmonport: $('#new-smon-port').val(),
+ newsmonenable: enable,
+ newsmonproto: $('#new-smon-proto').val(),
+ newsmonuri: $('#new-smon-uri').val(),
+ newsmonbody: $('#new-smon-body').val(),
+ newsmongroup: $('#new-smon-group').val(),
+ newsmondescription: $('#new-smon-description').val(),
+ newsmontelegram: $('#new-smon-telegram').val(),
+ token: $('#token').val()
+ },
+ type: "POST",
+ success: function( data ) {
+ data = data.replace(/\s+/g,' ');
+ if (data.indexOf('error') != '-1' || data.indexOf('unique') != '-1') {
+ $("#ajax").html(''+data+'
');;
+ $('#errorMess').click(function() {
+ $('#error').remove();
+ $('.alert-danger').remove();
+ });
+ } else {
+ $('.alert-danger').remove();
+ $("#ajax-smon").append(data);
+ $(".newserver").addClass( "update", 1000 );
+ $( "input[type=submit], button" ).button();
+ $( "input[type=checkbox]" ).checkboxradio();
+ $( "select" ).selectmenu();
+ $.getScript(awesome);
+ setTimeout(function() {
+ $( ".newserver" ).removeClass( "update" );
+ }, 2500 );
+ }
+ }
+ } );
+ clearTips();
+ $( "#smon-add-table" ).dialog("close" );
+ }
+}
function addUser() {
var valid = true;
$('#error').remove();
@@ -826,7 +926,7 @@ function addUser() {
success: function( data ) {
data = data.replace(/\s+/g,' ');
if (data.indexOf('error') != '-1') {
- $("#ajax-users").append(data);
+ $("#ajax-users").append(''+data+'
');
$('#errorMess').click(function() {
$('#error').remove();
$('.alert-danger').remove();
@@ -836,7 +936,6 @@ function addUser() {
$("#ajax-users").append(data);
var getId = new RegExp('[0-9]+');
var id = data.match(getId);
- console.log(id[0])
addUserGroup(id[0]);
}
}
@@ -897,7 +996,7 @@ function addServer() {
success: function( data ) {
data = data.replace(/\s+/g,' ');
if (data.indexOf('error') != '-1') {
- $("#ajax-servers").append(data);
+ $("#ajax-servers").append(''+data+'
');
$('#errorMess').click(function() {
$('#error').remove();
$('.alert-danger').remove();
@@ -1124,6 +1223,24 @@ function confirmDeleteBackup(id) {
}
});
}
+function confirmDeleteSmon(id) {
+ $( "#dialog-confirm" ).dialog({
+ resizable: false,
+ height: "auto",
+ width: 400,
+ modal: true,
+ title: "Are you sure you want to delete server " +$('#smon-ip-'+id).val() + "?",
+ buttons: {
+ "Delete": function() {
+ $( this ).dialog( "close" );
+ removeSmon(id);
+ },
+ Cancel: function() {
+ $( this ).dialog( "close" );
+ }
+ }
+ });
+}
function cloneServer(id) {
$( "#add-server-button" ).trigger( "click" );
if ($('#enable-'+id).is(':checked')) {
@@ -1305,6 +1422,25 @@ function removeBackup(id) {
}
} );
}
+function removeSmon(id) {
+ $("#smon-"+id).css("background-color", "#f2dede");
+ $.ajax( {
+ url: "options.py",
+ data: {
+ smondel: id,
+ token: $('#token').val()
+ },
+ type: "POST",
+ success: function( data ) {
+ data = data.replace(/\s+/g,' ');
+ if(data == "Ok ") {
+ $("#smon-"+id).remove();
+ } else {
+ alert(data);
+ }
+ }
+ } );
+}
function updateUser(id) {
$('.alert-danger').remove();
cur_url[0] = cur_url[0].split('#')[0]
@@ -1396,7 +1532,6 @@ function updateServer(id) {
if (cur_url[0].split('#')[0] == "servers.py") {
servergroup = $('#new-server-group-add').val();
}
- console.log(servergroup)
$.ajax( {
url: "options.py",
data: {