mirror of https://github.com/Aidaho12/haproxy-wi
parent
7e3dd0c56c
commit
14e663781b
|
@ -28,7 +28,7 @@ user_params = roxywi_common.get_users_params(haproxy=1)
|
|||
try:
|
||||
roxywi_auth.check_login(user_params['user_uuid'], user_params['token'], service=1)
|
||||
except Exception as e:
|
||||
print(f'error {e}')
|
||||
print('error: your session is expired')
|
||||
sys.exit()
|
||||
|
||||
roxywi_auth.page_for_admin(level=3)
|
||||
|
|
|
@ -982,6 +982,22 @@ def update_db_v_6_3_4():
|
|||
print('Updating... DB has been updated to version 6.3.4.0')
|
||||
|
||||
|
||||
|
||||
|
||||
def update_db_v_6_3_5():
|
||||
cursor = conn.cursor()
|
||||
sql = list()
|
||||
sql.append("ALTER TABLE `action_history` ADD COLUMN server_ip varchar(64);")
|
||||
sql.append("ALTER TABLE `action_history` ADD COLUMN hostname varchar(64);")
|
||||
for i in sql:
|
||||
try:
|
||||
cursor.execute(i)
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
print("Updating... DB has been updated to version 6.3.5.0")
|
||||
|
||||
|
||||
def update_ver():
|
||||
try:
|
||||
Version.update(version='6.3.4.0').execute()
|
||||
|
@ -1021,6 +1037,7 @@ def update_all():
|
|||
update_db_v_6_1_4()
|
||||
update_db_v_6_2_1()
|
||||
update_db_v_6_3_4()
|
||||
update_db_v_6_3_5()
|
||||
update_ver()
|
||||
|
||||
|
||||
|
|
|
@ -468,6 +468,8 @@ class ActionHistory(BaseModel):
|
|||
action = CharField(null=True)
|
||||
ip = CharField(null=True)
|
||||
date = DateTimeField(default=datetime.now)
|
||||
server_ip = CharField(null=True)
|
||||
hostname = CharField(null=True)
|
||||
|
||||
class Meta:
|
||||
table_name = 'action_history'
|
||||
|
|
|
@ -2004,7 +2004,8 @@ def select_service_table_metrics(service: str, group_id: int):
|
|||
if group_id == 1:
|
||||
groups = ""
|
||||
else:
|
||||
groups = "and servers.groups = '{group}' ".format(group=group_id)
|
||||
groups = f"and servers.groups = '{group_id}' "
|
||||
|
||||
if mysql_enable == '1':
|
||||
sql = """
|
||||
select ip.ip, hostname, avg_cur_1h, avg_cur_24h, avg_cur_3d, max_con_1h, max_con_24h, max_con_3d from
|
||||
|
@ -3368,7 +3369,7 @@ def delete_service_settings(server_id: int):
|
|||
out_error(e)
|
||||
|
||||
|
||||
def insert_action_history(service: str, action: str, server_id: int, user_id: int, user_ip: str):
|
||||
def insert_action_history(service: str, action: str, server_id: int, user_id: int, user_ip: str, server_ip: str, hostname: str):
|
||||
cur_date = get_date.return_date('regular')
|
||||
try:
|
||||
ActionHistory.insert(
|
||||
|
@ -3377,7 +3378,9 @@ def insert_action_history(service: str, action: str, server_id: int, user_id: in
|
|||
server_id=server_id,
|
||||
user_id=user_id,
|
||||
ip=user_ip,
|
||||
date=cur_date
|
||||
date=cur_date,
|
||||
server_ip=server_ip,
|
||||
hostname=hostname
|
||||
).execute()
|
||||
except Exception as e:
|
||||
out_error(e)
|
||||
|
|
|
@ -196,6 +196,7 @@ def logging(server_ip: str, action: str, **kwargs) -> None:
|
|||
def keep_action_history(service: str, action: str, server_ip: str, login: str, user_ip: str):
|
||||
try:
|
||||
server_id = sql.select_server_id_by_ip(server_ip=server_ip)
|
||||
hostname = sql.get_hostname_by_server_ip(server_ip)
|
||||
if login != '':
|
||||
user_id = sql.get_user_id_by_username(login)
|
||||
else:
|
||||
|
@ -203,7 +204,7 @@ def keep_action_history(service: str, action: str, server_ip: str, login: str, u
|
|||
if user_ip == '':
|
||||
user_ip = 'localhost'
|
||||
|
||||
sql.insert_action_history(service, action, server_id, user_id, user_ip)
|
||||
sql.insert_action_history(service, action, server_id, user_id, user_ip, server_ip, hostname)
|
||||
except Exception as e:
|
||||
logging('Roxy-WI server', f'Cannot save a history: {e}', roxywi=1)
|
||||
|
||||
|
@ -228,7 +229,7 @@ def get_users_params(**kwargs):
|
|||
user = sql.get_user_name_by_uuid(user_uuid.value)
|
||||
except Exception:
|
||||
print('<meta http-equiv="refresh" content="0; url=/app/login.py">')
|
||||
return
|
||||
return
|
||||
try:
|
||||
role = sql.get_user_role_by_uuid(user_uuid.value)
|
||||
except Exception:
|
||||
|
|
|
@ -0,0 +1,137 @@
|
|||
import json
|
||||
|
||||
import psutil
|
||||
|
||||
import modules.db.sql as sql
|
||||
import modules.server.server as server_mod
|
||||
|
||||
|
||||
def show_ram_metrics(metrics_type: str) -> None:
|
||||
metrics = {'chartData': {}}
|
||||
rams = ''
|
||||
|
||||
if metrics_type == '1':
|
||||
rams_list = psutil.virtual_memory()
|
||||
rams += str(round(rams_list.total / 1048576, 2)) + ' '
|
||||
rams += str(round(rams_list.used / 1048576, 2)) + ' '
|
||||
rams += str(round(rams_list.free / 1048576, 2)) + ' '
|
||||
rams += str(round(rams_list.shared / 1048576, 2)) + ' '
|
||||
rams += str(round(rams_list.cached / 1048576, 2)) + ' '
|
||||
rams += str(round(rams_list.available / 1048576, 2)) + ' '
|
||||
else:
|
||||
commands = ["free -m |grep Mem |awk '{print $2,$3,$4,$5,$6,$7}'"]
|
||||
metric, error = server_mod.subprocess_execute(commands[0])
|
||||
|
||||
for i in metric:
|
||||
rams = i
|
||||
|
||||
metrics['chartData']['rams'] = rams
|
||||
|
||||
print(json.dumps(metrics))
|
||||
|
||||
|
||||
def show_cpu_metrics(metrics_type: str) -> None:
|
||||
metrics = {'chartData': {}}
|
||||
cpus = ''
|
||||
|
||||
if metrics_type == '1':
|
||||
cpus_list = psutil.cpu_times_percent(interval=1, percpu=False)
|
||||
cpus += str(cpus_list.user) + ' '
|
||||
cpus += str(cpus_list.system) + ' '
|
||||
cpus += str(cpus_list.nice) + ' '
|
||||
cpus += str(cpus_list.idle) + ' '
|
||||
cpus += str(cpus_list.iowait) + ' '
|
||||
cpus += str(cpus_list.irq) + ' '
|
||||
cpus += str(cpus_list.softirq) + ' '
|
||||
cpus += str(cpus_list.steal) + ' '
|
||||
else:
|
||||
commands = [
|
||||
"top -b -n 1 |grep Cpu |awk -F':' '{print $2}'|awk -F' ' 'BEGIN{ORS=\" \";} { for (i=1;i<=NF;i+=2) print $i}'"]
|
||||
metric, error = server_mod.subprocess_execute(commands[0])
|
||||
|
||||
for i in metric:
|
||||
cpus = i
|
||||
|
||||
metrics['chartData']['cpus'] = cpus
|
||||
|
||||
print(json.dumps(metrics))
|
||||
|
||||
|
||||
def haproxy_metrics(server_ip: str, hostname: str, time_range: str) -> None:
|
||||
metric = sql.select_metrics(server_ip, 'haproxy', time_range=time_range)
|
||||
metrics = {'chartData': {}}
|
||||
metrics['chartData']['labels'] = {}
|
||||
labels = ''
|
||||
curr_con = ''
|
||||
curr_ssl_con = ''
|
||||
sess_rate = ''
|
||||
server = ''
|
||||
|
||||
for i in metric:
|
||||
label = str(i[5])
|
||||
label = label.split(' ')[1]
|
||||
labels += label + ','
|
||||
curr_con += str(i[1]) + ','
|
||||
curr_ssl_con += str(i[2]) + ','
|
||||
sess_rate += str(i[3]) + ','
|
||||
server = str(i[0])
|
||||
|
||||
metrics['chartData']['labels'] = labels
|
||||
metrics['chartData']['curr_con'] = curr_con
|
||||
metrics['chartData']['curr_ssl_con'] = curr_ssl_con
|
||||
metrics['chartData']['sess_rate'] = sess_rate
|
||||
metrics['chartData']['server'] = hostname + ' (' + server + ')'
|
||||
|
||||
print(json.dumps(metrics))
|
||||
|
||||
|
||||
def haproxy_http_metrics(server_ip: str, hostname: str, time_range: str) -> None:
|
||||
metric = sql.select_metrics(server_ip, 'http_metrics', time_range=time_range)
|
||||
metrics = {'chartData': {}}
|
||||
metrics['chartData']['labels'] = {}
|
||||
labels = ''
|
||||
http_2xx = ''
|
||||
http_3xx = ''
|
||||
http_4xx = ''
|
||||
http_5xx = ''
|
||||
server = ''
|
||||
|
||||
for i in metric:
|
||||
label = str(i[5])
|
||||
label = label.split(' ')[1]
|
||||
labels += label + ','
|
||||
http_2xx += str(i[1]) + ','
|
||||
http_3xx += str(i[2]) + ','
|
||||
http_4xx += str(i[3]) + ','
|
||||
http_5xx += str(i[4]) + ','
|
||||
server = str(i[0])
|
||||
|
||||
metrics['chartData']['labels'] = labels
|
||||
metrics['chartData']['http_2xx'] = http_2xx
|
||||
metrics['chartData']['http_3xx'] = http_3xx
|
||||
metrics['chartData']['http_4xx'] = http_4xx
|
||||
metrics['chartData']['http_5xx'] = http_5xx
|
||||
metrics['chartData']['server'] = f'{hostname} ({server})'
|
||||
|
||||
print(json.dumps(metrics))
|
||||
|
||||
|
||||
def service_metrics(server_ip: str, hostname: str, service: str, time_range: str) -> None:
|
||||
metric = sql.select_metrics(server_ip, service, time_range=time_range)
|
||||
|
||||
metrics = {'chartData': {}}
|
||||
metrics['chartData']['labels'] = {}
|
||||
labels = ''
|
||||
curr_con = ''
|
||||
|
||||
for i in metric:
|
||||
label = str(i[2])
|
||||
label = label.split(' ')[1]
|
||||
labels += label + ','
|
||||
curr_con += str(i[1]) + ','
|
||||
|
||||
metrics['chartData']['labels'] = labels
|
||||
metrics['chartData']['curr_con'] = curr_con
|
||||
metrics['chartData']['server'] = f'{hostname} ({server_ip})'
|
||||
|
||||
print(json.dumps(metrics))
|
|
@ -31,6 +31,7 @@ def ssh_command(server_ip: str, commands: list, **kwargs):
|
|||
if line:
|
||||
print(f'error: {line}')
|
||||
roxywi_common.logging('Roxy-WI server', f' {line}', roxywi=1)
|
||||
raise Exception(f'error: {line}')
|
||||
|
||||
try:
|
||||
if kwargs.get('raw'):
|
||||
|
@ -101,17 +102,22 @@ def get_system_info(server_ip: str) -> str:
|
|||
return 'error: IP cannot be empty'
|
||||
|
||||
server_id = sql.select_server_id_by_ip(server_ip)
|
||||
|
||||
command = ["sudo lshw -quiet -json"]
|
||||
command1 = ['sudo hostnamectl |grep "Operating System"|awk -F":" \'{print $2}\'']
|
||||
|
||||
try:
|
||||
sys_info_returned = ssh_command(server_ip, command, timeout=5)
|
||||
except Exception as e:
|
||||
raise e
|
||||
command = ['sudo hostnamectl |grep "Operating System"|awk -F":" \'{print $2}\'']
|
||||
|
||||
if 'command not found' in sys_info_returned:
|
||||
raise Exception(f' You should install lshw on the server {server_ip}. Update System info after installation.')
|
||||
|
||||
try:
|
||||
os_info = ssh_command(server_ip, command)
|
||||
os_info = ssh_command(server_ip, command1)
|
||||
except Exception as e:
|
||||
raise e
|
||||
|
||||
os_info = os_info.strip()
|
||||
system_info = json.loads(sys_info_returned)
|
||||
|
||||
|
|
158
app/options.py
158
app/options.py
|
@ -574,126 +574,41 @@ if form.getvalue('table_metrics'):
|
|||
print(template)
|
||||
|
||||
if form.getvalue('metrics_hapwi_ram'):
|
||||
ip = form.getvalue('ip')
|
||||
metrics = {'chartData': {}}
|
||||
rams = ''
|
||||
import modules.roxywi.metrics as metric
|
||||
metrics_type = common.checkAjaxInput(form.getvalue('ip'))
|
||||
|
||||
if ip == '1':
|
||||
import psutil
|
||||
|
||||
rams_list = psutil.virtual_memory()
|
||||
rams += str(round(rams_list.total / 1048576, 2)) + ' '
|
||||
rams += str(round(rams_list.used / 1048576, 2)) + ' '
|
||||
rams += str(round(rams_list.free / 1048576, 2)) + ' '
|
||||
rams += str(round(rams_list.shared / 1048576, 2)) + ' '
|
||||
rams += str(round(rams_list.cached / 1048576, 2)) + ' '
|
||||
rams += str(round(rams_list.available / 1048576, 2)) + ' '
|
||||
else:
|
||||
commands = ["free -m |grep Mem |awk '{print $2,$3,$4,$5,$6,$7}'"]
|
||||
metric, error = server_mod.subprocess_execute(commands[0])
|
||||
|
||||
for i in metric:
|
||||
rams = i
|
||||
|
||||
metrics['chartData']['rams'] = rams
|
||||
|
||||
print(json.dumps(metrics))
|
||||
metric.show_ram_metrics(metrics_type)
|
||||
|
||||
if form.getvalue('metrics_hapwi_cpu'):
|
||||
ip = form.getvalue('ip')
|
||||
metrics = {'chartData': {}}
|
||||
cpus = ''
|
||||
import modules.roxywi.metrics as metric
|
||||
|
||||
if ip == '1':
|
||||
import psutil
|
||||
metrics_type = common.checkAjaxInput(form.getvalue('ip'))
|
||||
|
||||
cpus_list = psutil.cpu_times_percent(interval=1, percpu=False)
|
||||
cpus += str(cpus_list.user) + ' '
|
||||
cpus += str(cpus_list.system) + ' '
|
||||
cpus += str(cpus_list.nice) + ' '
|
||||
cpus += str(cpus_list.idle) + ' '
|
||||
cpus += str(cpus_list.iowait) + ' '
|
||||
cpus += str(cpus_list.irq) + ' '
|
||||
cpus += str(cpus_list.softirq) + ' '
|
||||
cpus += str(cpus_list.steal) + ' '
|
||||
else:
|
||||
commands = [
|
||||
"top -b -n 1 |grep Cpu |awk -F':' '{print $2}'|awk -F' ' 'BEGIN{ORS=\" \";} { for (i=1;i<=NF;i+=2) print $i}'"]
|
||||
metric, error = server_mod.subprocess_execute(commands[0])
|
||||
|
||||
for i in metric:
|
||||
cpus = i
|
||||
|
||||
metrics['chartData']['cpus'] = cpus
|
||||
|
||||
print(json.dumps(metrics))
|
||||
metric.show_cpu_metrics(metrics_type)
|
||||
|
||||
if form.getvalue('new_metrics'):
|
||||
serv = form.getvalue('server')
|
||||
hostname = sql.get_hostname_by_server_ip(serv)
|
||||
time_range = form.getvalue('time_range')
|
||||
metric = sql.select_metrics(serv, 'haproxy', time_range=time_range)
|
||||
metrics = {'chartData': {}}
|
||||
metrics['chartData']['labels'] = {}
|
||||
labels = ''
|
||||
curr_con = ''
|
||||
curr_ssl_con = ''
|
||||
sess_rate = ''
|
||||
server = ''
|
||||
import modules.roxywi.metrics as metric
|
||||
|
||||
for i in metric:
|
||||
label = str(i[5])
|
||||
label = label.split(' ')[1]
|
||||
labels += label + ','
|
||||
curr_con += str(i[1]) + ','
|
||||
curr_ssl_con += str(i[2]) + ','
|
||||
sess_rate += str(i[3]) + ','
|
||||
server = str(i[0])
|
||||
server_ip = common.is_ip_or_dns(form.getvalue('server'))
|
||||
hostname = sql.get_hostname_by_server_ip(server_ip)
|
||||
time_range = common.checkAjaxInput(form.getvalue('time_range'))
|
||||
|
||||
metrics['chartData']['labels'] = labels
|
||||
metrics['chartData']['curr_con'] = curr_con
|
||||
metrics['chartData']['curr_ssl_con'] = curr_ssl_con
|
||||
metrics['chartData']['sess_rate'] = sess_rate
|
||||
metrics['chartData']['server'] = hostname + ' (' + server + ')'
|
||||
|
||||
print(json.dumps(metrics))
|
||||
metric.haproxy_metrics(server_ip, hostname, time_range)
|
||||
|
||||
if form.getvalue('new_http_metrics'):
|
||||
serv = form.getvalue('server')
|
||||
hostname = sql.get_hostname_by_server_ip(serv)
|
||||
import modules.roxywi.metrics as metric
|
||||
|
||||
server_ip = common.is_ip_or_dns(form.getvalue('server'))
|
||||
hostname = sql.get_hostname_by_server_ip(server_ip)
|
||||
time_range = common.checkAjaxInput(form.getvalue('time_range'))
|
||||
metric = sql.select_metrics(serv, 'http_metrics', time_range=time_range)
|
||||
metrics = {'chartData': {}}
|
||||
metrics['chartData']['labels'] = {}
|
||||
labels = ''
|
||||
http_2xx = ''
|
||||
http_3xx = ''
|
||||
http_4xx = ''
|
||||
http_5xx = ''
|
||||
server = ''
|
||||
|
||||
for i in metric:
|
||||
label = str(i[5])
|
||||
label = label.split(' ')[1]
|
||||
labels += label + ','
|
||||
http_2xx += str(i[1]) + ','
|
||||
http_3xx += str(i[2]) + ','
|
||||
http_4xx += str(i[3]) + ','
|
||||
http_5xx += str(i[4]) + ','
|
||||
server = str(i[0])
|
||||
|
||||
metrics['chartData']['labels'] = labels
|
||||
metrics['chartData']['http_2xx'] = http_2xx
|
||||
metrics['chartData']['http_3xx'] = http_3xx
|
||||
metrics['chartData']['http_4xx'] = http_4xx
|
||||
metrics['chartData']['http_5xx'] = http_5xx
|
||||
metrics['chartData']['server'] = f'{hostname} ({server})'
|
||||
|
||||
print(json.dumps(metrics))
|
||||
metric.haproxy_http_metrics(server_ip, hostname, time_range)
|
||||
|
||||
if any((form.getvalue('new_nginx_metrics'), form.getvalue('new_apache_metrics'), form.getvalue('new_waf_metrics'))):
|
||||
serv = form.getvalue('server')
|
||||
hostname = sql.get_hostname_by_server_ip(serv)
|
||||
import modules.roxywi.metrics as metric
|
||||
|
||||
server_ip = common.is_ip_or_dns(form.getvalue('server'))
|
||||
hostname = sql.get_hostname_by_server_ip(server_ip)
|
||||
time_range = common.checkAjaxInput(form.getvalue('time_range'))
|
||||
service = ''
|
||||
|
||||
|
@ -704,24 +619,7 @@ if any((form.getvalue('new_nginx_metrics'), form.getvalue('new_apache_metrics'),
|
|||
elif form.getvalue('new_waf_metrics'):
|
||||
service = 'waf'
|
||||
|
||||
metric = sql.select_metrics(serv, service, time_range=time_range)
|
||||
|
||||
metrics = {'chartData': {}}
|
||||
metrics['chartData']['labels'] = {}
|
||||
labels = ''
|
||||
curr_con = ''
|
||||
|
||||
for i in metric:
|
||||
label = str(i[2])
|
||||
label = label.split(' ')[1]
|
||||
labels += label + ','
|
||||
curr_con += str(i[1]) + ','
|
||||
|
||||
metrics['chartData']['labels'] = labels
|
||||
metrics['chartData']['curr_con'] = curr_con
|
||||
metrics['chartData']['server'] = f'{hostname} ({serv})'
|
||||
|
||||
print(json.dumps(metrics))
|
||||
metric.service_metrics(server_ip, hostname, service, time_range)
|
||||
|
||||
if form.getvalue('get_hap_v'):
|
||||
print(service_common.check_haproxy_version(serv))
|
||||
|
@ -952,8 +850,7 @@ if form.getvalue('updatepassowrd') is not None:
|
|||
|
||||
if form.getvalue('newserver') is not None:
|
||||
hostname = common.checkAjaxInput(form.getvalue('servername'))
|
||||
ip = form.getvalue('newip')
|
||||
ip = common.is_ip_or_dns(ip)
|
||||
ip = common.is_ip_or_dns(form.getvalue('newip'))
|
||||
group = common.checkAjaxInput(form.getvalue('newservergroup'))
|
||||
scan_server = common.checkAjaxInput(form.getvalue('scan_server'))
|
||||
typeip = common.checkAjaxInput(form.getvalue('typeip'))
|
||||
|
@ -1006,7 +903,7 @@ if form.getvalue('updatehapwiserver') is not None:
|
|||
service = form.getvalue('service_name')
|
||||
sql.update_hapwi_server(hapwi_id, alert, metrics, active, service)
|
||||
server_ip = sql.select_server_ip_by_id(hapwi_id)
|
||||
roxywi_common.logging(server_ip, 'The server ' + name + ' has been updated ', roxywi=1, login=1, keep_history=1,
|
||||
roxywi_common.logging(server_ip, f'The server {name} has been updated ', roxywi=1, login=1, keep_history=1,
|
||||
service=service)
|
||||
|
||||
if form.getvalue('updateserver') is not None:
|
||||
|
@ -1030,9 +927,9 @@ if form.getvalue('updateserver') is not None:
|
|||
else:
|
||||
sql.update_server(name, group, typeip, enable, master, serv_id, cred, port, desc, haproxy, nginx, apache,
|
||||
firewall, protected)
|
||||
roxywi_common.logging('the server ' + name, ' has been updated ', roxywi=1, login=1)
|
||||
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, 'The server ' + name + ' has been update', roxywi=1, login=1,
|
||||
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:
|
||||
|
@ -2706,6 +2603,11 @@ if act == 'getSystemInfo':
|
|||
if act == 'updateSystemInfo':
|
||||
server_mod.update_system_info()
|
||||
|
||||
if act == 'server_is_up':
|
||||
server_ip = common.is_ip_or_dns(form.getvalue('server_is_up'))
|
||||
|
||||
server_mod.server_is_up(server_ip)
|
||||
|
||||
if act == 'findInConfigs':
|
||||
server_ip = serv
|
||||
server_ip = common.is_ip_or_dns(server_ip)
|
||||
|
|
|
@ -19,7 +19,7 @@ user_params = roxywi_common.get_users_params()
|
|||
try:
|
||||
roxywi_auth.check_login(user_params['user_uuid'], user_params['token'])
|
||||
except Exception as e:
|
||||
print(f'error {e}')
|
||||
print('error: your session is expired')
|
||||
sys.exit()
|
||||
|
||||
try:
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
---
|
||||
- name: restart keepalived
|
||||
service: name=keepalived state=restarted
|
||||
|
||||
- name: restart rsyslog
|
||||
service: name=restart state=restarted
|
||||
service: name=rsyslog state=restarted
|
||||
|
|
|
@ -19,7 +19,7 @@ user_params = roxywi_common.get_users_params()
|
|||
try:
|
||||
roxywi_auth.check_login(user_params['user_uuid'], user_params['token'])
|
||||
except Exception as e:
|
||||
print(f'error {e}')
|
||||
print('error: your session is expired')
|
||||
sys.exit()
|
||||
|
||||
roxywi_auth.page_for_admin(level=2)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<tr class="odd">
|
||||
<td class="padding10 first-collumn-wi">
|
||||
{% if metrics_master == 'active' %}
|
||||
<span class="serverUp server-status" title="running {{ metrics_master }} master processes"></span>
|
||||
<span class="serverUp server-status-small" title="running {{ metrics_master }} master processes"></span>
|
||||
{% if role <= 1 %}
|
||||
<a href="/app/viewlogs.py?viewlogs={{metrics_log_id}}&rows=10&grep=&hour=00&minut=00&hour1=24&minut1=00" title="View metrics master's logs" class="logs_link">
|
||||
Metrics master
|
||||
|
@ -11,7 +11,7 @@
|
|||
{% endif %}
|
||||
{% else %}
|
||||
{% if metrics_master == 'inactive' or metrics_master == 'failed' %}
|
||||
<span class="serverDown server-status" title="Metrics is stopped"></span>
|
||||
<span class="serverDown server-status-small" title="Metrics is stopped"></span>
|
||||
{% if role <= 1 %}
|
||||
<a href="/app/users.py#services" title="Start Metrics - Roxy-WI service" class="logs_link">
|
||||
Metrics master
|
||||
|
@ -20,7 +20,7 @@
|
|||
Metrics master
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<span class="serverNone server-status" title="Metrics is not installed"></span>
|
||||
<span class="serverNone server-status-small" title="Metrics is not installed"></span>
|
||||
<a href="https://roxy-wi.org/services.py?service=metrics#installation" title="Metrics installation" target="_blank" class="logs_link">
|
||||
Metrics master
|
||||
</a>
|
||||
|
@ -29,7 +29,7 @@
|
|||
</td>
|
||||
<td class="third-collumn-wi">
|
||||
{% if checker_master == 'active' %}
|
||||
<span class="serverUp server-status" title="running {{ checker_master }} master processes"></span>
|
||||
<span class="serverUp server-status-small" title="running {{ checker_master }} master processes"></span>
|
||||
{% if role <= 1 %}
|
||||
<a href="/app/viewlogs.py?viewlogs={{checker_log_id}}&rows=10&grep=&hour=00&minut=00&hour1=24&minut1=00" title="View checker master's logs" class="logs_link">
|
||||
Checker master
|
||||
|
@ -39,7 +39,7 @@
|
|||
{% endif %}
|
||||
{% else %}
|
||||
{% if checker_master == 'inactive' or checker_master == 'failed' %}
|
||||
<span class="serverDown server-status" title="Checker is stopped"></span>
|
||||
<span class="serverDown server-status-small" title="Checker is stopped"></span>
|
||||
{% if role <= 1 %}
|
||||
<a href="/app/users.py#services" title="Start Checker - Roxy-WI service" class="logs_link">
|
||||
Checker master
|
||||
|
@ -48,7 +48,7 @@
|
|||
Checker master
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<span class="serverNone server-status" title="Backends checker is not installed"></span>
|
||||
<span class="serverNone server-status-small" title="Backends checker is not installed"></span>
|
||||
<a href="https://roxy-wi.org/services.py?service=checker#installation" title="Backends checker installation" target="_blank" class="logs_link">
|
||||
Checker master
|
||||
</a>
|
||||
|
@ -57,7 +57,7 @@
|
|||
</td>
|
||||
<td class="third-collumn-wi">
|
||||
{% if keep_alive == 'active' %}
|
||||
<span class="serverUp server-status" title="running {{ keep_alive }} processe"></span>
|
||||
<span class="serverUp server-status-small" title="running {{ keep_alive }} processe"></span>
|
||||
{% if role <= 1 %}
|
||||
<a href="/app/viewlogs.py?viewlogs={{keep_alive_log_id}}&rows=10&grep=&hour=00&minut=00&hour1=24&minut1=00" title="View Auto start logs" class="logs_link">
|
||||
Auto start
|
||||
|
@ -67,7 +67,7 @@
|
|||
{% endif %}
|
||||
{% else %}
|
||||
{% if keep_alive == 'inactive' or keep_alive == 'failed' %}
|
||||
<span class="serverDown server-status" title="Auto start is stopped"></span>
|
||||
<span class="serverDown server-status-small" title="Auto start is stopped"></span>
|
||||
{% if role <= 1 %}
|
||||
<a href="/app/users.py#services" title="Start Auto star - Roxy-WI service" class="logs_link">
|
||||
Auto start
|
||||
|
@ -76,7 +76,7 @@
|
|||
Auto start
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<span class="serverNone server-status" title="Auto start is not installed"></span>
|
||||
<span class="serverNone server-status-small" title="Auto start is not installed"></span>
|
||||
<a href="https://roxy-wi.org/services.py?service=auto_start#installation" title="Auto start installation" target="_blank" class="logs_link">
|
||||
Auto start
|
||||
</a>
|
||||
|
@ -87,12 +87,12 @@
|
|||
<tr class="even">
|
||||
<td class="padding10 first-collumn-wi">
|
||||
{% if metrics_worker|int() >= 1 %}
|
||||
<span class="serverUp server-status" title="running {{metrics_worker}} worker processes"></span>
|
||||
<span class="serverUp server-status-small" title="running {{metrics_worker}} worker processes"></span>
|
||||
{% else %}
|
||||
{% if is_metrics_worker|int() == 0 %}
|
||||
<span class="serverNone server-status" title="There is not job for metrics"></span>
|
||||
<span class="serverNone server-status-small" title="There is not job for metrics"></span>
|
||||
{% else %}
|
||||
<span class="serverDown server-status" title="running {{is_checker_worker}} worker processes"></span>
|
||||
<span class="serverDown server-status-small" title="running {{is_checker_worker}} worker processes"></span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if role <= 1 %}
|
||||
|
@ -105,12 +105,12 @@
|
|||
</td>
|
||||
<td>
|
||||
{% if checker_worker|int() >= 1 %}
|
||||
<span class="serverUp server-status" title="running {{ checker_worker }} worker processes"></span>
|
||||
<span class="serverUp server-status-small" title="running {{ checker_worker }} worker processes"></span>
|
||||
{% else %}
|
||||
{% if is_checker_worker|int() == 0 %}
|
||||
<span class="serverNone server-status" title="There is not job for checker"></span>
|
||||
<span class="serverNone server-status-small" title="There is not job for checker"></span>
|
||||
{% else %}
|
||||
<span class="serverDown server-status" title="running {{ checker_worker }} worker processes"></span>
|
||||
<span class="serverDown server-status-small" title="running {{ checker_worker }} worker processes"></span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if role <= 1 %}
|
||||
|
@ -123,18 +123,18 @@
|
|||
</td>
|
||||
<td>
|
||||
{% if smon == 'active' %}
|
||||
<span class="serverUp server-status" title="SMON is started"></span>
|
||||
<span class="serverUp server-status-small" title="SMON is started"></span>
|
||||
<a href="/app/smon.py?action=view" title="SMON Dashboard" class="logs_link">
|
||||
SMON
|
||||
</a>
|
||||
{% else %}
|
||||
{% if smon == 'inactive' or smon == 'failed' %}
|
||||
<span class="serverDown server-status" title="SMON is stopped"></span>
|
||||
<span class="serverDown server-status-small" title="SMON is stopped"></span>
|
||||
<a href="/app/users.py#services" title="Start SMON - Roxy-WI service" class="logs_link">
|
||||
SMON
|
||||
</a>
|
||||
{% else %}
|
||||
<span title="SMON is not installed"><span class="serverNone server-status"></span></span>
|
||||
<span title="SMON is not installed"><span class="serverNone server-status-small"></span></span>
|
||||
<a href="https://roxy-wi.org/services.py?service=smon" title="Simple monitoring ports installation" target="_blank" class="logs_link">
|
||||
SMON
|
||||
</a>
|
||||
|
@ -146,17 +146,17 @@
|
|||
{% if role == 1 %}
|
||||
<td class="padding10 first-collumn-wi">
|
||||
{% if grafana|int() >= 1 %}
|
||||
<span class="serverUp server-status" title="running {{grafana}} process"></span>
|
||||
<span class="serverUp server-status-small" title="running {{grafana}} process"></span>
|
||||
<a href="http://{{host}}:3000" target="_blank" title="Open Grafana" class="logs_link" rel="noopener noreferrer">Grafana</a>
|
||||
{% else %}
|
||||
<span class="serverNone server-status" title="The service is not installed or not running"></span>
|
||||
<span class="serverNone server-status-small" title="The service is not installed or not running"></span>
|
||||
<span>Grafana</span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td {% if role != 1 %}class="padding10 first-collumn-wi"{%endif%}>
|
||||
{% if socket == 'active' %}
|
||||
<span class="serverUp server-status" title="Socket service is started"></span>
|
||||
<span class="serverUp server-status-small" title="Socket service is started"></span>
|
||||
{% if role <= 1 %}
|
||||
<a href="/app/viewlogs.py?viewlogs={{socket_log_id}}&rows=10&grep=&hour=00&minut=00&hour1=24&minut1=00" title="View Socket's logs" class="logs_link">
|
||||
Socket service
|
||||
|
@ -166,12 +166,12 @@
|
|||
{% endif %}
|
||||
{% else %}
|
||||
{% if socket == 'inactive' or socket == 'failed' %}
|
||||
<span class="serverDown server-status" title="Socket service scanner is stopped"></span>
|
||||
<span class="serverDown server-status-small" title="Socket service scanner is stopped"></span>
|
||||
<a href="/app/users.py#services" title="Socket service - Roxy-WI service" class="logs_link">
|
||||
Socket service
|
||||
</a>
|
||||
{% else %}
|
||||
<span title="Socket service is not installed"><span class="serverNone server-status"></span></span>
|
||||
<span title="Socket service is not installed"><span class="serverNone server-status-small"></span></span>
|
||||
<a href="https://roxy-wi.org/services.py?service=socket" title="Socket service" target="_blank" class="logs_link">
|
||||
Socket service
|
||||
</a>
|
||||
|
@ -180,18 +180,18 @@
|
|||
</td>
|
||||
<td>
|
||||
{% if port_scanner == 'active' %}
|
||||
<span class="serverUp server-status" title="Port scanner is started"></span>
|
||||
<span class="serverUp server-status-small" title="Port scanner is started"></span>
|
||||
<a href="/app/portscanner.py" title="Port scanner Dashboard" class="logs_link">
|
||||
Port scanner
|
||||
</a>
|
||||
{% else %}
|
||||
{% if port_scanner == 'inactive' or port_scanner == 'failed' %}
|
||||
<span class="serverDown server-status" title="Port scanner is stopped"></span>
|
||||
<span class="serverDown server-status-small" title="Port scanner is stopped"></span>
|
||||
<a href="/app/users.py#services" title="Start Port scanner - Roxy-WI service" class="logs_link">
|
||||
Port scanner
|
||||
</a>
|
||||
{% else %}
|
||||
<span title="Port scanner is not installed"><span class="serverNone server-status"></span></span>
|
||||
<span title="Port scanner is not installed"><span class="serverNone server-status-small"></span></span>
|
||||
<a href="https://roxy-wi.org/services.py?service=port_scanner" title="Port scanner" target="_blank" class="logs_link">
|
||||
Port scanner
|
||||
</a>
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
<table class="overview-wi">
|
||||
<tr class="overviewHead">
|
||||
<td class="padding10 first-collumn-wi" colspan=2>
|
||||
<span class="runtime"></span>
|
||||
Base info
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -34,6 +35,7 @@
|
|||
<table class="overview-wi">
|
||||
<tr class="overviewHead" colspan=2>
|
||||
<td class="padding10 first-collumn-wi">
|
||||
<span class="ram"></span>
|
||||
RAM
|
||||
</td>
|
||||
<td>
|
||||
|
@ -59,6 +61,7 @@
|
|||
<table class="overview-wi" style="clear: both;">
|
||||
<tr class="overviewHead">
|
||||
<td class="padding10 first-collumn-wi" colspan=2>
|
||||
<span class="cpu"></span>
|
||||
CPU
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -92,6 +95,7 @@
|
|||
<table class="overview-wi">
|
||||
<tr class="overviewHead" colspan=2>
|
||||
<td class="padding10 first-collumn-wi" colspan=2>
|
||||
<span class="hdd"></span>
|
||||
{{v}}
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -126,6 +130,7 @@
|
|||
<table class="overview-wi">
|
||||
<tr class="overviewHead" colspan=2>
|
||||
<td class="padding10 first-collumn-wi" colspan=2>
|
||||
<span class="ethernet"></span>
|
||||
{{v}}
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -174,7 +174,6 @@
|
|||
<a class="delete" onclick="confirmDeleteServer({{server.0}})" title="Delete server {{server.1}}" style="cursor: pointer;"></a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="server_info-{{server.0}}" style="display: none"></tr>
|
||||
{% endfor %}
|
||||
{% if not adding %}
|
||||
</tbody>
|
||||
|
|
|
@ -356,4 +356,9 @@
|
|||
</div>
|
||||
<div id="change-user-service-dialog" style="display: none;">
|
||||
<div id="change-user-service-form"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="dialog-server-info" style="display: none;">
|
||||
<table class="overview">
|
||||
<tr id="server-info"></tr>
|
||||
</table>
|
||||
</div>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
{% else %}
|
||||
{% if page == 'users.py' %}
|
||||
<table id="grafana-table">
|
||||
<caption><h3>Installing Grafana and Prometheus servers</h3></caption>
|
||||
<caption><h3>Grafana and Prometheus servers</h3></caption>
|
||||
<tr class="overviewHead">
|
||||
<td class="padding10 first-collumn">Current installation</td>
|
||||
<td class="padding10 first-collumn" style="width: 40%;">Available Versions</td>
|
||||
|
@ -41,7 +41,7 @@
|
|||
</table>
|
||||
{% endif %}
|
||||
<table id="haproxy-table">
|
||||
<caption><h3>Install HAProxy Exporter</h3></caption>
|
||||
<caption><h3>HAProxy Exporter</h3></caption>
|
||||
<tr class="overviewHead">
|
||||
<td class="padding10 first-collumn" style="width: 20%;">Current installation</td>
|
||||
<td class="padding10 first-collumn" style="width: 30%;">Available Versions</td>
|
||||
|
@ -72,7 +72,7 @@
|
|||
</tr>
|
||||
</table>
|
||||
<table id="nginx-table">
|
||||
<caption><h3>Install NGINX Exporter</h3></caption>
|
||||
<caption><h3>NGINX Exporter</h3></caption>
|
||||
<tr class="overviewHead">
|
||||
<td class="padding10 first-collumn" style="width: 20%;">Current installation</td>
|
||||
<td class="padding10 first-collumn" style="width: 30%;">Available Versions</td>
|
||||
|
@ -103,7 +103,7 @@
|
|||
</tr>
|
||||
</table>
|
||||
<table id="apache-table">
|
||||
<caption><h3>Install Apache Exporter</h3></caption>
|
||||
<caption><h3>Apache Exporter</h3></caption>
|
||||
<tr class="overviewHead">
|
||||
<td class="padding10 first-collumn" style="width: 20%;">Current installation</td>
|
||||
<td class="padding10 first-collumn" style="width: 30%;">Available Versions</td>
|
||||
|
@ -134,7 +134,7 @@
|
|||
</tr>
|
||||
</table>
|
||||
<table id="keepalived-table">
|
||||
<caption><h3>Install Keepalived Exporter</h3></caption>
|
||||
<caption><h3>Keepalived Exporter</h3></caption>
|
||||
<tr class="overviewHead">
|
||||
<td class="padding10 first-collumn" style="width: 20%;">Current installation</td>
|
||||
<td class="padding10 first-collumn" style="width: 30%;">Available Versions</td>
|
||||
|
@ -165,7 +165,7 @@
|
|||
</tr>
|
||||
</table>
|
||||
<table style="margin-top: 20px" id="node-table">
|
||||
<caption><h3>Install Node Exporter</h3></caption>
|
||||
<caption><h3>Node Exporter</h3></caption>
|
||||
<tr class="overviewHead">
|
||||
<td class="padding10 first-collumn" style="width: 20%;">Current installation</td>
|
||||
<td class="padding10 first-collumn" style="width: 30%;">Available Versions</td>
|
||||
|
|
|
@ -22,7 +22,7 @@ user_params = roxywi_common.get_users_params()
|
|||
try:
|
||||
roxywi_auth.check_login(user_params['user_uuid'], user_params['token'])
|
||||
except Exception as e:
|
||||
print(f'error {e}')
|
||||
print('error: your session is expired')
|
||||
sys.exit()
|
||||
|
||||
if form.getvalue('grep') is None:
|
||||
|
|
|
@ -421,6 +421,26 @@
|
|||
font-family: "Font Awesome 5 Solid";
|
||||
content: "\f0f3";
|
||||
}
|
||||
.cpu::before {
|
||||
display: none;
|
||||
font-family: "Font Awesome 5 Solid";
|
||||
content: "\f2db";
|
||||
}
|
||||
.hdd::before {
|
||||
display: none;
|
||||
font-family: "Font Awesome 5 Solid";
|
||||
content: "\f0a0";
|
||||
}
|
||||
.ram::before {
|
||||
display: none;
|
||||
font-family: "Font Awesome 5 Solid";
|
||||
content: "\f538";
|
||||
}
|
||||
.ethernet::before {
|
||||
display: none;
|
||||
font-family: "Font Awesome 5 Solid";
|
||||
content: "\f796";
|
||||
}
|
||||
.user-circle::before {
|
||||
display: none;
|
||||
font-family: "Font Awesome 5 Solid";
|
||||
|
|
|
@ -825,6 +825,13 @@ label {
|
|||
margin-left: 2px;
|
||||
margin-bottom: -2px;
|
||||
}
|
||||
.server-status-small {
|
||||
border-radius: 50% 50%;
|
||||
width: 5px;
|
||||
height: 5px;
|
||||
display: inline-block;
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
.server-action {
|
||||
float: right;
|
||||
margin-top: 6px;
|
||||
|
|
60
inc/users.js
60
inc/users.js
|
@ -1119,7 +1119,10 @@ function addServer(dialog_id) {
|
|||
type: "POST",
|
||||
success: function( data ) {
|
||||
data = data.replace(/\s+/g,' ');
|
||||
if (data.indexOf('error:') != '-1') {
|
||||
if (data.indexOf('You should install lshw on the server') != '-1') {
|
||||
toastr.error(data);
|
||||
$( dialog_id ).dialog("close");
|
||||
} else if (data.indexOf('error:') != '-1') {
|
||||
toastr.error(data);
|
||||
} else {
|
||||
common_ajax_action_after_success(dialog_id, 'newserver', 'ajax-servers', data);
|
||||
|
@ -2737,32 +2740,37 @@ function updateServerInfo(ip, id) {
|
|||
} );
|
||||
}
|
||||
function showServerInfo(id, ip) {
|
||||
if ($('#server_info-'+id).css('display') == 'none') {
|
||||
$.ajax({
|
||||
url: "options.py",
|
||||
data: {
|
||||
act: 'getSystemInfo',
|
||||
server_ip: ip,
|
||||
server_id: id,
|
||||
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 {
|
||||
$("#server_info-"+id).html(data);
|
||||
$('#server_info-'+id).show();
|
||||
$('#server_info_link-'+id).attr('title', 'Hide System info');
|
||||
$.getScript(awesome);
|
||||
}
|
||||
$.ajax({
|
||||
url: "options.py",
|
||||
data: {
|
||||
act: 'getSystemInfo',
|
||||
server_ip: ip,
|
||||
server_id: id,
|
||||
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 {
|
||||
$("#server-info").html(data);
|
||||
$("#dialog-server-info").dialog({
|
||||
resizable: false,
|
||||
height: "auto",
|
||||
width: 1250,
|
||||
modal: true,
|
||||
title: "Server info (" + ip + ")",
|
||||
buttons: {
|
||||
Close: function () {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
}
|
||||
});
|
||||
$.getScript(awesome);
|
||||
}
|
||||
} );
|
||||
} else {
|
||||
$('#server_info-'+id).hide();
|
||||
$('#server_info_link-'+id).attr('title', 'Show System info');
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
function updateHaproxyCheckerSettings(id) {
|
||||
toastr.clear();
|
||||
|
|
Loading…
Reference in New Issue