diff --git a/app/funct.py b/app/funct.py index 1e9df15..f2ffc53 100644 --- a/app/funct.py +++ b/app/funct.py @@ -866,7 +866,7 @@ def open_port_firewalld(cfg, serv, **kwargs): pass firewalld_commands += 'sudo firewall-cmd --reload -q' - logging(serv, ' Next ports have been opened: ' + ports + ' has opened ') + logging(serv, ' Next ports have been opened: ' + ports) return firewalld_commands diff --git a/app/scripts/ansible/roles/grafana.yml b/app/scripts/ansible/roles/grafana.yml index 6ad812d..6159fb1 100644 --- a/app/scripts/ansible/roles/grafana.yml +++ b/app/scripts/ansible/roles/grafana.yml @@ -50,12 +50,48 @@ debugger: never when: (ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS') and ansible_facts.services["firewalld.service"]['state'] == "running" with_items: [ "3000", "9090" ] - + - name: Open stat port for iptables iptables: chain: INPUT destination_port: "{{ item }}" jump: ACCEPT protocol: tcp - ignore_errors: yes - with_items: [ "3000", "9090" ] \ No newline at end of file + ignore_errors: yes + with_items: [ "3000", "9090" ] + + - name: Ensure group "grafana" exists + ansible.builtin.group: + name: grafana + state: present + + - name: Add the Grafana user + user: + name: grafana + shell: /sbin/nologin + groups: grafana + append: yes + + - name: Create a directory if it does not exist + file: + path: "{{ item }}" + state: directory + mode: '0755' + owner: grafana + with_items: + - /var/lib/grafana + - /var/log/grafana + - /etc/grafana + + - name: Create grafana.ini + file: + path: /etc/grafana/grafana.ini + owner: grafana + group: grafana + mode: '0644' + state: touch + + - name: Restart service Grafana, in all cases + service: + name: grafana-server + state: restarted \ No newline at end of file diff --git a/app/sql.py b/app/sql.py index ea96753..bf46a08 100644 --- a/app/sql.py +++ b/app/sql.py @@ -553,16 +553,11 @@ def delete_uuid(uuid): def delete_old_uuid(): - cursor = conn.cursor() - if mysql_enable == '1': - sql = """ delete from uuid where exp < now() or exp is NULL """ - sql1 = """ delete from token where exp < now() or exp is NULL """ - else: - sql = """ delete from uuid where exp < datetime('now') or exp is NULL""" - sql1 = """ delete from token where exp < datetime('now') or exp is NULL""" + query = UUID.delete().where((UUID.exp < funct.get_data('regular')) | (UUID.exp.is_null(True)) ) + query1 = Token.delete().where((Token.exp < funct.get_data('regular')) | (Token.exp.is_null(True)) ) try: - cursor.execute(sql) - cursor.execute(sql1) + query.execute() + query1.execute() except Exception as e: funct.out_error(e) @@ -1110,25 +1105,28 @@ def select_waf_servers_metrics_for_master(): def select_waf_servers_metrics(uuid): - cursor = conn.cursor() - try: user_group = User.get(User.username == get_user_name_by_uuid(uuid)) except Exception as e: funct.out_error(e) else: if user_group.groups == '1': - 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' """ + query = Waf.select(Server.ip).join(Server, on=(Waf.server_id == Server.server_id)).where( + (Server.enable == 1) & + (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 and waf.metrics = '1' and servers.groups like '%{group}%' """.format(group=user_group.groups) + query = Waf.select(Server.ip).join(Server, on=(Waf.server_id == Server.server_id)).where( + (Server.enable == 1) & + (Waf.metrics == 1) & + (Server.groups == user_group.groups) + ) try: - cursor.execute(sql) + query_res = query.execute() except Exception as e: funct.out_error(e) else: - return cursor.fetchall() + return query_res def select_waf_metrics(serv, **kwargs): diff --git a/app/templates/add.html b/app/templates/add.html index 7c18809..9eb4b60 100644 --- a/app/templates/add.html +++ b/app/templates/add.html @@ -6,7 +6,7 @@ 'rdp-cookie':'rdp-cookie', 'uri':'uri', 'uri whole':'uri whole', 'static-rr': 'static-rr', 'url_param userid':'url_param userid'} %} {% set checks = dict() %} -{% set checks = {'':'Choose custom health check','option tcp-check':'Check a TCP Port', +{% set checks = {'':'Choose a custom health check','option tcp-check':'Check a TCP Port', 'option ssl-hello-chk':'Check a SSL Port','option httpchk':'Check a HTTP service', 'option ldap-check':'Check a LDAP service', 'option mysql-check':'Check a MySql Service', 'option pgsql-check':'Check a PgSQL Service', 'option redis-check': 'Check a Redis Service', @@ -40,15 +40,15 @@ - + @@ -289,15 +289,15 @@

Add listen

Select server: Select a server: -
Note: If you re-configure the master server, the slave server will re-configured automatically
+
Note: If you re-configure the master server, the slave server will be re-configured automatically
A "listen" section defines a complete proxy with its frontend and backend parts combined in one section. It is generally useful for TCP-only traffic. @@ -73,7 +73,7 @@ {{ input('ip', placeholder="Any", size='15') }}: {{ input('listen-port', name='port', type="number", title="Port for bind listen", placeholder="8080", size='5', required='required') }}
- The IP address for the bind listener, if empty, will be assigned to all IP addresses.
+ If the IP-address for the listener is empty, it will listen on all IP addresses.
Start typing IP or press down button. If you are using VRRP, leave the IP field blank. If you assign a VRRP IP, the slave server will not start
- + @@ -465,15 +465,15 @@

Add frontend

Select server: Select a server: -
Note: If you re-configure the master server, the slave server will re-configured automatically
+
Note: If you re-configure the master server, the slave server will be re-configured automatically
A "frontend" section describes a set of listening sockets accepting client connections. @@ -322,7 +322,7 @@ :
- The IP address for the bind listener, if empty, will be assigned to all IP addresses.
+ If the IP-address for the frontend is empty, it will listen on all IP addresses.
Start typing IP or press down button. If you are using VRRP, leave the IP field blank. If you assign a VRRP IP, the slave server will not start
- +

Add backend

Select server: Select a server: -
Note: If you re-configure the master server, the slave server will reconfigured automatically
+
Note: If you re-configure the master server, the slave server will be re-configured automatically
A "backend" section describes a set of servers to which the proxy will connect to forward incoming connections. @@ -678,7 +678,7 @@
- +

Add Userlist

Select server: Select a server: -
Note: If you reconfigure Master server, Slave will reconfigured automatically
+
Note: If you reconfigure Master server, Slave will be re-configured automatically
It is possible to control access to frontend/backend/listen sections or to @@ -928,15 +928,15 @@ - +

Existing UserList

Select server: Select a server: -
Note: If you reconfigure Master server, Slave will reconfigured automatically
+
Note: If you reconfigure Master server, Slave will be re-configured automatically
Show Userlist @@ -965,12 +965,12 @@ Select server: -
Note: If you reconfigure Master server, Slave will reconfigured automatically
+
Note: If you re-configure Master server, Slave will be re-configured automatically
The peers section enables the replication of stick table data between two or more HAProxy instances. @@ -1038,7 +1038,7 @@
- Choose server for backup + Select a server for backup * - + {% for select in selects %} {% if select.2 == serv %} diff --git a/app/templates/nettools.html b/app/templates/nettools.html index dc0c50c..0301c1d 100644 --- a/app/templates/nettools.html +++ b/app/templates/nettools.html @@ -31,7 +31,7 @@