From 6eb68b1983362e08253c294200bf1dfdd51d1765 Mon Sep 17 00:00:00 2001 From: Pavel Loginov Date: Fri, 27 Mar 2020 22:16:04 +0100 Subject: [PATCH] v4.2.0.0 https://haproxy-wi.org/changelog.py#4_2 --- app/create_db.py | 2 +- app/login.py | 1 - app/options.py | 161 ++++++++- app/scripts/ansible/roles/grafana.yml | 35 ++ .../ansible/roles/haproxy_exporter.yml | 12 + app/scripts/ansible/roles/nginx_exporter.yml | 15 + app/scripts/install_grafana.sh | 50 +++ app/scripts/install_haproxy_exporter.sh | 55 +++ app/scripts/install_nginx_exporter.sh | 55 +++ app/scripts/waf.sh | 6 +- app/servers.py | 2 + app/templates/ajax/config_show.html | 329 ++++++++++-------- app/templates/config.html | 11 +- app/templates/hapservers.html | 6 +- app/templates/servers.html | 103 +++++- 15 files changed, 665 insertions(+), 178 deletions(-) create mode 100644 app/scripts/ansible/roles/grafana.yml create mode 100644 app/scripts/ansible/roles/haproxy_exporter.yml create mode 100644 app/scripts/ansible/roles/nginx_exporter.yml create mode 100644 app/scripts/install_grafana.sh create mode 100644 app/scripts/install_haproxy_exporter.sh create mode 100644 app/scripts/install_nginx_exporter.sh diff --git a/app/create_db.py b/app/create_db.py index 5a7f4845..d7d20027 100644 --- a/app/create_db.py +++ b/app/create_db.py @@ -432,7 +432,7 @@ def update_db_v_42(**kwargs): def update_ver(**kwargs): con, cur = get_cur() - sql = """update version set version = '4.1.0.0'; """ + sql = """update version set version = '4.2.0.0'; """ try: cur.execute(sql) con.commit() diff --git a/app/login.py b/app/login.py index f5605cba..65764a37 100644 --- a/app/login.py +++ b/app/login.py @@ -1,7 +1,6 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -import cgi import os import sys import funct diff --git a/app/options.py b/app/options.py index 231abb43..51b6149b 100644 --- a/app/options.py +++ b/app/options.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*-" +# -*- coding: utf-8 -*- import os, sys import funct import sql @@ -595,10 +595,10 @@ if form.getvalue('servaction') is not None: command = [ cmd ] if enable != "show": - print('

You %s %s on HAproxy %s. Look it or Edit something else


' % (enable, backend, serv, serv)) + print('

You %s %s on HAproxy %s. Look it or Edit something else


' % (enable, backend, serv, serv)) print(funct.ssh_command(serv, command, show_log="1")) - action = 'edit.py ' + enable + ' ' + backend + action = 'runtimeapi.py ' + enable + ' ' + backend funct.logging(serv, action) @@ -641,14 +641,20 @@ if serv is not None and form.getvalue('right') is not None: if serv is not None and act == "configShow": if form.getvalue('service') == 'keepalived': configs_dir = funct.get_config_var('configs', 'kp_save_configs_dir') + cfg = '.conf' elif form.getvalue('service') == 'nginx': configs_dir = funct.get_config_var('configs', 'nginx_save_configs_dir') + cfg = '.conf' else: configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir') + cfg = '.cfg' if form.getvalue('configver') is None: - cfg = configs_dir + serv + "-" + funct.get_data('config') + ".cfg" - funct.get_config(serv, cfg) + cfg = configs_dir + serv + "-" + funct.get_data('config') + cfg + if form.getvalue('service') == 'nginx': + funct.get_config(serv, cfg, nginx=1) + else: + funct.get_config(serv, cfg) else: cfg = configs_dir + form.getvalue('configver') try: @@ -842,6 +848,147 @@ if form.getvalue('masteradd'): os.system("rm -f %s" % script) +if form.getvalue('install_grafana'): + script = "install_grafana.sh" + proxy = sql.get_setting('proxy') + + os.system("cp scripts/%s ." % script) + + if proxy is not None and proxy != '' and proxy != 'None': + proxy_serv = proxy + else: + proxy_serv = '' + + commands = [ "chmod +x "+script +" && ./"+script +" PROXY=" + proxy_serv ] + + output, error = funct.subprocess_execute(commands[0]) + + if error: + funct.logging('localhost', error, haproxywi=1) + import socket + print('success: Grafana and Prometheus servers were installed. You can find Grafana on http://'+socket.gethostname()+':3000
') + else: + for l in output: + if "FAILED" in l: + try: + l = l.split(':')[1] + l = l.split('"')[1] + print(l+"
") + break + except: + print(output) + break + else: + import socket + print('success: Grafana and Prometheus servers were installed. You can find Grafana on http://'+socket.gethostname()+':3000
') + + os.system("rm -f %s" % script) + + +if form.getvalue('haproxy_exp_install'): + serv = form.getvalue('haproxy_exp_install') + script = "install_haproxy_exporter.sh" + stats_port = sql.get_setting('stats_port') + server_state_file = sql.get_setting('server_state_file') + stats_user = sql.get_setting('stats_user') + stats_password = sql.get_setting('stats_password') + stat_page = sql.get_setting('stats_page') + proxy = sql.get_setting('proxy') + ssh_enable, ssh_user_name, ssh_user_password, ssh_key_name = funct.return_ssh_keys_path(serv) + + if ssh_enable == 0: + ssh_key_name = '' + + servers = sql.select_servers(server=serv) + for server in servers: + ssh_port = str(server[10]) + + os.system("cp scripts/%s ." % script) + + if proxy is not None and proxy != '' and proxy != 'None': + proxy_serv = proxy + else: + proxy_serv = '' + + commands = [ "chmod +x "+script +" && ./"+script +" PROXY=" + proxy_serv+ + " STAT_PORT="+stats_port+" STAT_FILE="+server_state_file+ + " SSH_PORT="+ssh_port+" STAT_PAGE="+stat_page+ + " STATS_USER="+stats_user+" STATS_PASS="+stats_password+" HOST="+serv+ + " USER="+ssh_user_name+" PASS="+ssh_user_password+" KEY="+ssh_key_name ] + + output, error = funct.subprocess_execute(commands[0]) + + if error: + funct.logging('localhost', error, haproxywi=1) + print('error: '+error) + else: + for l in output: + if "msg" in l or "FAILED" in l: + try: + l = l.split(':')[1] + l = l.split('"')[1] + print(l+"
") + break + except: + print(output) + break + else: + print('success: HAProxy exporter was installed
') + + os.system("rm -f %s" % script) + + +if form.getvalue('nginx_exp_install'): + serv = form.getvalue('nginx_exp_install') + script = "install_nginx_exporter.sh" + stats_user = sql.get_setting('nginx_stats_user') + stats_password = sql.get_setting('nginx_stats_password') + stats_port = sql.get_setting('nginx_stats_port') + stats_page = sql.get_setting('nginx_stats_page') + proxy = sql.get_setting('proxy') + ssh_enable, ssh_user_name, ssh_user_password, ssh_key_name = funct.return_ssh_keys_path(serv) + + if ssh_enable == 0: + ssh_key_name = '' + + servers = sql.select_servers(server=serv) + for server in servers: + ssh_port = str(server[10]) + + os.system("cp scripts/%s ." % script) + + if proxy is not None and proxy != '' and proxy != 'None': + proxy_serv = proxy + else: + proxy_serv = '' + + commands = [ "chmod +x "+script +" && ./"+script +" PROXY=" + proxy_serv+ + " STAT_PORT="+stats_port+" SSH_PORT="+ssh_port+" STAT_PAGE="+stats_page+ + " STATS_USER="+stats_user+" STATS_PASS="+stats_password+" HOST="+serv+ + " USER="+ssh_user_name+" PASS="+ssh_user_password+" KEY="+ssh_key_name ] + + output, error = funct.subprocess_execute(commands[0]) + + if error: + funct.logging('localhost', error, haproxywi=1) + print('error: '+error) + else: + for l in output: + if "msg" in l or "FAILED" in l: + try: + l = l.split(':')[1] + l = l.split('"')[1] + print(l+"
") + break + except: + print(output) + break + else: + print('success: Nginx exporter was installed
') + + os.system("rm -f %s" % script) + + if form.getvalue('backup') or form.getvalue('deljob') or form.getvalue('backupupdate'): server = form.getvalue('server') rpath = form.getvalue('rpath') @@ -1012,6 +1159,10 @@ if form.getvalue('get_nginx_v'): cmd = [ "/usr/sbin/nginx -v" ] print(funct.ssh_command(serv, cmd)) + +if form.getvalue('get_exporter_v'): + print(funct.check_service(serv, form.getvalue('get_exporter_v'))) + if form.getvalue('bwlists'): list = os.path.dirname(os.getcwd())+"/"+sql.get_setting('lists_path')+"/"+form.getvalue('group')+"/"+form.getvalue('color')+"/"+form.getvalue('bwlists') diff --git a/app/scripts/ansible/roles/grafana.yml b/app/scripts/ansible/roles/grafana.yml new file mode 100644 index 00000000..0d3509c9 --- /dev/null +++ b/app/scripts/ansible/roles/grafana.yml @@ -0,0 +1,35 @@ +- hosts: localhost + become: yes + become_method: sudo + roles: + - role: cloudalchemy.prometheus + environment: + http_proxy: "{{PROXY}}" + https_proxy: "{{PROXY}}" + vars: + prometheus_targets: + node: + - targets: + - "{{ansible_hostname}}:9100" + + - role: cloudalchemy.grafana + environment: + http_proxy: "{{PROXY}}" + https_proxy: "{{PROXY}}" + vars: + grafana_security: + admin_user: admin + admin_password: admin + grafana_datasources: + - name: prometheus + type: prometheus + url: "http://{{ansible_default_ipv4.address}}:9090" + basicAuth: false + grafana_dashboards: + - dashboard_id: 2428 + revision_id: 7 + datasource: prometheus + - dashboard_id: 11879 + revision_id: 3 + datasource: prometheus + \ No newline at end of file diff --git a/app/scripts/ansible/roles/haproxy_exporter.yml b/app/scripts/ansible/roles/haproxy_exporter.yml new file mode 100644 index 00000000..d9ef0837 --- /dev/null +++ b/app/scripts/ansible/roles/haproxy_exporter.yml @@ -0,0 +1,12 @@ +- hosts: "{{ variable_host }}" + become: yes + become_method: sudo + tasks: + - name: Set SSH port + set_fact: + ansible_port: "{{SSH_PORT}}" + + roles: + - role: bdellegrazie.haproxy_exporter + vars: + haproxy_exporter_options: ['--haproxy.scrape-uri=http://{{STATS_USER}}:{{STATS_PASS}}@{{variable_host}}:{{STAT_PORT}}/{{STAT_PAGE}};csv'] diff --git a/app/scripts/ansible/roles/nginx_exporter.yml b/app/scripts/ansible/roles/nginx_exporter.yml new file mode 100644 index 00000000..f3d2d2de --- /dev/null +++ b/app/scripts/ansible/roles/nginx_exporter.yml @@ -0,0 +1,15 @@ +- hosts: "{{ variable_host }}" + become: yes + become_method: sudo + tasks: + - name: Set SSH port + set_fact: + ansible_port: "{{SSH_PORT}}" + + roles: + - role: bdellegrazie.nginx_exporter + environment: + http_proxy: "{{PROXY}}" + https_proxy: "{{PROXY}}" + vars: + nginx_exporter_options: ['-nginx.scrape-uri http://{{STATS_USER}}:{{STATS_PASS}}@{{variable_host}}:{{STAT_PORT}}/{{STAT_PAGE}}'] diff --git a/app/scripts/install_grafana.sh b/app/scripts/install_grafana.sh new file mode 100644 index 00000000..0505d7a3 --- /dev/null +++ b/app/scripts/install_grafana.sh @@ -0,0 +1,50 @@ +#!/bin/bash +for ARGUMENT in "$@" +do + KEY=$(echo $ARGUMENT | cut -f1 -d=) + VALUE=$(echo $ARGUMENT | cut -f2 -d=) + + case "$KEY" in + PROXY) PROXY=${VALUE} ;; + *) + esac +done + +if [ ! -d "/var/www/haproxy-wi/app/scripts/ansible/roles/cloudalchemy.grafana" ]; then + if [ ! -z $PROXY ];then + export https_proxy="$PROXY" + export http_proxy="$PROXY" + fi + ansible-galaxy install cloudalchemy.grafana --roles-path /var/www/haproxy-wi/app/scripts/ansible/roles/ +fi + +if [ ! -d "/var/www/haproxy-wi/app/scripts/ansible/roles/cloudalchemy.prometheus" ]; then + if [ ! -z $PROXY ];then + export https_proxy="$PROXY" + export http_proxy="$PROXY" + fi + ansible-galaxy install cloudalchemy.prometheus --roles-path /var/www/haproxy-wi/app/scripts/ansible/roles/ +fi + +export ANSIBLE_HOST_KEY_CHECKING=False +export ANSIBLE_DISPLAY_SKIPPED_HOSTS=False +export ACTION_WARNINGS=False +export LOCALHOST_WARNING=False +export COMMAND_WARNINGS=False + +PWD=`pwd` +PWD=$PWD/scripts/ansible/ + +ansible-playbook $PWD/roles/grafana.yml -e "PROXY=$PROXY" + +if [ $? -gt 0 ] +then + echo "error: Can't install Grafana and Prometheus services

" + exit 1 +fi +if ! sudo grep -Fxq " - job_name: proxy" /etc/prometheus/prometheus.yml; then + sudo echo " - job_name: proxy" | sudo tee -a /etc/prometheus/prometheus.yml > /dev/null + sudo echo " metrics_path: /metrics" | sudo tee -a /etc/prometheus/prometheus.yml > /dev/null + sudo echo " static_configs:" | sudo tee -a /etc/prometheus/prometheus.yml > /dev/null + sudo echo " - targets:" | sudo tee -a /etc/prometheus/prometheus.yml > /dev/null +fi diff --git a/app/scripts/install_haproxy_exporter.sh b/app/scripts/install_haproxy_exporter.sh new file mode 100644 index 00000000..010b11f4 --- /dev/null +++ b/app/scripts/install_haproxy_exporter.sh @@ -0,0 +1,55 @@ +#!/bin/bash +for ARGUMENT in "$@" +do + KEY=$(echo $ARGUMENT | cut -f1 -d=) + VALUE=$(echo $ARGUMENT | cut -f2 -d=) + + case "$KEY" in + PROXY) PROXY=${VALUE} ;; + HOST) HOST=${VALUE} ;; + USER) USER=${VALUE} ;; + PASS) PASS=${VALUE} ;; + KEY) KEY=${VALUE} ;; + STAT_PORT) STAT_PORT=${VALUE} ;; + STAT_PAGE) STAT_PAGE=${VALUE} ;; + STATS_USER) STATS_USER=${VALUE} ;; + STATS_PASS) STATS_PASS=${VALUE} ;; + SSH_PORT) SSH_PORT=${VALUE} ;; + *) + esac +done + +if [ ! -d "/var/www/haproxy-wi/app/scripts/ansible/roles/bdellegrazie.haproxy_exporter" ]; then + if [ ! -z $PROXY ];then + export https_proxy="$PROXY" + export http_proxy="$PROXY" + fi + ansible-galaxy install bdellegrazie.haproxy_exporter --roles-path /var/www/haproxy-wi/app/scripts/ansible/roles/ +fi + +export ANSIBLE_HOST_KEY_CHECKING=False +export ANSIBLE_DISPLAY_SKIPPED_HOSTS=False +export ACTION_WARNINGS=False +export ANSIBLE_DEPRECATION_WARNINGS=False +PWD=`pwd` +PWD=$PWD/scripts/ansible/ +echo $HOST > $PWD/$HOST + +if [[ $KEY == "" ]]; then + ansible-playbook $PWD/roles/haproxy_exporter.yml -e "ansible_user=$USER ansible_ssh_pass=$PASS variable_host=$HOST PROXY=$PROXY STAT_PAGE=$STAT_PAGE STAT_PORT=$STAT_PORT STATS_USER=$STATS_USER STATS_PASS=$STATS_PASS SSH_PORT=$SSH_PORT" -i $PWD/$HOST +else + ansible-playbook $PWD/roles/haproxy_exporter.yml --key-file $KEY -e "ansible_user=$USER variable_host=$HOST PROXY=$PROXY STAT_PAGE=$STAT_PAGE STAT_PORT=$STAT_PORT STATS_USER=$STATS_USER STATS_PASS=$STATS_PASS SSH_PORT=$SSH_PORT" -i $PWD/$HOST +fi + +if [ $? -gt 0 ] +then + echo "error: Can't install HAProxy exporter

" + exit 1 +fi + +if ! sudo grep -Fxq " - $HOST:9101" /etc/prometheus/prometheus.yml; then + sudo echo " - $HOST:9101" | sudo tee -a /etc/prometheus/prometheus.yml > /dev/null +fi + +sudo systemctl reload prometheus +rm -f $PWD/$HOST diff --git a/app/scripts/install_nginx_exporter.sh b/app/scripts/install_nginx_exporter.sh new file mode 100644 index 00000000..15efc0e9 --- /dev/null +++ b/app/scripts/install_nginx_exporter.sh @@ -0,0 +1,55 @@ +#!/bin/bash +for ARGUMENT in "$@" +do + KEY=$(echo $ARGUMENT | cut -f1 -d=) + VALUE=$(echo $ARGUMENT | cut -f2 -d=) + + case "$KEY" in + PROXY) PROXY=${VALUE} ;; + HOST) HOST=${VALUE} ;; + USER) USER=${VALUE} ;; + PASS) PASS=${VALUE} ;; + KEY) KEY=${VALUE} ;; + STAT_PORT) STAT_PORT=${VALUE} ;; + STAT_PAGE) STAT_PAGE=${VALUE} ;; + STATS_USER) STATS_USER=${VALUE} ;; + STATS_PASS) STATS_PASS=${VALUE} ;; + SSH_PORT) SSH_PORT=${VALUE} ;; + *) + esac +done + +if [ ! -d "/var/www/haproxy-wi/app/scripts/ansible/roles/bdellegrazie.nginx_exporter" ]; then + if [ ! -z $PROXY ];then + export https_proxy="$PROXY" + export http_proxy="$PROXY" + fi + ansible-galaxy install bdellegrazie.nginx_exporter --roles-path /var/www/haproxy-wi/app/scripts/ansible/roles/ +fi + +export ANSIBLE_HOST_KEY_CHECKING=False +export ANSIBLE_DISPLAY_SKIPPED_HOSTS=False +export ACTION_WARNINGS=False +export ANSIBLE_DEPRECATION_WARNINGS=False +PWD=`pwd` +PWD=$PWD/scripts/ansible/ +echo $HOST > $PWD/$HOST + +if [[ $KEY == "" ]]; then + ansible-playbook $PWD/roles/nginx_exporter.yml -e "ansible_user=$USER ansible_ssh_pass=$PASS variable_host=$HOST PROXY=$PROXY STAT_PAGE=$STAT_PAGE STAT_PORT=$STAT_PORT STATS_USER=$STATS_USER STATS_PASS=$STATS_PASS SSH_PORT=$SSH_PORT" -i $PWD/$HOST +else + ansible-playbook $PWD/roles/nginx_exporter.yml --key-file $KEY -e "ansible_user=$USER variable_host=$HOST PROXY=$PROXY STAT_PAGE=$STAT_PAGE STAT_PORT=$STAT_PORT STATS_USER=$STATS_USER STATS_PASS=$STATS_PASS SSH_PORT=$SSH_PORT" -i $PWD/$HOST +fi + +if [ $? -gt 0 ] +then + echo "error: Can't install Nginx exporter

" + exit 1 +fi + +if ! sudo grep -Fxq " - $HOST:9113" /etc/prometheus/prometheus.yml; then + sudo echo " - $HOST:9113" | sudo tee -a /etc/prometheus/prometheus.yml > /dev/null +fi + +sudo systemctl reload prometheus +rm -f $PWD/$HOST diff --git a/app/scripts/waf.sh b/app/scripts/waf.sh index 8c8a060f..4738de83 100644 --- a/app/scripts/waf.sh +++ b/app/scripts/waf.sh @@ -134,11 +134,11 @@ EOF sudo mv /tmp/modsecurity.conf $HAPROXY_PATH/waf/modsecurity.conf wget -O /tmp/unicode.mapping https://github.com/SpiderLabs/ModSecurity/raw/v2/master/unicode.mapping sudo mv /tmp/unicode.mapping $HAPROXY_PATH/waf/unicode.mapping -wget -O /tmp/owasp.tar.gz https://github.com/SpiderLabs/owasp-modsecurity-crs/archive/v3.0.2.tar.gz +wget -O /tmp/owasp.tar.gz https://github.com/SpiderLabs/owasp-modsecurity-crs/archive/2.2.9.tar.gz cd /tmp/ sudo tar xf /tmp/owasp.tar.gz -sudo mv /tmp/owasp-modsecurity-crs-3.0.2/crs-setup.conf.example $HAPROXY_PATH/waf/rules/modsecurity_crs_10_setup.conf -sudo mv /tmp/owasp-modsecurity-crs-3.0.2/*rules/* $HAPROXY_PATH/waf/rules/ +sudo mv /tmp/owasp-modsecurity-crs-2.2.9/modsecurity_crs_10_setup.conf.example $HAPROXY_PATH/waf/rules/modsecurity_crs_10_setup.conf +sudo mv /tmp/owasp-modsecurity-crs-2.2.9/*rules/* $HAPROXY_PATH/waf/rules/ sudo sed -i 's/#SecAction/SecAction/' $HAPROXY_PATH/waf/rules/modsecurity_crs_10_setup.conf sudo sed -i 's/SecRuleEngine DetectionOnly/SecRuleEngine On/' $HAPROXY_PATH/waf/modsecurity.conf sudo sed -i 's/SecAuditLogParts ABIJDEFHZ/SecAuditLogParts ABIJDEH/' $HAPROXY_PATH/waf/modsecurity.conf diff --git a/app/servers.py b/app/servers.py index 400e0615..28270134 100644 --- a/app/servers.py +++ b/app/servers.py @@ -12,6 +12,7 @@ funct.page_for_admin(level = 2) try: user, user_id, role, token, servers = funct.get_users_params() ldap_enable = sql.get_setting('ldap_enable') + grafana, stderr = funct.subprocess_execute("service grafana-server status |grep Active |awk '{print $1}'") except: pass @@ -30,5 +31,6 @@ output_from_parsed_template = template.render(title = "Servers manage", token = token, versions = funct.versions(), backups = sql.select_backups(), + grafana = ''.join(grafana), ldap_enable = ldap_enable) print(output_from_parsed_template) diff --git a/app/templates/ajax/config_show.html b/app/templates/ajax/config_show.html index 6d02bd8a..d7d565a3 100644 --- a/app/templates/ajax/config_show.html +++ b/app/templates/ajax/config_show.html @@ -2,187 +2,212 @@

Config from {{serv}}

{% if role %} - Edit - {% endif %} - {% if service != 'keepalived' and service != 'nginx' %} - Expand all - - + Edit {% endif %} + Expand all + +

-
- - {% if service == 'nginx' %} -
-
-		{%- for line in conf -%}
-			{{ line }}
-		{% endfor %}
-		
-
- {% else %} +
+
{% set i = 0 -%} {% set section_name = {} %} {% for line in conf -%} {% set i = i + loop.index0 %} {% if not role %} - {% if line.startswith('#HideBlockStart') %} - + {% continue %} + {% endif %} {% endif %} - {% if line.startswith('#HideBlockEnd') %} - {{line}}--> - {% continue %} - {% endif %} - {% endif %} - {% if line.startswith('global') %} - {{ line }} - {% if role %} - {% if service != 'keepalived' %} + {% if service == 'nginx' %} + {%- if "server {" in line -%} + {% if i > 1 %} +
+ {% endif %} + {{ line }} +
+ {% continue %} + {% endif %} + {% if "listen " in line or "location" in line or "server_name" in line or "}" in line %} + {% if "#" not in line %} + + {{ i }} + + +  {{ line }} +
+ {% continue %} + {% endif %} + {% endif %} + {% if "#" in line %} + + {{ i }} + + +  {{ line }} +
+ {% continue %} + {% endif %} + {% if line|length > 1 %} + + {{ i }} +   {{ line }} +
+ {% endif %} + {% else %} + {% if line.startswith('global') %} + {{ line }} + {% if role %} + {% if service != 'keepalived' %} + + Edit + + {% endif %} + {% endif %} +
+ {% continue %} + {% endif %} + {% if line.startswith('defaults') %} +
{{ line }} + {% if role %} + + Edit + + {% endif %} +
+ {% continue %} + {% endif %} + {%- if line.startswith('listen') -%} +
{{- line -}} + {% if role %} Edit {% endif %} - {% endif %} -
- {% continue %} - {% endif %} - {% if line.startswith('defaults') %} -
{{ line }} - {% if role %} + {%- set backend = line.split(' ') -%} - Edit + Stats - {% endif %} -
- {% continue %} - {% endif %} - {%- if line.startswith('listen') -%} -
{{- line -}} - {% if role %} - - Edit - - {% endif %} - {%- set backend = line.split(' ') -%} - - Stats - - {%- set backend = backend|join('_') -%} - {%- do section_name.update({i: backend}) -%} - -
+ {%- set backend = backend|join('_') -%} + {%- do section_name.update({i: backend}) -%} + +
+ {% continue %} + {%- endif -%} + {%- if line.startswith('frontend') -%} +
{{ line }} + {% if role %} + + Edit + + {% endif %} + {% set backend = line.split(' ') %} + + Stats + + {% set backend = backend|join('_') %} + {% do section_name.update({i: backend}) %} + +
+ {% continue %} + {%- endif -%} + {% if line.startswith('backend') %} +
{{ line }} + {% if role %} + + Edit + + {% endif %} + {% set backend = line.split(' ') %} + + Stats + +
{% continue %} - {%- endif -%} - {%- if line.startswith('frontend') -%} -
{{ line }} - {% if role %} - - Edit - - {% endif %} - {% set backend = line.split(' ') %} - - Stats - - {% set backend = backend|join('_') %} - {% do section_name.update({i: backend}) %} - -
- {% continue %} - {%- endif -%} - {% if line.startswith('backend') %} -
{{ line }} - {% if role %} - - Edit - - {% endif %} - {% set backend = line.split(' ') %} - - Stats - + {% endif %} + {% if line.startswith('cache') %} +
{{ line }} + {% if role %} + + Edit + + {% endif %}
- {% continue %} - {% endif %} - {% if line.startswith('cache') %} -
{{ line }} - {% if role %} - - Edit - - {% endif %} -
- {% continue %} - {% endif %} - {% if line.startswith('peers') %} -
{{ line }} - {% if role %} - - Edit - - {% endif %} -
- {% continue %} - {% endif %} - {% if line.startswith('resolvers') %} -
{{ line }} - {% if role %} - - Edit - - {% endif %} -
- {% continue %} - {% endif %} - {% if line.startswith('userlist') %} -
{{ line }} - {% if role %} - - Edit - - {% endif %} -
- {% continue %} - {% endif %} - {% if "acl" in line or "option" in line or "server" in line %} - {% if "timeout" not in line and "default-server" not in line and "#use_backend" not in line and "#" not in line%} - + {% continue %} + {% endif %} + {% if line.startswith('peers') %} +
{{ line }} + {% if role %} + + Edit + + {% endif %} +
+ {% continue %} + {% endif %} + {% if line.startswith('resolvers') %} +
{{ line }} + {% if role %} + + Edit + + {% endif %} +
+ {% continue %} + {% endif %} + {% if line.startswith('userlist') %} +
{{ line }} + {% if role %} + + Edit + + {% endif %} +
+ {% continue %} + {% endif %} + {% if "acl" in line or "option" in line or "server" in line %} + {% if "timeout" not in line and "default-server" not in line and "#use_backend" not in line and "#" not in line%} {{ i }} - {{ line }} -
- {% continue %} + + {{ line }} +
+ {% continue %} + {% endif %} {% endif %} - {% endif %} - {% if line.startswith("#") %} - + {% if line.startswith("#") %} {{ i }} + {{ line }} -
- {% continue %} - {% endif %} - {% if line|length > 1 %} - - {{ i }} - {{ line }} -
- {% endif %} - {%- if "bind" in line -%} - {%- set bind = line.split(':') -%} - +

+ {% continue %} + {% endif %} + {% if line|length > 1 %} + + {{ i }} + {{ line }} +
+ {% endif %} + {%- if "bind" in line -%} + {%- set bind = line.split(':') -%} + + {%- endif -%} {%- endif -%} {%- endfor -%}
- {% endif %} {% if configver %}
diff --git a/app/templates/config.html b/app/templates/config.html index 9072943a..aa2e2005 100644 --- a/app/templates/config.html +++ b/app/templates/config.html @@ -17,13 +17,10 @@ {% endif %} {% endfor %} - {% if service != 'keepalived' and service != 'nginx'%} - Open - Map - {% endif %} + Open Stat - {% if role <= 2 and service == 'nginx'%} - + {% if service != 'keepalived' and service != 'nginx'%} + Map {% endif %} {% if service != 'keepalived' %} Compare @@ -85,7 +82,7 @@ if (cur_url[1].split('&')[1] == 'showCompare' || cur_url[1].split('&')[2] == 'showCompare') { showCompareConfigs(); } - if (cur_url[1].split('&')[1] == 'showConfig') { + if (cur_url[1].split('&')[2] == 'showConfig') { showConfig(); } $('textarea').linenumbers({col_width: '25px'}); diff --git a/app/templates/hapservers.html b/app/templates/hapservers.html index 91b107e3..c4333b07 100644 --- a/app/templates/hapservers.html +++ b/app/templates/hapservers.html @@ -152,11 +152,7 @@ {% endif %} @@ -469,6 +562,8 @@ $('#hapver').selectmenu('enable'); $('#haproxyaddserv').selectmenu('enable'); $('#nginxaddserv').selectmenu('enable'); + $('#haproxy_exp_addserv').selectmenu('enable'); + $('#nginx_exp_addserv').selectmenu('enable'); $('#syn_flood').checkboxradio('enable'); $('#nginx_syn_flood').checkboxradio('enable'); }, 500 );