mirror of https://github.com/Aidaho12/haproxy-wi
parent
2324e7a0f3
commit
a905a2ae3e
|
@ -92,12 +92,6 @@ def create_table(**kwargs):
|
|||
metrics INTEGER NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY(`id`)
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS `roles_users` (
|
||||
`user_id` INTEGER,
|
||||
`role_id` INTEGER,
|
||||
FOREIGN KEY(`user_id`) REFERENCES `user`(`id`),
|
||||
FOREIGN KEY(`role_id`) REFERENCES `role`(`id`)
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS `role` (
|
||||
`id` INTEGER NOT NULL,
|
||||
`name` VARCHAR ( 80 ) UNIQUE,
|
||||
|
@ -123,11 +117,6 @@ def create_table(**kwargs):
|
|||
`password` VARCHAR ( 64 ) NOT NULL,
|
||||
groups INTEGER NOT NULL DEFAULT 1
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS `token` (
|
||||
`user_id` INTEGER,
|
||||
`token` varchar(64),
|
||||
`exp` DATETIME default '0000-00-00 00:00:00'
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS `uuid` (`user_id` INTEGER NOT NULL, `uuid` varchar ( 64 ),`exp` timestamp default '0000-00-00 00:00:00');
|
||||
CREATE TABLE IF NOT EXISTS `token` (`user_id` INTEGER, `token` varchar(64), `exp` timestamp default '0000-00-00 00:00:00');
|
||||
CREATE TABLE IF NOT EXISTS `telegram` (`id` integer primary key autoincrement, `token` VARCHAR ( 64 ), `chanel_name` INTEGER NOT NULL DEFAULT 1, `groups` INTEGER NOT NULL DEFAULT 1);
|
||||
|
|
76
app/funct.py
76
app/funct.py
|
@ -1,25 +1,18 @@
|
|||
# -*- coding: utf-8 -*-"
|
||||
import cgi
|
||||
import os, sys
|
||||
import paramiko
|
||||
import http.cookies
|
||||
from paramiko import SSHClient
|
||||
from datetime import datetime
|
||||
from pytz import timezone
|
||||
from configparser import ConfigParser, ExtendedInterpolation
|
||||
|
||||
form = cgi.FieldStorage()
|
||||
serv = form.getvalue('serv')
|
||||
|
||||
def get_app_dir():
|
||||
d = sys.path[0]
|
||||
d = d.split('/')[-1]
|
||||
if d == "app":
|
||||
return sys.path[0]
|
||||
else:
|
||||
return os.path.dirname(sys.path[0])
|
||||
d = d.split('/')[-1]
|
||||
return sys.path[0] if d == "app" else os.path.dirname(sys.path[0])
|
||||
|
||||
def get_config_var(sec, var):
|
||||
from configparser import ConfigParser, ExtendedInterpolation
|
||||
try:
|
||||
path_config = get_app_dir()+"/haproxy-webintarface.config"
|
||||
config = ConfigParser(interpolation=ExtendedInterpolation())
|
||||
|
@ -27,15 +20,15 @@ def get_config_var(sec, var):
|
|||
except:
|
||||
print('Content-type: text/html\n')
|
||||
print('<center><div class="alert alert-danger">Check the config file, whether it exists and the path. Must be: app/haproxy-webintarface.config</div>')
|
||||
|
||||
try:
|
||||
var = config.get(sec, var)
|
||||
return var
|
||||
return config.get(sec, var)
|
||||
except:
|
||||
print('Content-type: text/html\n')
|
||||
print('<center><div class="alert alert-danger">Check the config file. Presence section %s and parameter %s</div>' % (sec, var))
|
||||
|
||||
def get_data(type):
|
||||
from datetime import datetime
|
||||
from pytz import timezone
|
||||
import sql
|
||||
now_utc = datetime.now(timezone(sql.get_setting('time_zone')))
|
||||
if type == 'config':
|
||||
|
@ -85,13 +78,12 @@ def telegram_send_mess(mess, **kwargs):
|
|||
import sql
|
||||
|
||||
telegrams = sql.get_telegram_by_ip(kwargs.get('ip'))
|
||||
proxy = sql.get_setting('proxy')
|
||||
|
||||
for telegram in telegrams:
|
||||
token_bot = telegram[1]
|
||||
channel_name = telegram[2]
|
||||
|
||||
proxy = sql.get_setting('proxy')
|
||||
|
||||
|
||||
if proxy is not None:
|
||||
apihelper.proxy = {'https': proxy}
|
||||
try:
|
||||
|
@ -131,20 +123,15 @@ def is_admin(**kwargs):
|
|||
level = 1
|
||||
|
||||
try:
|
||||
if role <= level:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
return True if role <= level else False
|
||||
except:
|
||||
return False
|
||||
pass
|
||||
|
||||
def page_for_admin(**kwargs):
|
||||
give_level = 1
|
||||
give_level = kwargs.get("level")
|
||||
|
||||
if give_level is None:
|
||||
give_level = 1
|
||||
|
||||
|
||||
if not is_admin(level = give_level):
|
||||
print('<center><h3 style="color: red">How did you get here?! O_o You do not have need permissions</h>')
|
||||
print('<meta http-equiv="refresh" content="10; url=/">')
|
||||
|
@ -152,6 +139,8 @@ def page_for_admin(**kwargs):
|
|||
sys.exit()
|
||||
|
||||
def ssh_connect(serv, **kwargs):
|
||||
import paramiko
|
||||
from paramiko import SSHClient
|
||||
import sql
|
||||
fullpath = get_config_var('main', 'fullpath')
|
||||
for sshs in sql.select_ssh(serv=serv):
|
||||
|
@ -196,12 +185,8 @@ def ssh_connect(serv, **kwargs):
|
|||
|
||||
def get_config(serv, cfg, **kwargs):
|
||||
import sql
|
||||
error = ""
|
||||
if kwargs.get("keepalived"):
|
||||
config_path = "/etc/keepalived/keepalived.conf"
|
||||
else:
|
||||
config_path = sql.get_setting('haproxy_config_path')
|
||||
|
||||
|
||||
config_path = "/etc/keepalived/keepalived.conf" if kwargs.get("keepalived") else sql.get_setting('haproxy_config_path')
|
||||
ssh = ssh_connect(serv)
|
||||
try:
|
||||
sftp = ssh.open_sftp()
|
||||
|
@ -213,7 +198,6 @@ def get_config(serv, cfg, **kwargs):
|
|||
return ssh
|
||||
|
||||
def diff_config(oldcfg, cfg):
|
||||
import subprocess
|
||||
log_path = get_config_var('main', 'log_path')
|
||||
diff = ""
|
||||
date = get_data('date_in_log')
|
||||
|
@ -242,10 +226,9 @@ def install_haproxy(serv, **kwargs):
|
|||
stats_password = sql.get_setting('stats_password')
|
||||
proxy = sql.get_setting('proxy')
|
||||
os.system("cp scripts/%s ." % script)
|
||||
if proxy is not None:
|
||||
proxy_serv = proxy
|
||||
else:
|
||||
proxy_serv = ""
|
||||
|
||||
proxy_serv = proxy if proxy is not None else ""
|
||||
|
||||
commands = [ "sudo chmod +x "+tmp_config_path+script+" && " +tmp_config_path+"/"+script +" PROXY=" + proxy_serv+
|
||||
" SOCK_PORT="+haproxy_sock_port+" STAT_PORT="+stats_port+" STAT_FILE="+server_state_file+
|
||||
" STATS_USER="+stats_user+" STATS_PASS="+stats_password ]
|
||||
|
@ -262,10 +245,7 @@ def syn_flood_protect(serv, **kwargs):
|
|||
script = "syn_flood_protect.sh"
|
||||
tmp_config_path = sql.get_setting('tmp_config_path')
|
||||
|
||||
if kwargs.get('enable') == "0":
|
||||
enable = "disable"
|
||||
else:
|
||||
enable = "enable"
|
||||
enable = "disable" if kwargs.get('enable') == "0" else "disable"
|
||||
|
||||
os.system("cp scripts/%s ." % script)
|
||||
|
||||
|
@ -393,12 +373,11 @@ def check_haproxy_config(serv):
|
|||
|
||||
def show_log(stdout):
|
||||
i = 0
|
||||
|
||||
for line in stdout:
|
||||
i = i + 1
|
||||
if i % 2 == 0:
|
||||
print('<div class="line3">' + escape_html(line) + '</div>')
|
||||
else:
|
||||
print('<div class="line">' + escape_html(line) + '</div>')
|
||||
line_class = "line3" if i % 2 == 0 else "line"
|
||||
print('<div class="'+line_class+'">' + escape_html(line) + '</div>')
|
||||
|
||||
def show_ip(stdout):
|
||||
for line in stdout:
|
||||
|
@ -478,19 +457,10 @@ def show_backends(serv, **kwargs):
|
|||
if kwargs.get('ret'):
|
||||
return ret
|
||||
|
||||
def get_files(**kwargs):
|
||||
def get_files(dir = get_config_var('configs', 'haproxy_save_configs_dir'), format = 'cfg', **kwargs):
|
||||
import glob
|
||||
file = set()
|
||||
return_files = set()
|
||||
if kwargs.get('dir'):
|
||||
dir = kwargs.get('dir')
|
||||
else:
|
||||
dir = get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
|
||||
if kwargs.get('format'):
|
||||
format = kwargs.get('format')
|
||||
else:
|
||||
format = 'cfg'
|
||||
|
||||
for files in glob.glob(os.path.join(dir,'*.'+format)):
|
||||
file.add(files.split('/')[-1])
|
||||
|
|
|
@ -438,6 +438,7 @@ if form.getvalue('metrics'):
|
|||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||
user_id = cookie.get('uuid')
|
||||
servers = sql.select_servers_metrics(user_id.value)
|
||||
servers = sorted(servers)
|
||||
|
||||
p = {}
|
||||
for serv in servers:
|
||||
|
@ -523,6 +524,7 @@ if form.getvalue('waf_metrics'):
|
|||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||
user_id = cookie.get('uuid')
|
||||
servers = sql.select_waf_servers_metrics(user_id.value)
|
||||
servers = sorted(servers)
|
||||
|
||||
p = {}
|
||||
for serv in servers:
|
||||
|
|
53
app/ovw.py
53
app/ovw.py
|
@ -1,27 +1,24 @@
|
|||
import funct
|
||||
import os
|
||||
import cgi
|
||||
import sql
|
||||
|
||||
form = cgi.FieldStorage()
|
||||
import http.cookies
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
env = Environment(loader=FileSystemLoader('templates/ajax'))
|
||||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||
user_id = cookie.get('uuid')
|
||||
haproxy_sock_port = sql.get_setting('haproxy_sock_port')
|
||||
listhap = sql.get_dick_permit()
|
||||
servers = []
|
||||
server_status = ()
|
||||
|
||||
def get_overview():
|
||||
import http.cookies
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
env = Environment(loader=FileSystemLoader('templates/ajax'))
|
||||
template = env.get_template('overview.html')
|
||||
haproxy_config_path = sql.get_setting('haproxy_config_path')
|
||||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||
user_id = cookie.get('uuid')
|
||||
haproxy_sock_port = sql.get_setting('haproxy_sock_port')
|
||||
|
||||
listhap = sql.get_dick_permit()
|
||||
haproxy_config_path = sql.get_setting('haproxy_config_path')
|
||||
|
||||
commands = [ "ls -l %s |awk '{ print $6\" \"$7\" \"$8}'" % haproxy_config_path ]
|
||||
commands1 = [ "ps ax |grep waf/bin/modsecurity |grep -v grep |wc -l" ]
|
||||
servers = []
|
||||
|
||||
for server in listhap:
|
||||
server_status = ()
|
||||
for server in listhap:
|
||||
cmd = 'echo "show info" |nc %s %s |grep -e "Process_num"' % (server[2], haproxy_sock_port)
|
||||
server_status = (server[1],server[2], funct.server_status(funct.subprocess_execute(cmd)), funct.ssh_command(server[2], commands), funct.ssh_command(server[2], commands1))
|
||||
servers.append(server_status)
|
||||
|
@ -30,22 +27,13 @@ def get_overview():
|
|||
print(template)
|
||||
|
||||
def get_overviewWaf(url):
|
||||
import http.cookies
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
env = Environment(loader=FileSystemLoader('templates/ajax'))
|
||||
template = env.get_template('overivewWaf.html')
|
||||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||
user_id = cookie.get('uuid')
|
||||
haproxy_dir = sql.get_setting('haproxy_dir')
|
||||
haproxy_sock_port = sql.get_setting('haproxy_sock_port')
|
||||
|
||||
listhap = sql.get_dick_permit()
|
||||
|
||||
commands = [ "ps ax |grep waf/bin/modsecurity |grep -v grep |wc -l" ]
|
||||
commands1 = [ "cat %s/waf/modsecurity.conf |grep SecRuleEngine |grep -v '#' |awk '{print $2}'" % haproxy_dir ]
|
||||
servers = []
|
||||
|
||||
for server in listhap:
|
||||
server_status = ()
|
||||
server_status = (server[1],server[2], funct.ssh_command(server[2], commands), funct.ssh_command(server[2], commands1), sql.select_waf_metrics_enable_server(server[2]))
|
||||
servers.append(server_status)
|
||||
|
||||
|
@ -53,18 +41,11 @@ def get_overviewWaf(url):
|
|||
print(template)
|
||||
|
||||
def get_overviewServers():
|
||||
import http.cookies
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
env = Environment(loader=FileSystemLoader('templates/ajax'))
|
||||
template = env.get_template('overviewServers.html')
|
||||
haproxy_sock_port = sql.get_setting('haproxy_sock_port')
|
||||
|
||||
listhap = sql.get_dick_permit()
|
||||
commands = [ "top -u haproxy -b -n 1" ]
|
||||
servers = []
|
||||
|
||||
|
||||
for server in sorted(listhap):
|
||||
server_status = ()
|
||||
cmd = 'echo "show info" |nc %s %s |grep -e "Ver\|CurrConns\|SessRate\|Maxco\|MB\|Uptime:"' % (server[2], haproxy_sock_port)
|
||||
out = funct.subprocess_execute(cmd)
|
||||
out1 = ""
|
||||
|
@ -109,10 +90,8 @@ def get_map(serv):
|
|||
|
||||
node = ""
|
||||
line_new2 = [1,""]
|
||||
i = 1200
|
||||
k = 1200
|
||||
j = 0
|
||||
m = 0
|
||||
i,k = 1200, 1200
|
||||
j, m = 0, 0
|
||||
for line in conf:
|
||||
if "listen" in line or "frontend" in line:
|
||||
if "stats" not in line:
|
||||
|
|
72
app/sql.py
72
app/sql.py
|
@ -85,7 +85,7 @@ def add_group(name, description):
|
|||
|
||||
def delete_group(id):
|
||||
con, cur = create_db.get_cur()
|
||||
sql = """delete from groups where id = '%s'""" % (id)
|
||||
sql = """ delete from groups where id = '%s'""" % (id)
|
||||
try:
|
||||
cur.execute(sql)
|
||||
con.commit()
|
||||
|
@ -99,8 +99,7 @@ def delete_group(id):
|
|||
|
||||
def update_group(name, descript, id):
|
||||
con, cur = create_db.get_cur()
|
||||
sql = """
|
||||
update groups set
|
||||
sql = """ update groups set
|
||||
name = '%s',
|
||||
description = '%s'
|
||||
where id = '%s';
|
||||
|
@ -119,9 +118,7 @@ def update_group(name, descript, id):
|
|||
|
||||
def add_server(hostname, ip, group, typeip, enable, master, cred, alert, metrics, port):
|
||||
con, cur = create_db.get_cur()
|
||||
sql = """
|
||||
INSERT INTO servers
|
||||
(hostname, ip, groups, type_ip, enable, master, cred, alert, metrics, port)
|
||||
sql = """ INSERT INTO servers (hostname, ip, groups, type_ip, enable, master, cred, alert, metrics, port)
|
||||
VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')
|
||||
""" % (hostname, ip, group, typeip, enable, master, cred, alert, metrics, port)
|
||||
try:
|
||||
|
@ -131,14 +128,13 @@ def add_server(hostname, ip, group, typeip, enable, master, cred, alert, metrics
|
|||
except sqltool.Error as e:
|
||||
out_error(e)
|
||||
con.rollback()
|
||||
return False
|
||||
|
||||
return False
|
||||
cur.close()
|
||||
con.close()
|
||||
|
||||
def delete_server(id):
|
||||
con, cur = create_db.get_cur()
|
||||
sql = """delete from servers where id = '%s'""" % (id)
|
||||
sql = """ delete from servers where id = '%s'""" % (id)
|
||||
try:
|
||||
cur.execute(sql)
|
||||
con.commit()
|
||||
|
@ -152,7 +148,7 @@ def delete_server(id):
|
|||
|
||||
def update_server(hostname, ip, group, typeip, enable, master, id, cred, alert, metrics, port):
|
||||
con, cur = create_db.get_cur()
|
||||
sql = """update servers set
|
||||
sql = """ update servers set
|
||||
hostname = '%s',
|
||||
ip = '%s',
|
||||
groups = '%s',
|
||||
|
@ -179,7 +175,7 @@ def update_server_master(master, slave):
|
|||
try:
|
||||
cur.execute(sql)
|
||||
except sqltool.Error as e:
|
||||
print('<span class="alert alert-danger" id="error">An error occurred: ' + e + ' <a title="Close" id="errorMess"><b>X</b></a></span>')
|
||||
out_error(e)
|
||||
for id in cur.fetchall():
|
||||
sql = """ update servers set master = '%s' where ip = '%s' """ % (id[0], slave)
|
||||
try:
|
||||
|
@ -242,8 +238,7 @@ def select_servers(**kwargs):
|
|||
if kwargs.get("get_master_servers") is not None:
|
||||
sql = """select id,hostname from servers where master = 0 and type_ip = 0 and enable = 1 ORDER BY groups """
|
||||
if kwargs.get("get_master_servers") is not None and kwargs.get('uuid') is not None:
|
||||
sql = """
|
||||
select servers.id, servers.hostname from servers
|
||||
sql = """ select servers.id, servers.hostname from servers
|
||||
left join user as user on servers.groups = user.groups
|
||||
left join uuid as uuid on user.id = uuid.user_id
|
||||
where uuid.uuid = '%s' and servers.master = 0 and servers.type_ip = 0 and servers.enable = 1 ORDER BY servers.groups
|
||||
|
@ -311,8 +306,7 @@ def get_token(uuid):
|
|||
out_error(e)
|
||||
else:
|
||||
for token in cur.fetchall():
|
||||
return token[0]
|
||||
|
||||
return token[0]
|
||||
cur.close()
|
||||
con.close()
|
||||
|
||||
|
@ -457,11 +451,7 @@ def get_dick_permit(**kwargs):
|
|||
try:
|
||||
cur.execute(sql)
|
||||
except sqltool.Error as e:
|
||||
if mysql_enable == '1':
|
||||
error = e
|
||||
else:
|
||||
error = e.args[0]
|
||||
print('<span class="alert alert-danger" id="error">An error occurred: ' + error + ' <a title="Close" id="errorMess"><b>X</b></a></span>')
|
||||
out_error(e)
|
||||
else:
|
||||
return cur.fetchall()
|
||||
cur.close()
|
||||
|
@ -529,8 +519,7 @@ def delete_ssh(id):
|
|||
|
||||
def update_ssh(id, name, enable, group, username, password):
|
||||
con, cur = create_db.get_cur()
|
||||
sql = """
|
||||
update cred set
|
||||
sql = """ update cred set
|
||||
name = '%s',
|
||||
enable = '%s',
|
||||
groups = %s,
|
||||
|
@ -551,7 +540,6 @@ def show_update_ssh(name, page):
|
|||
template = env.get_template('/new_ssh.html')
|
||||
|
||||
print('Content-type: text/html\n')
|
||||
|
||||
output_from_parsed_template = template.render(groups = select_groups(), sshs = select_ssh(name=name),page=page)
|
||||
print(output_from_parsed_template)
|
||||
|
||||
|
@ -601,8 +589,7 @@ def select_telegram(**kwargs):
|
|||
|
||||
def update_telegram(token, chanel, group, id):
|
||||
con, cur = create_db.get_cur()
|
||||
sql = """
|
||||
update telegram set
|
||||
sql = """ update telegram set
|
||||
`token` = '%s',
|
||||
`chanel_name` = '%s',
|
||||
`groups` = '%s'
|
||||
|
@ -672,11 +659,6 @@ def select_waf_servers_metrics(uuid, **kwargs):
|
|||
con, cur = create_db.get_cur()
|
||||
sql = """ select * from user where username = '%s' """ % get_user_name_by_uuid(uuid)
|
||||
|
||||
if kwargs.get('disable') == 0:
|
||||
disable = 'or enable = 0'
|
||||
else:
|
||||
disable = ''
|
||||
|
||||
try:
|
||||
cur.execute(sql)
|
||||
except sqltool.Error as e:
|
||||
|
@ -684,17 +666,13 @@ def select_waf_servers_metrics(uuid, **kwargs):
|
|||
else:
|
||||
for group in cur:
|
||||
if group[5] == '1':
|
||||
sql = """ select servers.ip from servers left join waf as waf on waf.server_id = servers.id where servers.enable = 1 %s and waf.metrics = '1' """ % (disable)
|
||||
sql = """ select servers.ip from servers left join waf as waf on waf.server_id = servers.id where servers.enable = 1 and waf.metrics = '1' """
|
||||
else:
|
||||
sql = """ select servers.ip from servers left join waf as waf on waf.server_id = servers.id where servers.enable = 1 %s and waf.metrics = '1' and servers.groups like '%{group}%' """.format(group=group[5])
|
||||
try:
|
||||
cur.execute(sql)
|
||||
except sqltool.Error as e:
|
||||
if mysql_enable == '1':
|
||||
error = e
|
||||
else:
|
||||
error = e.args[0]
|
||||
print('<span class="alert alert-danger" id="error">An error occurred: ' + error + ' <a title="Close" id="errorMess"><b>X</b></a></span>')
|
||||
out_error(e)
|
||||
else:
|
||||
return cur.fetchall()
|
||||
cur.close()
|
||||
|
@ -821,11 +799,6 @@ def select_servers_metrics(uuid, **kwargs):
|
|||
con, cur = create_db.get_cur()
|
||||
sql = """ select * from user where username = '%s' """ % get_user_name_by_uuid(uuid)
|
||||
|
||||
if kwargs.get('disable') == 0:
|
||||
disable = 'or enable = 0'
|
||||
else:
|
||||
disable = ''
|
||||
|
||||
try:
|
||||
cur.execute(sql)
|
||||
except sqltool.Error as e:
|
||||
|
@ -833,17 +806,13 @@ def select_servers_metrics(uuid, **kwargs):
|
|||
else:
|
||||
for group in cur:
|
||||
if group[5] == '1':
|
||||
sql = """ select ip from servers where enable = 1 %s and metrics = '1' """ % (disable)
|
||||
sql = """ select ip from servers where enable = 1 and metrics = '1' """
|
||||
else:
|
||||
sql = """ select ip from servers where groups like '%{group}%' and metrics = '1'""".format(group=group[5])
|
||||
try:
|
||||
cur.execute(sql)
|
||||
except sqltool.Error as e:
|
||||
if mysql_enable == '1':
|
||||
error = e
|
||||
else:
|
||||
error = e.args[0]
|
||||
print('<span class="alert alert-danger" id="error">An error occurred: ' + error + ' <a title="Close" id="errorMess"><b>X</b></a></span>')
|
||||
out_error(e)
|
||||
else:
|
||||
return cur.fetchall()
|
||||
cur.close()
|
||||
|
@ -963,8 +932,7 @@ def select_table_metrics(uuid):
|
|||
cur.execute(sql)
|
||||
except sqltool.Error as e:
|
||||
out_error(e)
|
||||
else:
|
||||
|
||||
else:
|
||||
return cur.fetchall()
|
||||
cur.close()
|
||||
con.close()
|
||||
|
@ -1005,7 +973,6 @@ def show_update_telegram(token, page):
|
|||
template = env.get_template('/new_telegram.html')
|
||||
|
||||
print('Content-type: text/html\n')
|
||||
|
||||
output_from_parsed_template = template.render(groups = select_groups(), telegrams = select_telegram(token=token),page=page)
|
||||
print(output_from_parsed_template)
|
||||
|
||||
|
@ -1015,7 +982,6 @@ def show_update_user(user):
|
|||
template = env.get_template('/new_user.html')
|
||||
|
||||
print('Content-type: text/html\n')
|
||||
|
||||
output_from_parsed_template = template.render(users = select_users(user=user),
|
||||
groups = select_groups(),
|
||||
roles = select_roles())
|
||||
|
@ -1027,7 +993,6 @@ def show_update_server(server, page):
|
|||
template = env.get_template('/new_server.html')
|
||||
|
||||
print('Content-type: text/html\n')
|
||||
|
||||
output_from_parsed_template = template.render(groups = select_groups(),
|
||||
servers = select_servers(server=server),
|
||||
roles = select_roles(),
|
||||
|
@ -1042,7 +1007,6 @@ def show_update_group(group):
|
|||
template = env.get_template('/new_group.html')
|
||||
|
||||
print('Content-type: text/html\n')
|
||||
|
||||
output_from_parsed_template = template.render(groups = select_groups(group=group))
|
||||
print(output_from_parsed_template)
|
||||
|
||||
|
@ -1107,7 +1071,6 @@ if form.getvalue('userdel') is not None:
|
|||
print("Ok")
|
||||
|
||||
if form.getvalue('newserver') is not None:
|
||||
import funct
|
||||
hostname = form.getvalue('servername')
|
||||
ip = form.getvalue('newip')
|
||||
group = form.getvalue('newservergroup')
|
||||
|
@ -1159,7 +1122,6 @@ if form.getvalue('updategroup') is not None:
|
|||
update_group(name, descript, id)
|
||||
|
||||
if form.getvalue('updateserver') is not None:
|
||||
import funct
|
||||
name = form.getvalue('updateserver')
|
||||
ip = form.getvalue('ip')
|
||||
group = form.getvalue('servergroup')
|
||||
|
|
|
@ -117,7 +117,7 @@
|
|||
</tr>
|
||||
{% for group in groups %}
|
||||
<tr id="group-{{ group.0 }}" class="{{ loop.cycle('odd', 'even') }}">
|
||||
{% if group.1 == All %}
|
||||
{% if group.1 == "All" %}
|
||||
<td class="padding10 first-collumn">{{ group.1 }}</td>
|
||||
<td>{{ group.2 }}</td>
|
||||
<td></td>
|
||||
|
|
|
@ -19,6 +19,7 @@ th, tr, td {
|
|||
<div id="table_metrics"></div>
|
||||
<div id="metrics_iframe"></div>
|
||||
<script>
|
||||
$("#secIntervals").css("display", "none");
|
||||
function callIframe(url, callback) {
|
||||
$('#metrics_iframe').html('<iframe id="metrics" style="width:100%;height:100%;" />');
|
||||
$('iframe#metrics').attr('src', url);
|
||||
|
@ -31,7 +32,7 @@ function loadMetrics() {
|
|||
callIframe('templates/metrics_out.html', function(){
|
||||
$.get( "options.py?metrics=1&token="+$('#token').val(), function( data ) {
|
||||
$( ".result" ).html( data );
|
||||
});
|
||||
})
|
||||
$.get( "options.py?table_metrics=1&token="+$('#token').val(), function( data ) {
|
||||
$( "#table_metrics" ).html( data );
|
||||
});
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
<script>
|
||||
if (cur_url[0] == "overview.py") {
|
||||
$("#secIntervals").css("display", "none");
|
||||
}
|
||||
$("#secIntervals").css("display", "none");
|
||||
</script>
|
||||
{% if role <= 1 %}
|
||||
<table class="overview">
|
||||
|
|
|
@ -100,7 +100,7 @@
|
|||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<a class="delete" onclick="confirmDeleteServer({{server.0}})" style="cursor: pointer;"></a>
|
||||
<a class="delete_button" onclick="confirmDeleteServer({{server.0}})" style="cursor: pointer;"></a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
@ -209,7 +209,7 @@
|
|||
<br>
|
||||
</td>
|
||||
<td>
|
||||
<a class="delete" onclick="confirmDeleteSsh({{ssh.0}})" style="cursor: pointer;"></a>
|
||||
<a class="delete_button" onclick="confirmDeleteSsh({{ssh.0}})" style="cursor: pointer;"></a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
|
@ -291,7 +291,7 @@
|
|||
<input type="text" id="telegram-chanel-{{telegram.0}}" class="form-control" value="{{telegram.2}}">
|
||||
</td>
|
||||
<td>
|
||||
<a class="delete" onclick="confirmDeleteSsh({{telegram.0}})" style="cursor: pointer;"></a>
|
||||
<a class="delete_button" onclick="confirmDeleteSsh({{telegram.0}})" style="cursor: pointer;"></a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
|
@ -344,7 +344,7 @@
|
|||
$("input[type=checkbox]").checkboxradio( "disable" );
|
||||
$("select").selectmenu( "disable" );
|
||||
$("input").attr( "readonly", "readonly" );
|
||||
$('.delete').remove()
|
||||
$('.delete_button').remove()
|
||||
}, 500 );
|
||||
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ if(Cookies.get('restart')) {
|
|||
}
|
||||
function autoRefreshStyle(autoRefresh) {
|
||||
var margin;
|
||||
if (cur_url[0] == "overview.py") {
|
||||
if (cur_url[0] == "overview.py" || cur_url[0] == "waf.py" || cur_url[0] == "metrics.py") {
|
||||
if(autoRefresh < 60000) {
|
||||
autoRefresh = 60000;
|
||||
}
|
||||
|
@ -126,10 +126,16 @@ function startSetInterval(interval) {
|
|||
intervalId = setInterval('viewLogs()', interval);
|
||||
viewLogs();
|
||||
} else if (cur_url[0] == "metrics.py") {
|
||||
if(interval < 60000) {
|
||||
interval = 60000;
|
||||
}
|
||||
intervalId = setInterval('loadMetrics()', interval);
|
||||
loadMetrics();
|
||||
}
|
||||
else if (cur_url[0] == "waf.py") {
|
||||
if(interval < 60000) {
|
||||
interval = 60000;
|
||||
}
|
||||
intervalId = setInterval('loadMetrics()', interval);
|
||||
showOverviewWaf();
|
||||
loadMetrics();
|
||||
|
|
Loading…
Reference in New Issue