diff --git a/app/add.py b/app/add.py index e4cdb7e1..572d8716 100644 --- a/app/add.py +++ b/app/add.py @@ -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) diff --git a/app/create_db.py b/app/create_db.py index e8315f94..dfc40510 100644 --- a/app/create_db.py +++ b/app/create_db.py @@ -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() diff --git a/app/modules/db/db_model.py b/app/modules/db/db_model.py index 48ba1f01..013f6ea8 100644 --- a/app/modules/db/db_model.py +++ b/app/modules/db/db_model.py @@ -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' diff --git a/app/modules/db/sql.py b/app/modules/db/sql.py index fd5986a2..b048f148 100755 --- a/app/modules/db/sql.py +++ b/app/modules/db/sql.py @@ -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) diff --git a/app/modules/roxywi/common.py b/app/modules/roxywi/common.py index b1b6e02d..dacf8cbd 100644 --- a/app/modules/roxywi/common.py +++ b/app/modules/roxywi/common.py @@ -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('') - return + return try: role = sql.get_user_role_by_uuid(user_uuid.value) except Exception: diff --git a/app/modules/roxywi/metrics.py b/app/modules/roxywi/metrics.py new file mode 100644 index 00000000..af15fa1d --- /dev/null +++ b/app/modules/roxywi/metrics.py @@ -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)) diff --git a/app/modules/server/server.py b/app/modules/server/server.py index 7e39e99d..64a8a104 100644 --- a/app/modules/server/server.py +++ b/app/modules/server/server.py @@ -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) diff --git a/app/options.py b/app/options.py index 4cd4829c..197b4200 100644 --- a/app/options.py +++ b/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) diff --git a/app/overview.py b/app/overview.py index ce9226b4..a660038a 100644 --- a/app/overview.py +++ b/app/overview.py @@ -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: diff --git a/app/scripts/ansible/roles/keepalived/handlers/main.yml b/app/scripts/ansible/roles/keepalived/handlers/main.yml index ae1aa8dc..7424ff9d 100644 --- a/app/scripts/ansible/roles/keepalived/handlers/main.yml +++ b/app/scripts/ansible/roles/keepalived/handlers/main.yml @@ -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 diff --git a/app/servers.py b/app/servers.py index c4ca7523..1f939ead 100644 --- a/app/servers.py +++ b/app/servers.py @@ -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) diff --git a/app/templates/ajax/show_services_ovw.html b/app/templates/ajax/show_services_ovw.html index 7f951d65..b3ae3160 100644 --- a/app/templates/ajax/show_services_ovw.html +++ b/app/templates/ajax/show_services_ovw.html @@ -1,7 +1,7 @@ {% if metrics_master == 'active' %} - + {% if role <= 1 %} Metrics master @@ -11,7 +11,7 @@ {% endif %} {% else %} {% if metrics_master == 'inactive' or metrics_master == 'failed' %} - + {% if role <= 1 %} Metrics master @@ -20,7 +20,7 @@ Metrics master {% endif %} {% else %} - + Metrics master @@ -29,7 +29,7 @@ {% if checker_master == 'active' %} - + {% if role <= 1 %} Checker master @@ -39,7 +39,7 @@ {% endif %} {% else %} {% if checker_master == 'inactive' or checker_master == 'failed' %} - + {% if role <= 1 %} Checker master @@ -48,7 +48,7 @@ Checker master {% endif %} {% else %} - + Checker master @@ -57,7 +57,7 @@ {% if keep_alive == 'active' %} - + {% if role <= 1 %} Auto start @@ -67,7 +67,7 @@ {% endif %} {% else %} {% if keep_alive == 'inactive' or keep_alive == 'failed' %} - + {% if role <= 1 %} Auto start @@ -76,7 +76,7 @@ Auto start {% endif %} {% else %} - + Auto start @@ -87,12 +87,12 @@ {% if metrics_worker|int() >= 1 %} - + {% else %} {% if is_metrics_worker|int() == 0 %} - + {% else %} - + {% endif %} {% endif %} {% if role <= 1 %} @@ -105,12 +105,12 @@ {% if checker_worker|int() >= 1 %} - + {% else %} {% if is_checker_worker|int() == 0 %} - + {% else %} - + {% endif %} {% endif %} {% if role <= 1 %} @@ -123,18 +123,18 @@ {% if smon == 'active' %} - + SMON {% else %} {% if smon == 'inactive' or smon == 'failed' %} - + SMON {% else %} - + SMON @@ -146,17 +146,17 @@ {% if role == 1 %} {% if grafana|int() >= 1 %} - + Grafana {% else %} - + Grafana {% endif %} {% endif %} {% if socket == 'active' %} - + {% if role <= 1 %} Socket service @@ -166,12 +166,12 @@ {% endif %} {% else %} {% if socket == 'inactive' or socket == 'failed' %} - + Socket service {% else %} - + Socket service @@ -180,18 +180,18 @@ {% if port_scanner == 'active' %} - + Port scanner {% else %} {% if port_scanner == 'inactive' or port_scanner == 'failed' %} - + Port scanner {% else %} - + Port scanner diff --git a/app/templates/ajax/show_system_info.html b/app/templates/ajax/show_system_info.html index 5c45aec6..dbc543a6 100644 --- a/app/templates/ajax/show_system_info.html +++ b/app/templates/ajax/show_system_info.html @@ -10,6 +10,7 @@ @@ -34,6 +35,7 @@
+ Base info
+ RAM @@ -59,6 +61,7 @@ @@ -92,6 +95,7 @@
+ CPU
@@ -126,6 +130,7 @@
+ {{v}}
diff --git a/app/templates/include/admin_servers.html b/app/templates/include/admin_servers.html index 3b809036..53ad09e3 100644 --- a/app/templates/include/admin_servers.html +++ b/app/templates/include/admin_servers.html @@ -174,7 +174,6 @@ - {% endfor %} {% if not adding %} diff --git a/app/templates/include/admins_dialogs.html b/app/templates/include/admins_dialogs.html index 1041dbce..f9b1abae 100644 --- a/app/templates/include/admins_dialogs.html +++ b/app/templates/include/admins_dialogs.html @@ -356,4 +356,9 @@ \ No newline at end of file + +
+ {{v}}
+ +
+ diff --git a/app/templates/include/mon_installation.html b/app/templates/include/mon_installation.html index 2abc123b..acc29d1c 100644 --- a/app/templates/include/mon_installation.html +++ b/app/templates/include/mon_installation.html @@ -9,7 +9,7 @@ {% else %} {% if page == 'users.py' %} - + @@ -41,7 +41,7 @@

Installing Grafana and Prometheus servers

Grafana and Prometheus servers

Current installation Available Versions
{% endif %} - + @@ -72,7 +72,7 @@

Install HAProxy Exporter

HAProxy Exporter

Current installation Available Versions
- + @@ -103,7 +103,7 @@

Install NGINX Exporter

NGINX Exporter

Current installation Available Versions
- + @@ -134,7 +134,7 @@

Install Apache Exporter

Apache Exporter

Current installation Available Versions
- + @@ -165,7 +165,7 @@

Install Keepalived Exporter

Keepalived Exporter

Current installation Available Versions
- + diff --git a/app/viewlogs.py b/app/viewlogs.py index d09cc887..14728da8 100644 --- a/app/viewlogs.py +++ b/app/viewlogs.py @@ -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: diff --git a/inc/css/awesome.css b/inc/css/awesome.css index d4d9de60..019990f5 100644 --- a/inc/css/awesome.css +++ b/inc/css/awesome.css @@ -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"; diff --git a/inc/css/style.css b/inc/css/style.css index 237eeccc..f025e71f 100644 --- a/inc/css/style.css +++ b/inc/css/style.css @@ -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; diff --git a/inc/users.js b/inc/users.js index 5bd00f46..22ab81c2 100644 --- a/inc/users.js +++ b/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();

Install Node Exporter

Node Exporter

Current installation Available Versions