diff --git a/app/templates/ajax/load_telegram.html b/app/templates/ajax/load_telegram.html
index 0a4ef85c..c267d09f 100644
--- a/app/templates/ajax/load_telegram.html
+++ b/app/templates/ajax/load_telegram.html
@@ -1,128 +1,433 @@
-{% from 'include/input_macros.html' import input, select %}
+{% from 'include/input_macros.html' import input, select, checkbox %}
{% if user_status == 0 %}
{% include 'include/no_sub.html' %}
{% else %}
+
+
{% for s in services %}
-{% if s.0 == 'roxy-wi-checker' %}
- {% if s.3 != '* is not installed' and s.3 != '' %}
-
-
Add Telegram channel
-
-
- Token
-
-
Channel name
- {% if page != "servers.py" %}
-
Group
- {% endif %}
-
-
-
-
- {% for telegram in telegrams %}
-
-
- {% set id = 'telegram-token-' + telegram.id|string() %}
- {{ input(id, value=telegram.token, size='30') }}
-
-
- {% set id = 'telegram-chanel-' + telegram.id|string() %}
- {{ input(id, value=telegram.chanel_name, size='30') }}
-
- {% if page != "servers.py" %}
-
-
-
- {% endif %}
-
-
-
-
-
-
-
-
-
-
- {% endfor %}
-
- + Add
-
-
-
Add Slack channel
-
-
- Token
-
-
Channel name
- {% if page != "servers.py" %}
-
Group
- {% endif %}
-
-
-
-
- {% for slack in slacks %}
-
-
- {% set id = 'slack-token-' + slack.id|string() %}
- {{ input(id, value=slack.token, size='30') }}
-
-
- {% set id = 'slack-chanel-' + slack.id|string() %}
- {{ input(id, value=slack.chanel_name, size='30') }}
-
- {% if page != "servers.py" %}
-
-
-
- {% endif %}
-
-
-
-
-
-
-
-
-
-
- {% endfor %}
-
- + Add
-
-
-
- You can read the description of all parameters here,
- How to create and use Telegram bot in this article,
- How to create and use Slack APP in this article
-
- {% else %}
-
-
-
You have not installed Backends checker
- Read hear
- how to install Checker service
+ {% if s.0 == 'roxy-wi-checker' %}
+ {% if s.3 == '* is not installed' and s.3 == '' %}
+
+
+
You have not installed Backends checker
+ Read hear
+ how to install Checker service
+ {% set id = 'telegram-token-' + telegram.id|string() %}
+ {{ input(id, value=telegram.token, size='30') }}
+
+
+ {% set id = 'telegram-chanel-' + telegram.id|string() %}
+ {{ input(id, value=telegram.chanel_name, size='30') }}
+
+ {% if page != "servers.py" %}
+
+
+
+ {% endif %}
+
+
+
+
+
+
+
+
+
+
+ {% endfor %}
+
+ + Add
+
+
+
Slack channels
+
+
+ Token
+
+
Channel name
+ {% if page != "servers.py" %}
+
Group
+ {% endif %}
+
+
+
+
+ {% for slack in slacks %}
+
+
+ {% set id = 'slack-token-' + slack.id|string() %}
+ {{ input(id, value=slack.token, size='30') }}
+
+
+ {% set id = 'slack-chanel-' + slack.id|string() %}
+ {{ input(id, value=slack.chanel_name, size='30') }}
+
+ {% if page != "servers.py" %}
+
+
+
+ {% endif %}
+
+
+
+
+
+
+
+
+
+
+ {% endfor %}
+
+ + Add
+
+
+
Test messages
+
+
Email
+
Web panel
+
+
+
+
+
+
+
+
+
+
+
+
+
+ You can read the description of all parameters here,
+ How to create and use Telegram bot in this article,
+ How to create and use Slack APP in this article
- {% endif %}
+
+
+
+
HAProxy servers
+
+
Server
+
Telegram
+
Slack
+
Email
+
Service
+
Backend
+
Maxconn
+
+
+ {% for s in haproxy_servers %}
+ {% for h in haproxy_settings %}
+ {% if h.server_id|string() == s.0|string() and h.service_id == 1 %}
+
+ {% set id = 'haproxy_server_status-' + h.id|string() %}
+ {% if h.service_alert == 1 %}
+ {{ checkbox(id, checked='checked', title='Alert about changing service status') }}
+ {% else %}
+ {{ checkbox(id, title='Alert about changing service status') }}
+ {% endif %}
+
+
+ {% set id = 'haproxy_server_backend-' + h.id|string() %}
+ {% if h.backend_alert == 1 %}
+ {{ checkbox(id, checked='checked', title='Alert about changing backend status') }}
+ {% else %}
+ {{ checkbox(id, title='Alert about changing backend status') }}
+ {% endif %}
+
+
+ {% set id = 'haproxy_server_maxconn-' + h.id|string() %}
+ {% if h.maxconn_alert == 1 %}
+ {{ checkbox(id, checked='checked', title='Alert if the number of connections is about to reach the limit') }}
+ {% else %}
+ {{ checkbox(id, title='Alert if the number of connections is about to reach the limit') }}
+ {% endif %}
+
+
+
+ {% endif %}
+ {% endfor %}
+ {% endfor %}
+
+
+
NGINX servers
+
+
Server
+
Telegram
+
Slack
+
Email
+
Service
+
+
+ {% for s in nginx_servers %}
+ {% for h in nginx_settings %}
+ {% if h.server_id|string() == s.0|string() and h.service_id == 2 %}
+
+
{{s.1}}
+
+
+
+
+
+
+
+ {% set id = 'nginx_server_email-' + h.id|string() %}
+ {% if h.email == 1 %}
+ {{ checkbox(id, checked='checked', title='Alert via email') }}
+ {% else %}
+ {{ checkbox(id, title='Alert via email') }}
+ {% endif %}
+
+
+ {% set id = 'nginx_server_status-' + h.id|string() %}
+ {% if h.service_alert == 1 %}
+ {{ checkbox(id, checked='checked', title='Alert about changing service status') }}
+ {% else %}
+ {{ checkbox(id, title='Alert about changing service status') }}
+ {% endif %}
+
+
+
+ {% endif %}
+ {% endfor %}
+ {% endfor %}
+
+
+
Apache servers
+
+
Server
+
Telegram
+
Slack
+
Email
+
Service
+
+
+ {% for s in apache_servers %}
+ {% for h in apache_settings %}
+ {% if h.server_id|string() == s.0|string() and h.service_id == 4 %}
+
+
{{s.1}}
+
+
+
+
+
+
+
+ {% set id = 'apache_server_email-' + h.id|string() %}
+ {% if h.email == 1 %}
+ {{ checkbox(id, checked='checked', title='Alert via email') }}
+ {% else %}
+ {{ checkbox(id, title='Alert via email') }}
+ {% endif %}
+
+
+ {% set id = 'apache_server_status-' + h.id|string() %}
+ {% if h.service_alert == 1 %}
+ {{ checkbox(id, checked='checked', title='Alert about changing service status') }}
+ {% else %}
+ {{ checkbox(id, title='Alert about changing service status') }}
+ {% endif %}
+
+
+
+ {% endif %}
+ {% endfor %}
+ {% endfor %}
+
+
+
Keepalived servers
+
+
Server
+
Telegram
+
Slack
+
Email
+
Service
+
Status
+
+
+ {% for s in keepalived_servers %}
+ {% for h in keepalived_settings %}
+ {% if h.server_id|string() == s.0|string() and h.service_id == 3 %}
+
+
{{s.1}}
+
+
+
+
+
+
+
+ {% set id = 'keepalived_server_email-' + h.id|string() %}
+ {% if h.email == 1 %}
+ {{ checkbox(id, checked='checked', title='Alert via email') }}
+ {% else %}
+ {{ checkbox(id, title='Alert via email') }}
+ {% endif %}
+
+
+ {% set id = 'keepalived_server_status-' + h.id|string() %}
+ {% if h.service_alert == 1 %}
+ {{ checkbox(id, checked='checked', title='Alert about changing service status') }}
+ {% else %}
+ {{ checkbox(id, title='Alert about changing service status') }}
+ {% endif %}
+
+
+ {% set id = 'keepalived_server_backend-' + h.id|string() %}
+ {% if h.backend_alert == 1 %}
+ {{ checkbox(id, checked='checked', title='Alert about changing Master/Backup status') }}
+ {% else %}
+ {{ checkbox(id, title='Alert about changing Master/Backup status') }}
+ {% endif %}
+
+
+
+ {% endif %}
+ {% endfor %}
+ {% endfor %}
+
+
+
+{% endif %}
{% endif %}
{% endfor %}
-{% endif %}
\ No newline at end of file
+{% endif %}
diff --git a/app/templates/ajax/load_updatehapwi.html b/app/templates/ajax/load_updatehapwi.html
index b22ccd34..ff1b89ad 100644
--- a/app/templates/ajax/load_updatehapwi.html
+++ b/app/templates/ajax/load_updatehapwi.html
@@ -33,7 +33,7 @@
{% for s in services %}
- {% if s.0 == 'roxy-wi-smon' or s.0 == 'roxy-wi-checker' or s.0 == 'roxy-wi-keep_alive' or s.0 == 'roxy-wi-metrics' or s.0 == 'roxy-wi-portscanner' or s.0 == 'roxy-wi-socket' %}
+ {% if s.0 in ('roxy-wi-smon', 'roxy-wi-checker', 'roxy-wi-keep_alive', 'roxy-wi-metrics', 'roxy-wi-portscanner', 'roxy-wi-socket') %}
{% set is_need_update = 0 %}
{% if s.0 == 'roxy-wi-smon' %}
@@ -43,6 +43,7 @@
{% if s.3|float < smon_ver|float %}
{% set is_need_update = 1 %}
{% endif %}
+ {% set description = 'SMON stands for Simple MONitoring' %}
{% elif s.0 == 'roxy-wi-checker' %}
{% set service_name = 'Checker' %}
{% set service_link = 'checker' %}
@@ -50,6 +51,7 @@
{% if s.3|float < checker_ver|float %}
{% set is_need_update = 1 %}
{% endif %}
+ {% set description = 'Checker is designed for monitoring HAProxy, Nginx, Apache and Keepalived services as well as HAProxy backends' %}
{% elif s.0 == 'roxy-wi-keep_alive' %}
{% set service_name = 'Auto start' %}
{% set service_link = 'auto_start' %}
@@ -57,6 +59,7 @@
{% if s.3|float < keep_ver|float %}
{% set is_need_update = 1 %}
{% endif %}
+ {% set description = 'The Auto Start service allows to restart the HAProxy, NGINX, Apache and Keepalived services if they are down' %}
{% elif s.0 == 'roxy-wi-metrics' %}
{% set service_name = 'Metrics' %}
{% set service_link = 'metrics' %}
@@ -64,23 +67,26 @@
{% if s.3|float < metrics_ver|float %}
{% set is_need_update = 1 %}
{% endif %}
+ {% set description = 'Collects number of connections for HAProxy, NGINX and WAF services' %}
{% elif s.0 == 'roxy-wi-portscanner' %}
{% set service_name = 'Port scanner' %}
{% set service_link = 'portscanner' %}
- {% set desc_link = 'https://roxy-wi.org/services.py?service={{service_link}}' %}
+ {% set desc_link = 'https://roxy-wi.org/services.py?service=' + service_link %}
{% if s.3|float < portscanner_ver|float %}
{% set is_need_update = 1 %}
{% endif %}
+ {% set description = 'Probes and saves a server or host for open ports' %}
{% elif s.0 == 'roxy-wi-socket' %}
{% set service_name = 'Socket service' %}
{% set service_link = 'socket' %}
- {% set desc_link = 'https://roxy-wi.org/services.py?service={{service_link}}' %}
+ {% set desc_link = 'https://roxy-wi.org/services.py?service=' + service_link %}
{% if s.3|float < socket_ver|float %}
{% set is_need_update = 1 %}
{% endif %}
+ {% set description = 'Socket is a service for sending alerts and notifications' %}
{% endif %}
{% set section = namespace(section='') %}
{% for set in settings %}
- {% if page == "servers.py" and (set.section == 'monitoring' or set.section == 'rabbitmq') %}
+ {% if page == "servers.py" and (set.section in ('monitoring', 'rabbitmq', 'mail')) %}
{% else %}
{% if section.section|string() != set.section|string() %}
@@ -27,18 +27,33 @@
{{set.param}}
- Fields marked "*" are required.
+ Fields marked with "*" are required.
\ No newline at end of file
diff --git a/app/templates/sections.html b/app/templates/sections.html
index 35179228..04535715 100644
--- a/app/templates/sections.html
+++ b/app/templates/sections.html
@@ -70,6 +70,9 @@
{% include 'include/errors.html' %}
{% else %}
Config is ok
+ {% if warning %}
+
{{warning}}
+ {% endif %}
Config |
Go to stats
{% endif %}
diff --git a/app/users.py b/app/users.py
index 4c068c4b..0633ae44 100644
--- a/app/users.py
+++ b/app/users.py
@@ -1,5 +1,7 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
+import pytz
+
import funct
import sql
from jinja2 import Environment, FileSystemLoader
@@ -18,7 +20,6 @@ try:
users = sql.select_users()
settings = sql.get_setting('', all=1)
ldap_enable = sql.get_setting('ldap_enable')
- grafana, stderr = funct.subprocess_execute("systemctl is-active grafana-server")
services = sql.select_services()
gits = sql.select_gits()
except Exception:
@@ -33,8 +34,8 @@ except Exception as e:
rendered_template = template.render(
title="Admin area: Manage users", role=role, user=user, users=users, groups=sql.select_groups(),
servers=sql.select_servers(full=1), roles=sql.select_roles(), masters=sql.select_servers(get_master_servers=1),
- sshs=sql.select_ssh(), token=token, settings=settings, backups=sql.select_backups(), grafana=''.join(grafana),
+ sshs=sql.select_ssh(), token=token, settings=settings, backups=sql.select_backups(),
page="users.py", user_services=user_services, ldap_enable=ldap_enable, user_status=user_status,
- user_plan=user_plan, gits=gits, services=services
+ user_plan=user_plan, gits=gits, services=services, timezones=pytz.all_timezones
)
print(rendered_template)
diff --git a/inc/add.js b/inc/add.js
index dfb883ad..9d87786a 100644
--- a/inc/add.js
+++ b/inc/add.js
@@ -1660,7 +1660,7 @@ function saveList(action, list, color) {
}
function deleteList(list, color) {
var serv = $( "#serv-"+color+"-list option:selected" ).val();
- if (serv == 'Choose server') {
+ if (serv == '------') {
toastr.warning('Choose a server before deleting');
} else {
$.ajax({
@@ -1810,16 +1810,15 @@ function addProxy(form_name) {
data: frm.serialize(),
type: frm.attr('method'),
success: function( data ) {
- data = data.replace(/\s+/g, ' ');
if (data.indexOf('error: ') != '-1' || data.indexOf('Fatal') != '-1') {
- toastr.clear();
- toastr.error(data);
+ returnNiceCheckingConfig(data);
} else if (data == '') {
toastr.clear();
toastr.error('error: Proxy cannot be empty');
} else {
toastr.clear();
- toastr.success('Section: ' + data + ' has been added. Do not forget to restart the server');
+ returnNiceCheckingConfig(data);
+ toastr.info('Section has been added. Do not forget to restart the server');
var ip = frm.find('select[name=serv]').val();
localStorage.setItem('restart', ip);
resetProxySettings();
diff --git a/inc/configshow.js b/inc/configshow.js
index 7790c341..3f9c16f6 100644
--- a/inc/configshow.js
+++ b/inc/configshow.js
@@ -62,10 +62,7 @@ $( function() {
type: frm.attr('method'),
success: function( data ) {
data = data.replace('\n', ' ');
- if (data.indexOf('error: ') != '-1' || data.indexOf('Fatal') != '-1' || data.indexOf('Error') != '-1' || data.indexOf('failed ') != '-1' || data.indexOf('emerg] ') != '-1') {
- toastr.clear();
- toastr.error(data);
- } else if (data.indexOf(service + ': command not found') != '-1') {
+ if (data.indexOf(service + ': command not found') != '-1') {
try {
var service = findGetParameter('service');
toastr.error('Cannot save config. There is no ' + service);
@@ -74,7 +71,7 @@ $( function() {
}
} else {
toastr.clear();
- toastr.success(data);
+ returnNiceCheckingConfig(data);
}
}
});
diff --git a/inc/ha.js b/inc/ha.js
index f62958d5..632de651 100644
--- a/inc/ha.js
+++ b/inc/ha.js
@@ -220,13 +220,10 @@ $( function() {
data = data.replace(/^\s+|\s+$/g,'');
if(data.indexOf('keepalived:') != '-1') {
$('#cur_master_ver').text('Keepalived has not installed');
- $('#create').prop('disabled', false);
$('#create').attr('title', 'Create HA cluster');
} else {
$('#cur_master_ver').text(data);
$('#cur_master_ver').css('font-weight', 'bold');
- $('#create').prop('disabled', true);
- $('#create').attr('title', 'Keepalived has been alredy installed. You cannot create a new HA Cluster');
}
}
} );
@@ -244,13 +241,10 @@ $( function() {
data = data.replace(/^\s+|\s+$/g,'');
if(data.indexOf('keepalived:') != '-1') {
$('#cur_slave_ver').text('Keepalived has not installed');
- $('#create').prop('disabled', false);
$('#create').attr('title', 'Create HA cluster');
} else {
$('#cur_slave_ver').text(data);
$('#cur_slave_ver').css('font-weight', 'bold');
- $('#create').prop('disabled', true);
- $('#create').attr('title', 'Keepalived has been alredy installed. You cannot create a new HA Cluster');
}
}
} );
@@ -268,13 +262,10 @@ $( function() {
data = data.replace(/^\s+|\s+$/g,'');
if(data.indexOf('keepalived:') != '-1') {
$('#cur_master_ver-add').text('Keepalived has not installed');
- $('#add-vrrp').prop('disabled', true);
$('#add-vrrp').attr('title', 'Add a HA configuration');
} else {
$('#cur_master_ver-add').text(data);
$('#cur_master_ver-add').css('font-weight', 'bold');
- $('#add-vrrp').prop('disabled', false);
- $('#add-vrrp').attr('title', 'Keepalived has been alredy installed. You cannot add a new HA configuration');
}
}
} );
@@ -292,13 +283,10 @@ $( function() {
data = data.replace(/^\s+|\s+$/g,'');
if(data.indexOf('keepalived:') != '-1') {
$('#cur_slave_ver-add').text('Keepalived has not installed');
- $('#add-vrrp').prop('disabled', true);
$('#add-vrrp').attr('title', 'Add a HA configuration');
} else {
$('#cur_slave_ver-add').text(data);
$('#cur_slave_ver-add').css('font-weight', 'bold');
- $('#add-vrrp').prop('disabled', false);
- $('#add-vrrp').attr('title', 'Keepalived has been alredy installed. You cannot add a new HA configuration');
}
}
} );
diff --git a/inc/script.js b/inc/script.js
index 4d1ae7ad..6840371e 100644
--- a/inc/script.js
+++ b/inc/script.js
@@ -23,7 +23,7 @@ function show_current_page(id) {
id.parent().children().css('margin-left', '-20px');
id.parent().find('a').css('padding-left', '20px');
id.find('a').css('padding-left', '30px');
- id.find('a').css('border-left', '4px solid #5D9CEB');
+ id.find('a').css('border-left', '4px solid var(--right-menu-blue-rolor)');
}
$( function() {
$('.menu li ul li').each(function () {
@@ -983,9 +983,9 @@ $( function() {
$( ".users" ).on( "click", function() {
$('.menu li ul li').each(function () {
$(this).find('a').css('padding-left', '20px')
- $(this).find('a').css('border-left', '0px solid #5D9CEB');
+ $(this).find('a').css('border-left', '0px solid var(--right-menu-blue-rolor)');
$(this).children(".users").css('padding-left', '30px');
- $(this).children(".users").css('border-left', '4px solid #5D9CEB');
+ $(this).children(".users").css('border-left', '4px solid var(--right-menu-blue-rolor)');
});
$( "#tabs" ).tabs( "option", "active", 0 );
} );
@@ -993,55 +993,65 @@ $( function() {
$( ".group" ).on( "click", function() {
$('.menu li ul li').each(function () {
$(this).find('a').css('padding-left', '20px')
- $(this).find('a').css('border-left', '0px solid #5D9CEB');
+ $(this).find('a').css('border-left', '0px solid var(--right-menu-blue-rolor)');
$(this).children(".group").css('padding-left', '30px');
- $(this).children(".group").css('border-left', '4px solid #5D9CEB');
+ $(this).children(".group").css('border-left', '4px solid var(--right-menu-blue-rolor)');
});
$( "#tabs" ).tabs( "option", "active", 1 );
} );
$( ".runtime" ).on( "click", function() {
$('.menu li ul li').each(function () {
- $(this).find('a').css('border-left', '0px solid #5D9CEB');
+ $(this).find('a').css('border-left', '0px solid var(--right-menu-blue-rolor)');
$(this).find('a').css('padding-left', '20px')
$(this).children(".runtime").css('padding-left', '30px');
- $(this).children(".runtime").css('border-left', '4px solid #5D9CEB');
+ $(this).children(".runtime").css('border-left', '4px solid var(--right-menu-blue-rolor)');
});
$( "#tabs" ).tabs( "option", "active", 2 );
} );
$( ".admin" ).on( "click", function() {
$('.menu li ul li').each(function () {
$(this).find('a').css('padding-left', '20px')
- $(this).find('a').css('border-left', '0px solid #5D9CEB');
+ $(this).find('a').css('border-left', '0px solid var(--right-menu-blue-rolor)');
$(this).children(".admin").css('padding-left', '30px');
- $(this).children(".admin").css('border-left', '4px solid #5D9CEB');
+ $(this).children(".admin").css('border-left', '4px solid var(--right-menu-blue-rolor)');
});
$( "#tabs" ).tabs( "option", "active", 3 );
} );
+ $( ".checker" ).on( "click", function() {
+ $('.menu li ul li').each(function () {
+ $(this).find('a').css('border-left', '0px solid var(--right-menu-blue-rolor)');
+ $(this).find('a').css('padding-left', '20px')
+ $(this).children(".checker").css('padding-left', '30px');
+ $(this).children(".checker").css('border-left', '4px solid var(--right-menu-blue-rolor)');
+ });
+ loadchecker();
+ $( "#tabs" ).tabs( "option", "active", 4 );
+ } );
$( ".settings" ).on( "click", function() {
$('.menu li ul li').each(function () {
- $(this).find('a').css('border-left', '0px solid #5D9CEB');
+ $(this).find('a').css('border-left', '0px solid var(--right-menu-blue-rolor)');
$(this).find('a').css('padding-left', '20px')
$(this).children(".settings").css('padding-left', '30px');
- $(this).children(".settings").css('border-left', '4px solid #5D9CEB');
+ $(this).children(".settings").css('border-left', '4px solid var(--right-menu-blue-rolor)');
});
$( "#tabs" ).tabs( "option", "active", 6 );
} );
$( ".services" ).on( "click", function() {
$('.menu li ul li').each(function () {
- $(this).find('a').css('border-left', '0px solid #5D9CEB');
+ $(this).find('a').css('border-left', '0px solid var(--right-menu-blue-rolor)');
$(this).find('a').css('padding-left', '20px')
$(this).children(".services").css('padding-left', '30px');
- $(this).children(".services").css('border-left', '4px solid #5D9CEB');
+ $(this).children(".services").css('border-left', '4px solid var(--right-menu-blue-rolor)');
});
loadServices();
$( "#tabs" ).tabs( "option", "active", 7 );
} );
$( ".updatehapwi" ).on( "click", function() {
$('.menu li ul li').each(function () {
- $(this).find('a').css('border-left', '0px solid #5D9CEB');
+ $(this).find('a').css('border-left', '0px solid var(--right-menu-blue-rolor)');
$(this).find('a').css('padding-left', '20px')
$(this).children(".updatehapwi").css('padding-left', '30px');
- $(this).children(".updatehapwi").css('border-left', '4px solid #5D9CEB');
+ $(this).children(".updatehapwi").css('border-left', '4px solid var(--right-menu-blue-rolor)');
});
$( "#tabs" ).tabs( "option", "active", 8 );
loadupdatehapwi();
@@ -1050,54 +1060,64 @@ $( function() {
$( ".runtime" ).on( "click", function() {
$('.menu li ul li').each(function () {
$(this).find('a').css('padding-left', '20px')
- $(this).find('a').css('border-left', '0px solid #5D9CEB');
+ $(this).find('a').css('border-left', '0px solid var(--right-menu-blue-rolor)');
$(this).children(".runtime").css('padding-left', '30px');
- $(this).children(".runtime").css('border-left', '4px solid #5D9CEB');
+ $(this).children(".runtime").css('border-left', '4px solid var(--right-menu-blue-rolor)');
});
$( "#tabs" ).tabs( "option", "active", 1 );
} );
$( ".admin" ).on( "click", function() {
$('.menu li ul li').each(function () {
- $(this).find('a').css('border-left', '0px solid #5D9CEB');
+ $(this).find('a').css('border-left', '0px solid var(--right-menu-blue-rolor)');
$(this).find('a').css('padding-left', '20px')
$(this).children(".admin").css('padding-left', '30px');
- $(this).children(".admin").css('border-left', '4px solid #5D9CEB');
+ $(this).children(".admin").css('border-left', '4px solid var(--right-menu-blue-rolor)');
});
$( "#tabs" ).tabs( "option", "active", 2 );
} );
+ $( ".checker" ).on( "click", function() {
+ $('.menu li ul li').each(function () {
+ $(this).find('a').css('border-left', '0px solid var(--right-menu-blue-rolor)');
+ $(this).find('a').css('padding-left', '20px')
+ $(this).children(".checker").css('padding-left', '30px');
+ $(this).children(".checker").css('border-left', '4px solid var(--right-menu-blue-rolor)');
+ });
+ loadchecker();
+ $( "#tabs" ).tabs( "option", "active", 3 );
+ } );
$( ".settings" ).on( "click", function() {
$('.menu li ul li').each(function () {
- $(this).find('a').css('border-left', '0px solid #5D9CEB');
+ $(this).find('a').css('border-left', '0px solid var(--right-menu-blue-rolor)');
$(this).find('a').css('padding-left', '20px')
$(this).children(".settings").css('padding-left', '30px');
- $(this).children(".settings").css('border-left', '4px solid #5D9CEB');
+ $(this).children(".settings").css('border-left', '4px solid var(--right-menu-blue-rolor)');
});
$( "#tabs" ).tabs( "option", "active", 4 );
} );
$( ".installproxy" ).on( "click", function() {
$('.menu li ul li').each(function () {
$(this).find('a').css('padding-left', '20px')
- $(this).find('a').css('border-left', '0px solid #5D9CEB');
+ $(this).find('a').css('border-left', '0px solid var(--right-menu-blue-rolor)');
$(this).children(".installproxy").css('padding-left', '30px');
- $(this).children(".installproxy").css('border-left', '4px solid #5D9CEB');
+ $(this).children(".installproxy").css('border-left', '4px solid var(--right-menu-blue-rolor)');
});
$( "#tabs" ).tabs( "option", "active", 5 );
} );
$( ".installmon" ).on( "click", function() {
$('.menu li ul li').each(function () {
$(this).find('a').css('padding-left', '20px')
- $(this).find('a').css('border-left', '0px solid #5D9CEB');
+ $(this).find('a').css('border-left', '0px solid var(--right-menu-blue-rolor)');
$(this).children(".installmon").css('padding-left', '30px');
- $(this).children(".installmon").css('border-left', '4px solid #5D9CEB');
+ $(this).children(".installmon").css('border-left', '4px solid var(--right-menu-blue-rolor)');
});
$( "#tabs" ).tabs( "option", "active", 6 );
} );
$( ".backup" ).on( "click", function() {
$('.menu li ul li').each(function () {
$(this).find('a').css('padding-left', '20px')
- $(this).find('a').css('border-left', '0px solid #5D9CEB');
+ $(this).find('a').css('border-left', '0px solid var(--right-menu-blue-rolor)');
$(this).children(".backup").css('padding-left', '30px');
- $(this).children(".backup").css('border-left', '4px solid #5D9CEB');
+ $(this).children(".backup").css('border-left', '4px solid var(--right-menu-blue-rolor)');
});
$( "#tabs" ).tabs( "option", "active", 7 );
} );
@@ -1413,3 +1433,43 @@ function waitForElm(selector) {
function randomIntFromInterval(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min)
}
+const removeEmptyLines = str => str.split(/\r?\n/).filter(line => line.trim() !== '').join('\n');
+function returnNiceCheckingConfig(data) {
+ if (data.indexOf('sudo: firewall-cmd: command not found') != '-1') {
+ data = data.replaceAll('sudo: firewall-cmd: command not found\n', '');
+ data = data.replaceAll('sudo: firewall-cmd: command not found', '');
+ toastr.warning('The Firewalld service is not enabled. You should disable this setting for this server or enable the firewalld service on the server.')
+ }
+ data = data.replaceAll('Configuration file is valid', '');
+ data = data.replaceAll('Warnings were found.', '');
+ data = data.replaceAll('nginx: the configuration file /etc/nginx/nginx.conf syntax is ok', '');
+ data = data.replaceAll('nginx: configuration file /etc/nginx/nginx.conf test is successful', '');
+ data = data.replaceAll('Syntax OK', '');
+ output = data.split(' ')
+ var alerts = []
+ alerts.push(output[0] + '\n' + output[1]);
+ try {
+ for (var i = 0; i < output.length; i++) {
+ if (i > 1) {
+ if (output[i] !== undefined) {
+ alerts.push(output[i])
+ }
+ }
+ }
+ } catch (err) {
+ console.log(err);
+ }
+ alerts.forEach((element) => {
+ if (element.indexOf('error: ') != '-1' || element.indexOf('Fatal') != '-1' || element.indexOf('Error') != '-1' || element.indexOf('failed ') != '-1' || element.indexOf('emerg] ') != '-1' || element.indexOf('Syntax error ') != '-1') {
+ toastr.error('
' + element + '
');
+ toastr.info('Config not applied');
+ return
+ } else {
+ toastr.success('Configuration file is valid');
+ }
+ if (element.indexOf('[WARNING]') != '-1' || element.indexOf('[ALER]') != '-1' || element.indexOf('[warn]') != '-1') {
+ element = removeEmptyLines(element);
+ toastr.warning('
' + element + '
')
+ }
+ })
+}
diff --git a/inc/style.css b/inc/style.css
index ed86957a..485d1c43 100644
--- a/inc/style.css
+++ b/inc/style.css
@@ -5,6 +5,7 @@
--link-dark-blue: #23527c;
--light-blue-color: #d1ecf1;
--menu-color: #06212a;
+ --right-menu-blue-rolor: #5D9CEB;
}
html {
font-size: 10px;
diff --git a/inc/users.js b/inc/users.js
index 529af555..d97a7208 100644
--- a/inc/users.js
+++ b/inc/users.js
@@ -607,9 +607,22 @@ $( function() {
updateSSH(id[1])
sshKeyEnableShow(id[1])
});
+ $( "#settings select" ).on('select2:select',function() {
+ var id = $(this).attr('id');
+ var val = $(this).val();
+ updateSettings(id, val);
+ updateSettings(id[1])
+ });
$( "#settings input" ).change(function() {
var id = $(this).attr('id');
var val = $(this).val();
+ if($('#'+id).is(':checkbox')) {
+ if ($('#'+id).is(':checked')){
+ val = 1;
+ } else {
+ val = 0;
+ }
+ }
updateSettings(id, val);
});
$('#new-ssh_enable').click(function() {
@@ -655,6 +668,38 @@ $( function() {
$('.services_for_scan').show();
}
});
+ $( "#checker_haproxy_table select" ).on('selectmenuchange',function() {
+ var id = $(this).attr('id').split('-');
+ updateHaproxyCheckerSettings(id[1])
+ });
+ $( "#checker_haproxy_table input" ).change(function() {
+ var id = $(this).attr('id').split('-');
+ updateHaproxyCheckerSettings(id[1])
+ });
+ $( "#checker_nginx_table select" ).on('selectmenuchange',function() {
+ var id = $(this).attr('id').split('-');
+ updateServiceCheckerSettings(id[1], 'nginx')
+ });
+ $( "#checker_nginx_table input" ).change(function() {
+ var id = $(this).attr('id').split('-');
+ updateServiceCheckerSettings(id[1], 'nginx')
+ });
+ $( "#checker_apache_table select" ).on('selectmenuchange',function() {
+ var id = $(this).attr('id').split('-');
+ updateServiceCheckerSettings(id[1], 'apache')
+ });
+ $( "#checker_apache_table input" ).change(function() {
+ var id = $(this).attr('id').split('-');
+ updateServiceCheckerSettings(id[1], 'apache')
+ });
+ $( "#checker_keepalived_table select" ).on('selectmenuchange',function() {
+ var id = $(this).attr('id').split('-');
+ updateKeepalivedCheckerSettings(id[1])
+ });
+ $( "#checker_keepalived_table input" ).change(function() {
+ var id = $(this).attr('id').split('-');
+ updateKeepalivedCheckerSettings(id[1])
+ });
$('#search_ldap_user').click(function() {
var valid = true;
toastr.clear();
@@ -756,17 +801,40 @@ $( function() {
});
$("#tabs ul li").click(function() {
var activeTab = $(this).find("a").attr("href");
-
+ var activeTabClass = activeTab.replace('#', '');
+ $('.menu li ul li').each(function () {
+ $(this).find('a').css('border-left', '0px solid var(--right-menu-blue-rolor)');
+ $(this).find('a').css('padding-left', '20px')
+ $(this).children("."+activeTabClass).css('padding-left', '30px');
+ $(this).children("."+activeTabClass).css('border-left', '4px solid var(--right-menu-blue-rolor)');
+ });
if (activeTab == '#services') {
loadServices();
} else if (activeTab == '#updatehapwi') {
loadupdatehapwi();
} else if (activeTab == '#checker'){
+
loadchecker();
} else if (activeTab == '#openvpn'){
loadopenvpn();
}
});
+ $("#checker_tabs ul li").click(function() {
+ $('.menu li ul li').each(function () {
+ $(this).find('a').css('border-left', '0px solid var(--right-menu-blue-rolor)');
+ $(this).find('a').css('padding-left', '20px')
+ $(this).children(".checker").css('padding-left', '30px');
+ $(this).children(".checker").css('border-left', '4px solid var(--right-menu-blue-rolor)');
+ });
+ });
+ $("#backup_tabs ul li").click(function() {
+ $('.menu li ul li').each(function () {
+ $(this).find('a').css('border-left', '0px solid var(--right-menu-blue-rolor)');
+ $(this).find('a').css('padding-left', '20px')
+ $(this).children(".backup").css('padding-left', '30px');
+ $(this).children(".backup").css('border-left', '4px solid var(--right-menu-blue-rolor)');
+ });
+ });
$('#nginx-section-head').click(function () {
hideAndShowSettings('nginx');
});
@@ -794,6 +862,9 @@ $( function() {
$('#keepalived-section-head').click(function () {
hideAndShowSettings('keepalived');
});
+ $('#mail-section-head').click(function () {
+ hideAndShowSettings('mail');
+ });
} );
function hideAndShowSettings(section) {
var ElemId = $('#' + section + '-section-h3');
@@ -1089,6 +1160,10 @@ function addTelegram(dialog_id) {
if (data.indexOf('error:') != '-1') {
toastr.error(data);
} else {
+ var getId = new RegExp('telegram-table-[0-9]+');
+ var id = data.match(getId) + '';
+ id = id.split('-').pop();
+ $('select:regex(id, telegram_channel)').append('').selectmenu("refresh");
common_ajax_action_after_success(dialog_id, 'newgroup', 'checker_table', data);
$( "input[type=submit], button" ).button();
$( "input[type=checkbox]" ).checkboxradio();
@@ -1121,6 +1196,10 @@ function addSlack(dialog_id) {
if (data.indexOf('error:') != '-1') {
toastr.error(data);
} else {
+ var getId = new RegExp('slack-table-[0-9]+');
+ var id = data.match(getId) + '';
+ id = id.split('-').pop();
+ $('select:regex(id, slack_channel)').append('').selectmenu("refresh");
common_ajax_action_after_success(dialog_id, 'newgroup', 'checker_slack_table', data);
$( "input[type=submit], button" ).button();
$( "input[type=checkbox]" ).checkboxradio();
@@ -2243,7 +2322,7 @@ function updateService(service) {
$.ajax( {
url: "options.py",
data: {
- update_haproxy_wi: 1,
+ update_roxy_wi: 1,
service: service,
token: $('#token').val()
},
@@ -2257,16 +2336,16 @@ function updateService(service) {
toastr.success(service + ' has been updated');
} else if (data.indexOf('Unauthorized') != '-1') {
toastr.clear();
- toastr.error('It seems like Unauthorized in the Roxy-WI repository. How to get Roxy-WI auth you can read hear');
+ toastr.error('It seems like Unauthorized in the Roxy-WI repository. How to get Roxy-WI auth you can read hear');
} else if (data.indexOf('but not installed') != '-1') {
toastr.clear();
toastr.error('There is settings for Roxy-WI repository, but Roxy-WI is installed without repository. Please reinstall with yum');
} else if (data.indexOf('No Match for argument') != '-1') {
toastr.clear();
- toastr.error('It seems like Roxy-WI repository is not set. Please read docs for detail');
+ toastr.error('It seems like Roxy-WI repository is not set. Please read docs for detail');
} else if (data.indexOf('password for') != '-1') {
toastr.clear();
- toastr.error('It seems like apache user needs to be add to sudoers. Please read docs for detail');
+ toastr.error('It seems like apache user needs to be add to sudoers. Please read docs for detail');
} else if (data.indexOf('No packages marked for update') != '-1') {
toastr.clear();
toastr.info('It seems like the lastest version Roxy-WI is installed');
@@ -2478,7 +2557,7 @@ function loadupdatehapwi() {
}
} );
}
-function loadchecker() {
+function loadchecker(tab = 0) {
$.ajax({
url: "options.py",
data: {
@@ -2495,8 +2574,10 @@ function loadchecker() {
$('#checker').html(data);
$( "select" ).selectmenu();
$("button").button();
+ $( "input[type=checkbox]" ).checkboxradio();
$.getScript('/inc/users.js');
$.getScript(awesome);
+ $( "#checker_tabs" ).tabs( "option", "active", tab );
}
}
} );
@@ -2607,3 +2688,160 @@ function showServerInfo(id, ip) {
$('#server_info_link-'+id).attr('title', 'Show System info');
}
}
+function updateHaproxyCheckerSettings(id) {
+ toastr.clear();
+ let email = 0;
+ let server = 0;
+ let backend = 0;
+ let maxconn = 0;
+ if ($('#haproxy_server_email-'+id).is(':checked')) {
+ email = '1';
+ }
+ if ($('#haproxy_server_status-'+id).is(':checked')) {
+ server = '1';
+ }
+ if ($('#haproxy_server_backend-'+id).is(':checked')) {
+ backend = '1';
+ }
+ if ($('#haproxy_server_maxconn-'+id).is(':checked')) {
+ maxconn = '1';
+ }
+ $.ajax( {
+ url: "options.py",
+ data: {
+ updateHaproxyCheckerSettings: id,
+ email: email,
+ server: server,
+ backend: backend,
+ maxconn: maxconn,
+ telegram_id: $('#haproxy_server_telegram_channel-'+id+' option:selected' ).val(),
+ slack_id: $('#haproxy_server_slack_channel-'+id+' option:selected').val(),
+ token: $('#token').val()
+ },
+ type: "POST",
+ success: function( data ) {
+ data = data.replace(/\s+/g,' ');
+ if (data.indexOf('error:') != '-1' || data.indexOf('unique') != '-1') {
+ toastr.error(data);
+ } else if (data.indexOf('ok') != '-1') {
+ toastr.clear();
+ $("#haproxy_server_tr_id-"+id).addClass( "update", 1000 );
+ setTimeout(function() {
+ $( "#haproxy_server_tr_id-"+id ).removeClass( "update" );
+ }, 2500 );
+ }
+ }
+ } );
+}
+function updateKeepalivedCheckerSettings(id) {
+ toastr.clear();
+ let email = 0;
+ let server = 0;
+ let backend = 0;
+ if ($('#keepalived_server_email-'+id).is(':checked')) {
+ email = '1';
+ }
+ if ($('#keepalived_server_status-'+id).is(':checked')) {
+ server = '1';
+ }
+ if ($('#keepalived_server_backend-'+id).is(':checked')) {
+ backend = '1';
+ }
+
+ $.ajax( {
+ url: "options.py",
+ data: {
+ updateKeepalivedCheckerSettings: id,
+ email: email,
+ server: server,
+ backend: backend,
+ telegram_id: $('#keepalived_server_telegram_channel-'+id+' option:selected' ).val(),
+ slack_id: $('#keepalived_server_slack_channel-'+id+' option:selected').val(),
+ token: $('#token').val()
+ },
+ type: "POST",
+ success: function( data ) {
+ data = data.replace(/\s+/g,' ');
+ if (data.indexOf('error:') != '-1' || data.indexOf('unique') != '-1') {
+ toastr.error(data);
+ } else if (data.indexOf('ok') != '-1') {
+ toastr.clear();
+ $("#keepalived_server_tr_id-"+id).addClass( "update", 1000 );
+ setTimeout(function() {
+ $( "#keepalived_server_tr_id-"+id ).removeClass( "update" );
+ }, 2500 );
+ }
+ }
+ } );
+}
+function updateServiceCheckerSettings(id, service_name) {
+ toastr.clear();
+ let email = 0;
+ let server = 0;
+ if ($('#'+service_name+'_server_email-'+id).is(':checked')) {
+ email = '1';
+ }
+ if ($('#'+service_name+'_server_status-'+id).is(':checked')) {
+ server = '1';
+ }
+ $.ajax( {
+ url: "options.py",
+ data: {
+ updateServiceCheckerSettings: id,
+ email: email,
+ server: server,
+ telegram_id: $('#'+service_name+'_server_telegram_channel-'+id+' option:selected' ).val(),
+ slack_id: $('#'+service_name+'_server_slack_channel-'+id+' option:selected').val(),
+ token: $('#token').val()
+ },
+ type: "POST",
+ success: function( data ) {
+ data = data.replace(/\s+/g,' ');
+ if (data.indexOf('error:') != '-1' || data.indexOf('unique') != '-1') {
+ toastr.error(data);
+ } else if (data.indexOf('ok') != '-1') {
+ toastr.clear();
+ $('#'+service_name+'_server_tr_id-'+id).addClass( "update", 1000 );
+ setTimeout(function() {
+ $('#'+service_name+'_server_tr_id-'+id ).removeClass( "update" );
+ }, 2500 );
+ }
+ }
+ } );
+}
+function checkWebPanel() {
+ $.ajax({
+ url: "options.py",
+ data: {
+ check_rabbitmq_alert: 1,
+ token: $('#token').val()
+ },
+ type: "POST",
+ success: function (data) {
+ data = data.replace(/\s+/g, ' ');
+ if (data.indexOf('error:') != '-1' || data.indexOf('error_code') != '-1') {
+ toastr.error(data);
+ } else {
+ toastr.success('Test message has been sent');
+ }
+ }
+ });
+}
+function checkEmail() {
+ $.ajax({
+ url: "options.py",
+ data: {
+ check_email_alert: 1,
+ token: $('#token').val()
+ },
+ type: "POST",
+ success: function (data) {
+ data = data.replace(/\s+/g, ' ');
+ if (data.indexOf('error:') != '-1' || data.indexOf('error_code') != '-1') {
+ toastr.error(data);
+ } else {
+ toastr.success('Test message has been sent');
+ }
+ }
+ });
+}