mirror of https://github.com/Aidaho12/haproxy-wi
parent
1e34e0b996
commit
c1a4daa5a6
|
@ -65,6 +65,7 @@ def default_values():
|
|||
{'param': 'portscanner_keep_history_range', 'value': '14', 'section': 'monitoring', 'desc': 'Retention period for Port scanner history', 'group': '1'},
|
||||
{'param': 'smon_keep_history_range', 'value': '14', 'section': 'monitoring', 'desc': 'Retention period for SMON history', 'group': '1'},
|
||||
{'param': 'checker_keep_history_range', 'value': '14', 'section': 'monitoring', 'desc': 'Retention period for Checker history', 'group': '1'},
|
||||
{'param': 'action_keep_history_range', 'value': '30', 'section': 'monitoring', 'desc': 'Retention period for Action history', 'group': '1'},
|
||||
{'param': 'checker_maxconn_threshold', 'value': '90', 'section': 'monitoring', 'desc': 'Threshold value for alerting, in %', 'group': '1'},
|
||||
{'param': 'checker_check_interval', 'value': '1', 'section': 'monitoring', 'desc': 'Check interval for Checker (in minutes)', 'group': '1'},
|
||||
{'param': 'smon_ssl_expire_warning_alert', 'value': '14', 'section': 'monitoring', 'desc': 'Warning alert about a SSL certificate expiration (in days)', 'group': '1'},
|
||||
|
@ -811,9 +812,25 @@ def update_db_v_6_3_9():
|
|||
print("Updating... DB has been updated to version 6.3.9")
|
||||
|
||||
|
||||
def update_db_v_6_3_11():
|
||||
cursor = conn.cursor()
|
||||
sql = """
|
||||
ALTER TABLE `smon` ADD COLUMN pd_channel_id integer default 0;
|
||||
"""
|
||||
try:
|
||||
cursor.execute(sql)
|
||||
except Exception as e:
|
||||
if e.args[0] == 'duplicate column name: pd_channel_id' or str(e) == '(1060, "Duplicate column name \'pd_channel_id\'")':
|
||||
print('Updating... DB has been updated to version 6.3.11')
|
||||
else:
|
||||
print("An error occurred:", e)
|
||||
else:
|
||||
print("Updating... DB has been updated to version 6.3.11")
|
||||
|
||||
|
||||
def update_ver():
|
||||
try:
|
||||
Version.update(version='6.3.10.0').execute()
|
||||
Version.update(version='6.3.11.0').execute()
|
||||
except Exception:
|
||||
print('Cannot update version')
|
||||
|
||||
|
@ -842,6 +859,7 @@ def update_all():
|
|||
update_db_v_6_3_6()
|
||||
update_db_v_6_3_8()
|
||||
update_db_v_6_3_9()
|
||||
update_db_v_6_3_11()
|
||||
update_ver()
|
||||
|
||||
|
||||
|
|
|
@ -40,6 +40,11 @@ except Exception as e:
|
|||
user_subscription = roxywi_common.return_unsubscribed_user_status()
|
||||
roxywi_common.logging('Roxy-WI server', f'Cannot get a user plan: {e}', roxywi=1)
|
||||
|
||||
try:
|
||||
sql.delete_action_history_for_period()
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
rendered_template = template.render(
|
||||
h2=1, autorefresh=0, role=user_params['role'], user=user_params['user'], users=users, serv=serv,
|
||||
service=service, history=history, user_services=user_params['user_services'], token=user_params['token'],
|
||||
|
|
|
@ -431,6 +431,7 @@ class SMON(BaseModel):
|
|||
ssl_expire_warning_alert = IntegerField(constraints=[SQL('DEFAULT 0')])
|
||||
ssl_expire_critical_alert = IntegerField(constraints=[SQL('DEFAULT 0')])
|
||||
ssl_expire_date = CharField(null=True)
|
||||
pd_channel_id = IntegerField(null=True)
|
||||
|
||||
class Meta:
|
||||
table_name = 'smon'
|
||||
|
|
|
@ -48,7 +48,7 @@ def get_setting(param, **kwargs):
|
|||
'ldap_port', 'ldap_enable', 'log_time_storage', 'syslog_server_enable', 'smon_check_interval',
|
||||
'checker_check_interval', 'port_scan_interval', 'smon_keep_history_range', 'checker_keep_history_range',
|
||||
'portscanner_keep_history_range', 'checker_maxconn_threshold', 'apache_stats_port', 'smon_ssl_expire_warning_alert',
|
||||
'smon_ssl_expire_critical_alert'
|
||||
'smon_ssl_expire_critical_alert', 'action_keep_history_range'
|
||||
):
|
||||
return int(setting.value)
|
||||
else:
|
||||
|
@ -2474,7 +2474,7 @@ def check_token_exists(token):
|
|||
return False
|
||||
|
||||
|
||||
def insert_smon(server, port, enable, proto, uri, body, group, desc, telegram, slack, user_group):
|
||||
def insert_smon(server, port, enable, proto, uri, body, group, desc, telegram, slack, pd, user_group):
|
||||
try:
|
||||
http = proto + ':' + uri
|
||||
except Exception:
|
||||
|
@ -2483,7 +2483,7 @@ def insert_smon(server, port, enable, proto, uri, body, group, desc, telegram, s
|
|||
try:
|
||||
last_id = SMON.insert(
|
||||
ip=server, port=port, en=enable, desc=desc, group=group, http=http, body=body,
|
||||
telegram_channel_id=telegram, slack_channel_id=slack, user_group=user_group, status='3'
|
||||
telegram_channel_id=telegram, slack_channel_id=slack, pd_channel_id=pd, user_group=user_group, status='3'
|
||||
).execute()
|
||||
except Exception as e:
|
||||
out_error(e)
|
||||
|
@ -2508,11 +2508,11 @@ def select_smon(user_group, **kwargs):
|
|||
http = kwargs.get('proto') + ':' + kwargs.get('uri')
|
||||
except Exception:
|
||||
http = ''
|
||||
sql = """select id, ip, port, en, http, body, telegram_channel_id, `desc`, `group`, user_group, slack_channel_id from smon
|
||||
sql = """select id, ip, port, en, http, body, telegram_channel_id, `desc`, `group`, user_group, slack_channel_id, pd_channel_id from smon
|
||||
where ip='%s' and port='%s' and http='%s' and body='%s' %s
|
||||
""" % (kwargs.get('ip'), kwargs.get('port'), http, body, user_group)
|
||||
elif kwargs.get('action') == 'add':
|
||||
sql = """select id, ip, port, en, http, body, telegram_channel_id, `desc`, `group`, user_group, slack_channel_id from smon
|
||||
sql = """select id, ip, port, en, http, body, telegram_channel_id, `desc`, `group`, user_group, slack_channel_id, pd_channel_id from smon
|
||||
%s order by `group`""" % user_group
|
||||
else:
|
||||
sql = """select * from `smon` %s """ % user_group
|
||||
|
@ -2527,7 +2527,7 @@ def select_smon(user_group, **kwargs):
|
|||
|
||||
def select_smon_by_id(last_id):
|
||||
cursor = conn.cursor()
|
||||
sql = """select id, ip, port, en, http, body, telegram_channel_id, `desc`, `group`, user_group, slack_channel_id
|
||||
sql = """select id, ip, port, en, http, body, telegram_channel_id, `desc`, `group`, user_group, slack_channel_id, pd_channel_id
|
||||
from `smon` where id = {} """.format(last_id)
|
||||
|
||||
try:
|
||||
|
@ -2549,9 +2549,9 @@ def delete_smon(smon_id, user_group):
|
|||
return True
|
||||
|
||||
|
||||
def update_smon(smon_id, ip, port, body, telegram, slack, group, desc, en):
|
||||
def update_smon(smon_id, ip, port, body, telegram, slack, pd, group, desc, en):
|
||||
query = (SMON.update(
|
||||
ip=ip, port=port, body=body, telegram_channel_id=telegram, slack_channel_id=slack, group=group, desc=desc, en=en
|
||||
ip=ip, port=port, body=body, telegram_channel_id=telegram, slack_channel_id=slack, pd_channel_id=pd, group=group, desc=desc, en=en
|
||||
).where(SMON.id == smon_id))
|
||||
try:
|
||||
query.execute()
|
||||
|
@ -3479,6 +3479,16 @@ def delete_action_history(server_id: int):
|
|||
return True
|
||||
|
||||
|
||||
def delete_action_history_for_period():
|
||||
time_period = get_setting('action_keep_history_range')
|
||||
cur_date = get_date.return_date('regular', timedelta_minus=time_period)
|
||||
query = ActionHistory.delete().where(ActionHistory.date < cur_date)
|
||||
try:
|
||||
query.execute()
|
||||
except Exception as e:
|
||||
out_error(e)
|
||||
|
||||
|
||||
def select_action_history_by_server_id(server_id: int):
|
||||
query = ActionHistory.select().where(ActionHistory.server_id == server_id)
|
||||
try:
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
NAME = 'roxy-wi-tools-module'
|
|
@ -0,0 +1,110 @@
|
|||
from jinja2 import Environment, FileSystemLoader
|
||||
|
||||
import modules.db.sql as sql
|
||||
import modules.common.common as common
|
||||
import modules.roxywi.common as roxywi_common
|
||||
|
||||
form = common.form
|
||||
|
||||
|
||||
def create_smon() -> None:
|
||||
user_group = roxywi_common.get_user_group(id=1)
|
||||
server = common.checkAjaxInput(form.getvalue('newsmon'))
|
||||
port = common.checkAjaxInput(form.getvalue('newsmonport'))
|
||||
enable = common.checkAjaxInput(form.getvalue('newsmonenable'))
|
||||
http = common.checkAjaxInput(form.getvalue('newsmonproto'))
|
||||
uri = common.checkAjaxInput(form.getvalue('newsmonuri'))
|
||||
body = common.checkAjaxInput(form.getvalue('newsmonbody'))
|
||||
group = common.checkAjaxInput(form.getvalue('newsmongroup'))
|
||||
desc = common.checkAjaxInput(form.getvalue('newsmondescription'))
|
||||
telegram = common.checkAjaxInput(form.getvalue('newsmontelegram'))
|
||||
slack = common.checkAjaxInput(form.getvalue('newsmonslack'))
|
||||
pd = common.checkAjaxInput(form.getvalue('newsmonpd'))
|
||||
|
||||
try:
|
||||
port = int(port)
|
||||
except Exception:
|
||||
print('SMON error: port must number')
|
||||
return None
|
||||
if port > 65535 or port < 0:
|
||||
print('SMON error: port must be 0-65535')
|
||||
return None
|
||||
if port == 80 and http == 'https':
|
||||
print('SMON error: Cannot be HTTPS with 80 port')
|
||||
return None
|
||||
if port == 443 and http == 'http':
|
||||
print('SMON error: Cannot be HTTP with 443 port')
|
||||
return None
|
||||
|
||||
last_id = sql.insert_smon(server, port, enable, http, uri, body, group, desc, telegram, slack, pd, user_group)
|
||||
if last_id:
|
||||
lang = roxywi_common.get_user_lang()
|
||||
smon = sql.select_smon_by_id(last_id)
|
||||
pds = sql.get_user_pd_by_group(user_group)
|
||||
slacks = sql.get_user_slack_by_group(user_group)
|
||||
telegrams = sql.get_user_telegram_by_group(user_group)
|
||||
env = Environment(loader=FileSystemLoader('templates'), autoescape=True)
|
||||
template = env.get_template('ajax/show_new_smon.html')
|
||||
template = template.render(smon=smon, telegrams=telegrams, slacks=slacks, pds=pds, lang=lang)
|
||||
print(template)
|
||||
roxywi_common.logging('SMON', f' A new server {server} to SMON has been add ', roxywi=1, login=1)
|
||||
|
||||
|
||||
def update_smon() -> None:
|
||||
smon_id = common.checkAjaxInput(form.getvalue('id'))
|
||||
ip = common.checkAjaxInput(form.getvalue('updateSmonIp'))
|
||||
port = common.checkAjaxInput(form.getvalue('updateSmonPort'))
|
||||
en = common.checkAjaxInput(form.getvalue('updateSmonEn'))
|
||||
http = common.checkAjaxInput(form.getvalue('updateSmonHttp'))
|
||||
body = common.checkAjaxInput(form.getvalue('updateSmonBody'))
|
||||
telegram = common.checkAjaxInput(form.getvalue('updateSmonTelegram'))
|
||||
slack = common.checkAjaxInput(form.getvalue('updateSmonSlack'))
|
||||
pd = common.checkAjaxInput(form.getvalue('updateSmonPD'))
|
||||
group = common.checkAjaxInput(form.getvalue('updateSmonGroup'))
|
||||
desc = common.checkAjaxInput(form.getvalue('updateSmonDesc'))
|
||||
|
||||
try:
|
||||
port = int(port)
|
||||
except Exception:
|
||||
print('SMON error: port must number')
|
||||
return None
|
||||
if port > 65535 or port < 0:
|
||||
print('SMON error: port must be 0-65535')
|
||||
return None
|
||||
if port == 80 and http == 'https':
|
||||
print('SMON error: Cannot be https with 80 port')
|
||||
return None
|
||||
if port == 443 and http == 'http':
|
||||
print('SMON error: Cannot be HTTP with 443 port')
|
||||
return None
|
||||
|
||||
roxywi_common.check_user_group()
|
||||
try:
|
||||
if sql.update_smon(smon_id, ip, port, body, telegram, slack, pd, group, desc, en):
|
||||
print("Ok")
|
||||
roxywi_common.logging('SMON', f' The SMON server {ip} has been update ', roxywi=1, login=1)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
|
||||
def show_smon() -> None:
|
||||
user_group = roxywi_common.get_user_group(id=1)
|
||||
lang = roxywi_common.get_user_lang()
|
||||
sort = common.checkAjaxInput(form.getvalue('sort'))
|
||||
env = Environment(loader=FileSystemLoader('templates'), autoescape=True)
|
||||
template = env.get_template('ajax/smon_dashboard.html')
|
||||
template = template.render(smon=sql.smon_list(user_group), sort=sort, lang=lang, update=1)
|
||||
print(template)
|
||||
|
||||
|
||||
def delete_smon() -> None:
|
||||
user_group = roxywi_common.get_user_group(id=1)
|
||||
smon_id = common.checkAjaxInput(form.getvalue('smondel'))
|
||||
|
||||
if roxywi_common.check_user_group():
|
||||
try:
|
||||
if sql.delete_smon(smon_id, user_group):
|
||||
print('Ok')
|
||||
roxywi_common.logging('SMON', ' The server from SMON has been delete ', roxywi=1, login=1)
|
||||
except Exception as e:
|
||||
print(e)
|
169
app/options.py
169
app/options.py
|
@ -27,16 +27,10 @@ serv = common.is_ip_or_dns(form.getvalue('serv'))
|
|||
act = form.getvalue("act")
|
||||
token = form.getvalue("token")
|
||||
|
||||
if (
|
||||
form.getvalue('new_metrics')
|
||||
or form.getvalue('new_http_metrics')
|
||||
or form.getvalue('new_waf_metrics')
|
||||
or form.getvalue('new_nginx_metrics')
|
||||
or form.getvalue('new_apache_metrics')
|
||||
or form.getvalue('metrics_hapwi_ram')
|
||||
or form.getvalue('metrics_hapwi_cpu')
|
||||
or form.getvalue('getoption')
|
||||
or form.getvalue('getsavedserver')
|
||||
if any((
|
||||
form.getvalue('new_metrics'), form.getvalue('new_http_metrics'), form.getvalue('new_waf_metrics'), form.getvalue('new_nginx_metrics'),
|
||||
form.getvalue('new_apache_metrics'), form.getvalue('metrics_hapwi_ram'), form.getvalue('metrics_hapwi_cpu'), form.getvalue('getoption'),
|
||||
form.getvalue('getsavedserver'))
|
||||
):
|
||||
print('Content-type: application/json\n')
|
||||
else:
|
||||
|
@ -500,8 +494,7 @@ if form.getvalue('git_backup'):
|
|||
print(template)
|
||||
print('success: Git job has been created')
|
||||
roxywi_common.logging(
|
||||
server_ip, ' A new git job has been created', roxywi=1, login=1,
|
||||
keep_history=1, service=service_name
|
||||
server_ip, ' A new git job has been created', roxywi=1, login=1, keep_history=1, service=service_name
|
||||
)
|
||||
else:
|
||||
if sql.delete_git(form.getvalue('git_backup')):
|
||||
|
@ -801,8 +794,7 @@ if form.getvalue('updateserver') is not None:
|
|||
sql.update_server(name, group, typeip, enable, master, serv_id, cred, port, desc, firewall, protected)
|
||||
roxywi_common.logging(f'the server {name}', ' has been updated ', roxywi=1, login=1)
|
||||
server_ip = sql.select_server_ip_by_id(serv_id)
|
||||
roxywi_common.logging(server_ip, f'The server {name} has been update', roxywi=1, login=1,
|
||||
keep_history=1, service='server')
|
||||
roxywi_common.logging(server_ip, f'The server {name} has been update', roxywi=1, login=1, keep_history=1, service='server')
|
||||
|
||||
if form.getvalue('serverdel') is not None:
|
||||
server_id = common.checkAjaxInput(form.getvalue('serverdel'))
|
||||
|
@ -893,8 +885,7 @@ if form.getvalue('updatesettings') is not None:
|
|||
val = common.checkAjaxInput(form.getvalue('val'))
|
||||
user_group = roxywi_common.get_user_group(id=1)
|
||||
if sql.update_setting(settings, val, user_group):
|
||||
roxywi_common.logging('Roxy-WI server', f'The {settings} setting has been changed to: {val}', roxywi=1,
|
||||
login=1)
|
||||
roxywi_common.logging('Roxy-WI server', f'The {settings} setting has been changed to: {val}', roxywi=1, login=1)
|
||||
print("Ok")
|
||||
|
||||
if form.getvalue('getuserservices'):
|
||||
|
@ -932,102 +923,24 @@ if form.getvalue('getcurrentusergroup') is not None:
|
|||
roxy_user.get_user_active_group(user_id, group)
|
||||
|
||||
if form.getvalue('newsmon') is not None:
|
||||
user_group = roxywi_common.get_user_group(id=1)
|
||||
server = common.checkAjaxInput(form.getvalue('newsmon'))
|
||||
port = common.checkAjaxInput(form.getvalue('newsmonport'))
|
||||
enable = common.checkAjaxInput(form.getvalue('newsmonenable'))
|
||||
http = common.checkAjaxInput(form.getvalue('newsmonproto'))
|
||||
uri = common.checkAjaxInput(form.getvalue('newsmonuri'))
|
||||
body = common.checkAjaxInput(form.getvalue('newsmonbody'))
|
||||
group = common.checkAjaxInput(form.getvalue('newsmongroup'))
|
||||
desc = common.checkAjaxInput(form.getvalue('newsmondescription'))
|
||||
telegram = common.checkAjaxInput(form.getvalue('newsmontelegram'))
|
||||
slack = common.checkAjaxInput(form.getvalue('newsmonslack'))
|
||||
import modules.tools.smon as smon_mod
|
||||
|
||||
try:
|
||||
port = int(port)
|
||||
except Exception:
|
||||
print('SMON error: port must number')
|
||||
sys.exit()
|
||||
if port > 65535 or port < 0:
|
||||
print('SMON error: port must be 0-65535')
|
||||
sys.exit()
|
||||
if port == 80 and http == 'https':
|
||||
print('SMON error: Cannot be HTTPS with 80 port')
|
||||
sys.exit()
|
||||
if port == 443 and http == 'http':
|
||||
print('SMON error: Cannot be HTTP with 443 port')
|
||||
sys.exit()
|
||||
|
||||
last_id = sql.insert_smon(server, port, enable, http, uri, body, group, desc, telegram, slack, user_group)
|
||||
if last_id:
|
||||
lang = roxywi_common.get_user_lang()
|
||||
env = Environment(loader=FileSystemLoader('templates'), autoescape=True)
|
||||
template = env.get_template('ajax/show_new_smon.html')
|
||||
template = template.render(
|
||||
smon=sql.select_smon_by_id(last_id),
|
||||
telegrams=sql.get_user_telegram_by_group(user_group),
|
||||
slacks=sql.get_user_slack_by_group(user_group),
|
||||
lang=lang
|
||||
)
|
||||
print(template)
|
||||
roxywi_common.logging('SMON', f' Has been add a new server {server} to SMON ', roxywi=1, login=1)
|
||||
smon_mod.create_smon()
|
||||
|
||||
if form.getvalue('smondel') is not None:
|
||||
user_group = roxywi_common.get_user_group(id=1)
|
||||
smon_id = common.checkAjaxInput(form.getvalue('smondel'))
|
||||
import modules.tools.smon as smon_mod
|
||||
|
||||
if roxywi_common.check_user_group():
|
||||
try:
|
||||
if sql.delete_smon(smon_id, user_group):
|
||||
print('Ok')
|
||||
roxywi_common.logging('SMON', ' Has been delete server from SMON ', roxywi=1, login=1)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
smon_mod.delete_smon()
|
||||
|
||||
if form.getvalue('showsmon') is not None:
|
||||
user_group = roxywi_common.get_user_group(id=1)
|
||||
lang = roxywi_common.get_user_lang()
|
||||
sort = common.checkAjaxInput(form.getvalue('sort'))
|
||||
env = Environment(loader=FileSystemLoader('templates'), autoescape=True)
|
||||
template = env.get_template('ajax/smon_dashboard.html')
|
||||
template = template.render(smon=sql.smon_list(user_group), sort=sort, lang=lang, update=1)
|
||||
print(template)
|
||||
import modules.tools.smon as smon_mod
|
||||
|
||||
smon_mod.show_smon()
|
||||
|
||||
if form.getvalue('updateSmonIp') is not None:
|
||||
smon_id = common.checkAjaxInput(form.getvalue('id'))
|
||||
ip = common.checkAjaxInput(form.getvalue('updateSmonIp'))
|
||||
port = common.checkAjaxInput(form.getvalue('updateSmonPort'))
|
||||
en = common.checkAjaxInput(form.getvalue('updateSmonEn'))
|
||||
http = common.checkAjaxInput(form.getvalue('updateSmonHttp'))
|
||||
body = common.checkAjaxInput(form.getvalue('updateSmonBody'))
|
||||
telegram = common.checkAjaxInput(form.getvalue('updateSmonTelegram'))
|
||||
slack = common.checkAjaxInput(form.getvalue('updateSmonSlack'))
|
||||
group = common.checkAjaxInput(form.getvalue('updateSmonGroup'))
|
||||
desc = common.checkAjaxInput(form.getvalue('updateSmonDesc'))
|
||||
import modules.tools.smon as smon_mod
|
||||
|
||||
try:
|
||||
port = int(port)
|
||||
except Exception:
|
||||
print('SMON error: port must number')
|
||||
sys.exit()
|
||||
if port > 65535 or port < 0:
|
||||
print('SMON error: port must be 0-65535')
|
||||
sys.exit()
|
||||
if port == 80 and http == 'https':
|
||||
print('SMON error: Cannot be https with 80 port')
|
||||
sys.exit()
|
||||
if port == 443 and http == 'http':
|
||||
print('SMON error: Cannot be HTTP with 443 port')
|
||||
sys.exit()
|
||||
|
||||
roxywi_common.check_user_group()
|
||||
try:
|
||||
if sql.update_smon(smon_id, ip, port, body, telegram, slack, group, desc, en):
|
||||
print("Ok")
|
||||
roxywi_common.logging('SMON', f' Has been update the server {ip} to SMON ', roxywi=1, login=1)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
smon_mod.update_smon()
|
||||
|
||||
if form.getvalue('showBytes') is not None:
|
||||
import modules.roxywi.overview as roxywi_overview
|
||||
|
@ -1079,7 +992,7 @@ if form.getvalue('uploadovpn'):
|
|||
conf.write(form.getvalue('uploadovpn'))
|
||||
except IOError as e:
|
||||
print(str(e))
|
||||
print('error: Can\'t save ovpn file')
|
||||
print('error: Cannot save ovpn file')
|
||||
else:
|
||||
print('success: ovpn file has been saved </div>')
|
||||
|
||||
|
@ -1095,7 +1008,7 @@ if form.getvalue('uploadovpn'):
|
|||
except IOError as e:
|
||||
roxywi_common.logging('Roxy-WI server', e.args[0], roxywi=1)
|
||||
|
||||
roxywi_common.logging("Roxy-WI server", " has been uploaded a new ovpn file %s" % ovpn_file, roxywi=1, login=1)
|
||||
roxywi_common.logging("Roxy-WI server", f" has been uploaded a new ovpn file {ovpn_file}", roxywi=1, login=1)
|
||||
|
||||
if form.getvalue('openvpndel') is not None:
|
||||
openvpndel = common.checkAjaxInput(form.getvalue('openvpndel'))
|
||||
|
@ -1114,15 +1027,18 @@ if form.getvalue('actionvpn') is not None:
|
|||
action = common.checkAjaxInput(form.getvalue('actionvpn'))
|
||||
|
||||
if action == 'start':
|
||||
cmd = 'sudo openvpn3 session-start --config /tmp/%s.ovpn' % openvpn
|
||||
cmd = f'sudo openvpn3 session-start --config /tmp/{openvpn}.ovpn'
|
||||
elif action == 'restart':
|
||||
cmd = 'sudo openvpn3 session-manage --config /tmp/%s.ovpn --restart' % openvpn
|
||||
cmd = f'sudo openvpn3 session-manage --config /tmp/{openvpn}.ovpn --restart'
|
||||
elif action == 'disconnect':
|
||||
cmd = 'sudo openvpn3 session-manage --config /tmp/%s.ovpn --disconnect' % openvpn
|
||||
cmd = f'sudo openvpn3 session-manage --config /tmp/{openvpn}.ovpn --disconnect'
|
||||
else:
|
||||
print('error: wrong action')
|
||||
sys.exit()
|
||||
try:
|
||||
server_mod.subprocess_execute(cmd)
|
||||
print("success: The " + openvpn + " has been " + action + "ed")
|
||||
roxywi_common.logging(openvpn, ' has ' + action + ' the ovpn session ', roxywi=1, login=1)
|
||||
print(f"success: The {openvpn} has been {action}ed")
|
||||
roxywi_common.logging(openvpn, f' The ovpn session has been {action}ed ', roxywi=1, login=1)
|
||||
except IOError as e:
|
||||
print(e.args[0])
|
||||
roxywi_common.logging('Roxy-WI server', e.args[0], roxywi=1)
|
||||
|
@ -1135,8 +1051,8 @@ if form.getvalue('scan_ports') is not None:
|
|||
for s in server:
|
||||
ip = s[2]
|
||||
|
||||
cmd = "sudo nmap -sS %s |grep -E '^[[:digit:]]'|sed 's/ */ /g'" % ip
|
||||
cmd1 = "sudo nmap -sS %s |head -5|tail -2" % ip
|
||||
cmd = f"sudo nmap -sS {ip} |grep -E '^[[:digit:]]'|sed 's/ */ /g'"
|
||||
cmd1 = f"sudo nmap -sS {ip} |head -5|tail -2"
|
||||
|
||||
stdout, stderr = server_mod.subprocess_execute(cmd)
|
||||
stdout1, stderr1 = server_mod.subprocess_execute(cmd1)
|
||||
|
@ -1158,7 +1074,6 @@ if form.getvalue('geoipserv') is not None:
|
|||
service = common.checkAjaxInput(form.getvalue('geoip_service'))
|
||||
if service in ('haproxy', 'nginx'):
|
||||
service_dir = common.return_nice_path(sql.get_setting(f'{service}_dir'))
|
||||
|
||||
cmd = [f"ls {service_dir}geoip/"]
|
||||
print(server_mod.ssh_command(serv, cmd))
|
||||
else:
|
||||
|
@ -2223,10 +2138,10 @@ if act == 'showListOfVersion':
|
|||
for_delver = common.checkAjaxInput(form.getvalue('for_delver'))
|
||||
users = sql.select_users()
|
||||
service_desc = sql.select_service(service)
|
||||
configs = sql.select_config_version(serv, service_desc.slug)
|
||||
lang = roxywi_common.get_user_lang()
|
||||
|
||||
if service in ('haproxy', 'nginx', 'keepalived', 'apache'):
|
||||
configs = sql.select_config_version(serv, service_desc.slug)
|
||||
action = f'versions.py?service={service_desc.slug}'
|
||||
|
||||
if service in ('haproxy', 'nginx', 'apache'):
|
||||
|
@ -2239,20 +2154,20 @@ if act == 'showListOfVersion':
|
|||
else:
|
||||
files = roxywi_common.get_files(configs_dir, 'conf')
|
||||
|
||||
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True,
|
||||
extensions=["jinja2.ext.loopcontrols", "jinja2.ext.do"])
|
||||
template = env.get_template('ajax/show_list_version.html')
|
||||
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True,
|
||||
extensions=["jinja2.ext.loopcontrols", "jinja2.ext.do"])
|
||||
template = env.get_template('ajax/show_list_version.html')
|
||||
|
||||
template = template.render(serv=serv,
|
||||
service=service,
|
||||
action=action,
|
||||
return_files=files,
|
||||
configver=configver,
|
||||
for_delver=for_delver,
|
||||
configs=configs,
|
||||
users=users,
|
||||
lang=lang)
|
||||
print(template)
|
||||
template = template.render(serv=serv,
|
||||
service=service,
|
||||
action=action,
|
||||
return_files=files,
|
||||
configver=configver,
|
||||
for_delver=for_delver,
|
||||
configs=configs,
|
||||
users=users,
|
||||
lang=lang)
|
||||
print(template)
|
||||
|
||||
if act == 'getSystemInfo':
|
||||
server_mod.show_system_info()
|
||||
|
|
13
app/smon.py
13
app/smon.py
|
@ -27,13 +27,18 @@ action = form.getvalue('action')
|
|||
sort = form.getvalue('sort')
|
||||
autorefresh = 0
|
||||
lang = user_params['lang']
|
||||
|
||||
telegrams = ''
|
||||
slacks = ''
|
||||
pds = ''
|
||||
user_group = roxywi_common.get_user_group(id=1)
|
||||
cmd = "systemctl is-active roxy-wi-smon"
|
||||
smon_status, stderr = server_mod.subprocess_execute(cmd)
|
||||
|
||||
|
||||
if action == 'add':
|
||||
telegrams = sql.get_user_telegram_by_group(user_group)
|
||||
slacks = sql.get_user_slack_by_group(user_group)
|
||||
pds = sql.get_user_pd_by_group(user_group)
|
||||
smon = sql.select_smon(user_group, action='add')
|
||||
roxywi_auth.page_for_admin(level=3)
|
||||
if lang == 'ru':
|
||||
|
@ -80,8 +85,8 @@ except Exception as e:
|
|||
|
||||
rendered_template = template.render(
|
||||
h2=1, title=title, autorefresh=autorefresh, role=user_params['role'], user=user_params['user'], group=user_group,
|
||||
telegrams=sql.get_user_telegram_by_group(user_group), slacks=sql.get_user_slack_by_group(user_group), lang=lang,
|
||||
smon=smon, smon_status=smon_status, smon_error=stderr, action=action, sort=sort, user_services=user_params['user_services'],
|
||||
user_status=user_subscription['user_status'], user_plan=user_subscription['user_plan'], token=user_params['token']
|
||||
telegrams=telegrams, slacks=slacks, pds=pds, lang=lang, smon=smon, smon_status=smon_status, smon_error=stderr,
|
||||
action=action, sort=sort, user_services=user_params['user_services'], user_status=user_subscription['user_status'],
|
||||
user_plan=user_subscription['user_plan'], token=user_params['token']
|
||||
)
|
||||
print(rendered_template)
|
||||
|
|
|
@ -7,21 +7,34 @@
|
|||
{% include 'include/no_sub.html' %}
|
||||
{% else %}
|
||||
<link href="/inc/css/table-6.3.9.css" rel="stylesheet" type="text/css">
|
||||
<link href="/inc/dataTables/buttons.dataTables.min.css" rel="stylesheet" type="text/css">
|
||||
<script type="text/javascript" charset="utf8" src="/inc/dataTables.min.js"></script>
|
||||
<script type="text/javascript" charset="utf8" src="/inc/dataTables/dataTables.buttons.min.js"></script>
|
||||
<script type="text/javascript" charset="utf8" src="/inc/dataTables/jszip.min.js"></script>
|
||||
<script type="text/javascript" charset="utf8" src="/inc/dataTables/pdfmake.min.js"></script>
|
||||
<script type="text/javascript" charset="utf8" src="/inc/dataTables/vfs_fonts.js"></script>
|
||||
<script type="text/javascript" charset="utf8" src="/inc/dataTables/buttons.html5.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#table_history').on('page.dt')
|
||||
.DataTable( {
|
||||
dom: 'Blfrtip',
|
||||
colReorder: true,
|
||||
"pageLength": 25,
|
||||
"order": [ 4, "desc" ],
|
||||
stateSave: true,
|
||||
"lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
|
||||
"columnDefs": [
|
||||
{
|
||||
"searchable": false,
|
||||
"orderable": false
|
||||
}
|
||||
],
|
||||
"lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]]
|
||||
buttons: [
|
||||
'excelHtml5',
|
||||
'csvHtml5',
|
||||
'pdfHtml5'
|
||||
],
|
||||
} );
|
||||
} );
|
||||
</script>
|
||||
|
|
|
@ -42,14 +42,15 @@
|
|||
<td class="addOption">
|
||||
{% if set.param in ('ldap_password', 'stats_password', 'nginx_stats_password', 'apache_stats_password', 'rabbitmq_password', 'mail_smtp_password') %}
|
||||
{% if set.value is none %}
|
||||
{{ input(set.param, size='25', type='password') }}
|
||||
{{ input(set.param, size='25', type='password', style='width: 210px;') }}
|
||||
{% else %}
|
||||
{{ input(set.param, size='25', type='password', placeholder='******') }}
|
||||
{{ input(set.param, size='25', type='password', style='width: 210px;', placeholder='******') }}
|
||||
{% endif %}
|
||||
{% elif set.param in ('nginx_stats_port', 'session_ttl', 'token_ttl', 'stats_port', 'haproxy_sock_port',
|
||||
'ldap_port', 'log_time_storage', 'smon_check_interval', 'checker_check_interval', 'port_scan_interval',
|
||||
'smon_keep_history_range', 'checker_keep_history_range', 'portscanner_keep_history_range',
|
||||
'checker_maxconn_threshold', 'apache_stats_port', 'mail_smtp_port', 'rabbitmq_port') %}
|
||||
'checker_maxconn_threshold', 'apache_stats_port', 'mail_smtp_port', 'rabbitmq_port', 'smon_ssl_expire_warning_alert',
|
||||
'smon_ssl_expire_critical_alert', 'action_keep_history_range') %}
|
||||
{{ input(set.param, value=set.value, style='width: 210px;', type='number') }}
|
||||
{% elif set.param == 'time_zone' %}
|
||||
<select name="{{set.param}}" id="{{set.param}}" style="width: 215px;">
|
||||
|
@ -69,9 +70,9 @@
|
|||
{% endif %}
|
||||
{% else %}
|
||||
{% if set.value is none %}
|
||||
{{ input(set.param, size='25') }}
|
||||
{{ input(set.param, size='25', style='width: 210px;') }}
|
||||
{% else %}
|
||||
{{ input(set.param, value=set.value, size='25') }}
|
||||
{{ input(set.param, value=set.value, size='25', style='width: 210px;') }}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</td>
|
||||
|
|
|
@ -61,6 +61,18 @@
|
|||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<select id="smon-pd-{{s.0}}">
|
||||
<option value="0">{{lang.words.disabled|title()}}</option>
|
||||
{% for t in pds %}
|
||||
{% if s.11|int() == t.id|int() %}
|
||||
<option value="{{t.id}}" selected>{{t.chanel_name}}</option>
|
||||
{% else %}
|
||||
<option value="{{t.id}}">{{t.chanel_name}}</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
{% set id = 'smon-group-' + s.0|string() %}
|
||||
{% if s.8 is not none %}
|
||||
|
@ -87,10 +99,13 @@
|
|||
<script>
|
||||
$( function() {
|
||||
$("#smon-telegram-{{s.0}}" ).selectmenu({
|
||||
width: 170
|
||||
width: 160
|
||||
});
|
||||
$("#smon-slack-{{s.0}}" ).selectmenu({
|
||||
width: 170
|
||||
width: 160
|
||||
});
|
||||
$("#smon-pd-{{s.0}}" ).selectmenu({
|
||||
width: 160
|
||||
});
|
||||
$("#smon-proto-{{s.0}}" ).selectmenu({
|
||||
width: 78
|
||||
|
|
|
@ -55,15 +55,17 @@
|
|||
{% if action == 'add' %}
|
||||
<table class="overview" id="ajax-smon">
|
||||
<thead>
|
||||
<caption><h3>TCP/UDP check</h3></caption>
|
||||
<tr class="overviewHead">
|
||||
<th class="padding10 first-collumn" style="width: 150px;">IP</th>
|
||||
<th class="padding10 first-collumn" style="width: 150px;">Hostname</th>
|
||||
<th style="width: 2%;">{{lang.words.port|title()}}</th>
|
||||
<th style="width: 5%;">{{lang.words.enabled|title()}}</th>
|
||||
<th style="width: 10%;">{{lang.words.protocol|title()}}</th>
|
||||
<th style="width: 15%;">URI</th>
|
||||
<th style="width: 20%;">{{lang.words.body|title()}}</th>
|
||||
<th style="width: 15%;">Telegram</th>
|
||||
<th style="width: 15%;">Slack</th>
|
||||
<th style="width: 11%;">Telegram</th>
|
||||
<th style="width: 11%;">Slack</th>
|
||||
<th style="width: 11%;">PagerDuty</th>
|
||||
<th style="width: 10%;">{{lang.words.group|title()}}</th>
|
||||
<th style="width: 100%;">{{lang.words.desc|title()}}</th>
|
||||
<th></th>
|
||||
|
@ -149,6 +151,17 @@
|
|||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="padding20">PagerDuty</td>
|
||||
<td>
|
||||
<select id="new-smon-pd">
|
||||
<option value="0">{{lang.words.disabled|title()}}</option>
|
||||
{% for t in pds %}
|
||||
<option value="{{t.id}}">{{t.chanel_name}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="padding20">{{lang.words.group|title()}}</td>
|
||||
<td>{{ input('new-smon-group') }}</td>
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -89,6 +89,7 @@ function addNewSmonServer(dialog_id) {
|
|||
newsmondescription: $('#new-smon-description').val(),
|
||||
newsmontelegram: $('#new-smon-telegram').val(),
|
||||
newsmonslack: $('#new-smon-slack').val(),
|
||||
newsmonpd: $('#new-smon-pd').val(),
|
||||
token: $('#token').val()
|
||||
},
|
||||
type: "POST",
|
||||
|
@ -166,6 +167,7 @@ function updateSmon(id) {
|
|||
updateSmonBody: $('#smon-body-'+id).text(),
|
||||
updateSmonTelegram: $('#smon-telegram-'+id).val(),
|
||||
updateSmonSlack: $('#smon-slack-'+id).val(),
|
||||
updateSmonPD: $('#smon-pd-'+id).val(),
|
||||
updateSmonGroup: $('#smon-group-'+id).val(),
|
||||
updateSmonDesc: $('#smon-desc-'+id).val(),
|
||||
id: id,
|
||||
|
@ -200,7 +202,10 @@ function cloneSmom(id) {
|
|||
$('#new-smon-description').val($('#smon-desc-'+id).val())
|
||||
$('#new-smon-telegram').val($('#smon-telegram-'+id+' option:selected').val()).change()
|
||||
$('#new-smon-slack').val($('#smon-slack-'+id+' option:selected').val()).change()
|
||||
$('#new-smon-pd').val($('#smon-pd-'+id+' option:selected').val()).change()
|
||||
$('#new-smon-telegram').selectmenu("refresh");
|
||||
$('#new-smon-slack').selectmenu("refresh");
|
||||
$('#new-smon-pd').selectmenu("refresh");
|
||||
}
|
||||
$( function() {
|
||||
$('#add-smon-button').click(function() {
|
||||
|
|
Loading…
Reference in New Issue