Pavel Loginov 2020-03-27 22:16:04 +01:00
parent 59d5ea9913
commit 6eb68b1983
15 changed files with 665 additions and 178 deletions

View File

@ -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()

View File

@ -1,7 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import cgi
import os
import sys
import funct

View File

@ -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('<center><h3>You %s %s on HAproxy %s. <a href="viewsttats.py?serv=%s" title="View stat" target="_blank">Look it</a> or <a href="edit.py" title="Edit">Edit something else</a></h3><br />' % (enable, backend, serv, serv))
print('<center><h3>You %s %s on HAproxy %s. <a href="viewsttats.py?serv=%s" title="View stat" target="_blank">Look it</a> or <a href="runtimeapi.py" title="RutimeAPI">Edit something else</a></h3><br />' % (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<br>')
else:
for l in output:
if "FAILED" in l:
try:
l = l.split(':')[1]
l = l.split('"')[1]
print(l+"<br>")
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<br>')
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+"<br>")
break
except:
print(output)
break
else:
print('success: HAProxy exporter was installed<br>')
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+"<br>")
break
except:
print(output)
break
else:
print('success: Nginx exporter was installed<br>')
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')

View File

@ -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

View File

@ -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']

View File

@ -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}}']

View File

@ -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 <br /><br />"
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

View File

@ -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 <br /><br />"
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

View File

@ -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 <br /><br />"
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

View File

@ -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

View File

@ -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)

View File

@ -2,187 +2,212 @@
<h4>Config from {{serv}}</h4>
<p class="accordion-expand-holder">
{% if role %}
<a class="ui-button ui-widget ui-corner-all" title="Edit this run config" href="config.py?serv={{serv}}&open=open">Edit</a>
{% endif %}
{% if service != 'keepalived' and service != 'nginx' %}
<a class="accordion-expand-all ui-button ui-widget ui-corner-all" href="#">Expand all</a>
<button id="raw">Raw</button>
<button id="according" style="display: none;">According</button>
<a class="ui-button ui-widget ui-corner-all" title="Edit this run config" href="config.py?service={{service}}&serv={{serv}}&open=open">Edit</a>
{% endif %}
<a class="accordion-expand-all ui-button ui-widget ui-corner-all" href="#">Expand all</a>
<button id="raw">Raw</button>
<button id="according" style="display: none;">According</button>
</p>
</center>
{% if service == 'nginx' %}
<div style="margin-left: 20%; border: 1px solid #ddd; padding-left: 50px; width: 60%;">
<pre>
{%- for line in conf -%}
{{ line }}
{% endfor %}
</pre>
</div>
{% else %}
</center>
<div style="margin-left: 16%" class="configShow">
{% set i = 0 -%}
{% set section_name = {} %}
{% for line in conf -%}
{% set i = i + loop.index0 %}
{% if not role %}
{% if line.startswith('#HideBlockStart') %}
<!--{{line}}
{% continue %}
{% if line.startswith('#HideBlockStart') %}
<!--{{line}}
{% continue %}
{% endif %}
{% if line.startswith('#HideBlockEnd') %}
{{line}}-->
{% continue %}
{% endif %}
{% endif %}
{% if line.startswith('#HideBlockEnd') %}
{{line}}-->
{% continue %}
{% endif %}
{% endif %}
{% if line.startswith('global') %}
<span class="param">{{ line }}
{% if role %}
{% if service != 'keepalived' %}
{% if service == 'nginx' %}
{%- if "server {" in line -%}
{% if i > 1 %}
</div>
{% endif %}
<span class="param">{{ line }}
</span><div>
{% continue %}
{% endif %}
{% if "listen " in line or "location" in line or "server_name" in line or "}" in line %}
{% if "#" not in line %}
<span class="numRow">
{{ i }}
</span>
<span class="paramInSec">
&emsp;{{ line }}
</span><br />
{% continue %}
{% endif %}
{% endif %}
{% if "#" in line %}
<span class="numRow">
{{ i }}
</span>
<span class="comment">
&emsp;{{ line }}
</span><br />
{% continue %}
{% endif %}
{% if line|length > 1 %}
<span class="configLine">
<span class="numRow">{{ i }}</span>
&emsp;&emsp;{{ line }}
</span><br />
{% endif %}
{% else %}
{% if line.startswith('global') %}
<span class="param">{{ line }}
{% if role %}
{% if service != 'keepalived' %}
<span class="accordion-link">
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit</a>
</span>
{% endif %}
{% endif %}
</span><div>
{% continue %}
{% endif %}
{% if line.startswith('defaults') %}
</div><span class="param">{{ line }}
{% if role %}
<span class="accordion-link">
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit</a>
</span>
{% endif %}
</span><div>
{% continue %}
{% endif %}
{%- if line.startswith('listen') -%}
</div><span class="param">{{- line -}}
{% if role %}
<span class="accordion-link">
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit</a>
</span>
{% endif %}
{% endif %}
</span><div>
{% continue %}
{% endif %}
{% if line.startswith('defaults') %}
</div><span class="param">{{ line }}
{% if role %}
{%- set backend = line.split(' ') -%}
<span class="accordion-link">
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit</a>
<a href="/app/viewsttats.py?serv={{-serv-}}#{{- backend[1]-}}" target="_blank">Stats</a>
</span>
{% endif %}
</span><div>
{% continue %}
{% endif %}
{%- if line.startswith('listen') -%}
</div><span class="param">{{- line -}}
{% if role %}
<span class="accordion-link">
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit</a>
</span>
{% endif %}
{%- set backend = line.split(' ') -%}
<span class="accordion-link">
<a href="/app/viewsttats.py?serv={{-serv-}}#{{- backend[1]-}}" target="_blank">Stats</a>
</span>
{%- set backend = backend|join('_') -%}
{%- do section_name.update({i: backend}) -%}
<span id="{{-section_name[i]|replace('\n', '')-}}" class="accordion-link"></span>
</span><div>
{%- set backend = backend|join('_') -%}
{%- do section_name.update({i: backend}) -%}
<span id="{{-section_name[i]|replace('\n', '')-}}" class="accordion-link"></span>
</span><div>
{% continue %}
{%- endif -%}
{%- if line.startswith('frontend') -%}
</div><span class="param">{{ line }}
{% if role %}
<span class="accordion-link">
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit</a>
</span>
{% endif %}
{% set backend = line.split(' ') %}
<span class="accordion-link">
<a href="/app/viewsttats.py?serv={{serv}}#{{ backend[1]}}" target="_blank">Stats</a>
</span>
{% set backend = backend|join('_') %}
{% do section_name.update({i: backend}) %}
<span id="{{section_name[i]|replace('\n', '')}}" class="accordion-link"></span>
</span><div>
{% continue %}
{%- endif -%}
{% if line.startswith('backend') %}
</div><span class="param">{{ line }}
{% if role %}
<span class="accordion-link">
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit</a>
</span>
{% endif %}
{% set backend = line.split(' ') %}
<span class="accordion-link">
<a href="/app/viewsttats.py?serv={{serv}}#{{ backend[1]}}" target="_blank">Stats</a>
</span>
</span><div>
{% continue %}
{%- endif -%}
{%- if line.startswith('frontend') -%}
</div><span class="param">{{ line }}
{% if role %}
<span class="accordion-link">
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit</a>
</span>
{% endif %}
{% set backend = line.split(' ') %}
<span class="accordion-link">
<a href="/app/viewsttats.py?serv={{serv}}#{{ backend[1]}}" target="_blank">Stats</a>
</span>
{% set backend = backend|join('_') %}
{% do section_name.update({i: backend}) %}
<span id="{{section_name[i]|replace('\n', '')}}" class="accordion-link"></span>
</span><div>
{% continue %}
{%- endif -%}
{% if line.startswith('backend') %}
</div><span class="param">{{ line }}
{% if role %}
<span class="accordion-link">
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit</a>
</span>
{% endif %}
{% set backend = line.split(' ') %}
<span class="accordion-link">
<a href="/app/viewsttats.py?serv={{serv}}#{{ backend[1]}}" target="_blank">Stats</a>
</span>
{% endif %}
{% if line.startswith('cache') %}
</div><span class="param">{{ line }}
{% if role %}
<span class="accordion-link">
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit</a>
</span>
{% endif %}
</span><div>
{% continue %}
{% endif %}
{% if line.startswith('cache') %}
</div><span class="param">{{ line }}
{% if role %}
<span class="accordion-link">
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit</a>
</span>
{% endif %}
</span><div>
{% continue %}
{% endif %}
{% if line.startswith('peers') %}
</div><span class="param">{{ line }}
{% if role %}
<span class="accordion-link">
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit</a>
</span>
{% endif %}
</span><div>
{% continue %}
{% endif %}
{% if line.startswith('resolvers') %}
</div><span class="param">{{ line }}
{% if role %}
<span class="accordion-link">
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit</a>
</span>
{% endif %}
</span><div>
{% continue %}
{% endif %}
{% if line.startswith('userlist') %}
</div><span class="param">{{ line }}
{% if role %}
<span class="accordion-link">
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit</a>
</span>
{% endif %}
</span><div>
{% 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%}
<span class="paramInSec">
{% continue %}
{% endif %}
{% if line.startswith('peers') %}
</div><span class="param">{{ line }}
{% if role %}
<span class="accordion-link">
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit</a>
</span>
{% endif %}
</span><div>
{% continue %}
{% endif %}
{% if line.startswith('resolvers') %}
</div><span class="param">{{ line }}
{% if role %}
<span class="accordion-link">
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit</a>
</span>
{% endif %}
</span><div>
{% continue %}
{% endif %}
{% if line.startswith('userlist') %}
</div><span class="param">{{ line }}
{% if role %}
<span class="accordion-link">
<a href="/app/sections.py?serv={{serv}}&section={{ line }}">Edit</a>
</span>
{% endif %}
</span><div>
{% 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%}
<span class="numRow">
{{ i }}
</span>
{{ line }}
</span><br />
{% continue %}
<span class="paramInSec">
{{ line }}
</span><br />
{% continue %}
{% endif %}
{% endif %}
{% endif %}
{% if line.startswith("#") %}
<span class="comment">
{% if line.startswith("#") %}
<span class="numRow">
{{ i }}
</span>
<span class="comment">
{{ line }}
</span><br />
{% continue %}
{% endif %}
{% if line|length > 1 %}
<span class="configLine">
<span class="numRow">{{ i }}</span>
{{ line }}
</span><br />
{% endif %}
{%- if "bind" in line -%}
{%- set bind = line.split(':') -%}
<script>
{% set k = i - 1 %}
$('#{{-section_name[k]|replace("\n", "")-}}').html('<a href="http://{{-serv-}}:{{-bind[1]|replace("\n", "")-}}" title="Open {{serv-}}:{{-bind[1]|replace("\n", "")-}}" target="_blank">Open</a>')
</script>
</span><br />
{% continue %}
{% endif %}
{% if line|length > 1 %}
<span class="configLine">
<span class="numRow">{{ i }}</span>
{{ line }}
</span><br />
{% endif %}
{%- if "bind" in line -%}
{%- set bind = line.split(':') -%}
<script>
{% set k = i - 1 %}
$('#{{-section_name[k]|replace("\n", "")-}}').html('<a href="http://{{-serv-}}:{{-bind[1]|replace("\n", "")-}}" title="Open {{serv-}}:{{-bind[1]|replace("\n", "")-}}" target="_blank">Open</a>')
</script>
{%- endif -%}
{%- endif -%}
{%- endfor -%}
</div>
</div>
{% endif %}
{% if configver %}
<br>
<center>

View File

@ -17,13 +17,10 @@
{% endif %}
{% endfor %}
</select>
{% if service != 'keepalived' and service != 'nginx'%}
<a class="ui-button ui-widget ui-corner-all" title="Show running config" onclick="showConfig()">Open</a>
<a class="ui-button ui-widget ui-corner-all" title="Show map" onclick="showMap()">Map</a>
{% endif %}
<a class="ui-button ui-widget ui-corner-all" title="Show running config" onclick="showConfig()">Open</a>
<a class="ui-button ui-widget ui-corner-all" title="View stat" onclick="openStats()">Stat</a>
{% if role <= 2 and service == 'nginx'%}
<button type="submit" value="open" name="open" class="btn btn-default" title="Edit running config">Edit</button>
{% if service != 'keepalived' and service != 'nginx'%}
<a class="ui-button ui-widget ui-corner-all" title="Show map" onclick="showMap()">Map</a>
{% endif %}
{% if service != 'keepalived' %}
<a class="ui-button ui-widget ui-corner-all" title="Compare configs" onclick="showCompareConfigs()">Compare</a>
@ -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'});

View File

@ -152,11 +152,7 @@
</div>
{% endif %}
<div class="server-act-links">
{% if service != 'nginx' %}
<a href="/app/config.py?serv={{s.2}}&showConfig" class="ui-button ui-widget ui-corner-all" title="Open running config">Open</a>
{% else %}
<a class="ui-button ui-widget ui-corner-all" title="Edit this run config" href="config.py?service={{service}}&serv={{s.2}}&open=open">Edit</a>
{% endif %}
<a href="/app/config.py?service={{service}}&serv={{s.2}}&showConfig" class="ui-button ui-widget ui-corner-all" title="Open running config">Open</a>
<a href="/app/config.py?service={{service}}&serv={{s.2}}&showCompare" class="ui-button ui-widget ui-corner-all" title="Compare configs">Compare</a>
{% if service != 'nginx' %}
<a href="/app/config.py?serv={{s.2}}&showMap" class="ui-button ui-widget ui-corner-all" title="Show map">Map</a>

View File

@ -277,8 +277,8 @@
<caption><h3>Install HAProxy</h3></caption>
<tr class="overviewHead">
<td class="padding10 first-collumn">Current version</td>
<td class="padding10 first-collumn" style="width: 25%;">Available Versions</td>
<td class="padding10 first-collumn" style="width: 35%;">Server</td>
<td class="padding10 first-collumn" style="width: 30%;">Available Versions</td>
<td class="padding10 first-collumn" style="width: 30%;">Server</td>
<td>SYN flood protect</td>
<td></td>
</tr>
@ -310,8 +310,8 @@
<caption><h3>Install Nginx</h3></caption>
<tr class="overviewHead">
<td class="padding10 first-collumn">Current version</td>
<td class="padding10 first-collumn" style="width: 25%;">Available Versions</td>
<td class="padding10 first-collumn" style="width: 35%;">Server</td>
<td class="padding10 first-collumn" style="width: 30%;">Available Versions</td>
<td class="padding10 first-collumn" style="width: 30%;">Server</td>
<td>SYN flood protect</td>
<td></td>
</tr>
@ -337,6 +337,99 @@
</td>
</tr>
</table>
<table>
<caption><h3>Install Grafana and Prometheus servers</h3></caption>
<tr class="overviewHead">
<td class="padding10 first-collumn">Current instalation</td>
<td class="padding10 first-collumn" style="width: 30%;">Available Versions</td>
<td class="padding10 first-collumn" style="width: 30%;">Note</td>
<td></td>
<td></td>
</tr>
<tr>
<td id="cur_grafana_ver" class="padding10 first-collumn">
{% if grafana == "Active:" %}
Grafana and Prometheus servers have already installed
{% else %}
There are no Grafana and Prometheus servers
{% endif %}
</td>
<td class="padding10 first-collumn" style="width: 20%;">
HAProxy-WI will try to install the latest Grafana and Prometheus server versions
</td>
<td class="padding10 first-collumn">
Before Install any Exporters install Grafana and Prometheus servers first
</td>
<td>
</td>
<td>
{% if grafana != "Active:" %}
<a class="ui-button ui-widget ui-corner-all" id="grafna_install" title="Install Grafana and Prometheus server">Install</a>
{% endif %}
</td>
</tr>
</table>
<table>
<caption><h3>Install HAProxy Exporter</h3></caption>
<tr class="overviewHead">
<td class="padding10 first-collumn">Current instalation</td>
<td class="padding10 first-collumn" style="width: 30%;">Available Versions</td>
<td class="padding10 first-collumn" style="width: 30%;">Server</td>
<td></td>
<td></td>
</tr>
<tr>
<td id="cur_haproxy_exp_ver" class="padding10 first-collumn">
</td>
<td class="padding10 first-collumn" style="width: 20%;">
HAProxy-WI will try to install the latest HAProxy Exporter version
</td>
<td class="padding10 first-collumn">
<select autofocus required name="haproxy_exp_addserv" id="haproxy_exp_addserv">
<option disabled selected>Choose server</option>
{% for select in servers %}
<option value="{{ select.2 }}">{{ select.1 }}</option>
{% endfor %}
</select>
</td>
<td>
</td>
<td>
<a class="ui-button ui-widget ui-corner-all" id="haproxy_exp_install" title="Install HAProxy Exporter">Install</a>
</td>
</tr>
</table>
<table>
<caption><h3>Install Nginx Exporter</h3></caption>
<tr class="overviewHead">
<td class="padding10 first-collumn">Current instalation</td>
<td class="padding10 first-collumn" style="width: 30%;">Available Versions</td>
<td class="padding10 first-collumn" style="width: 30%;">Server</td>
<td></td>
<td></td>
</tr>
<tr>
<td id="cur_nginx_exp_ver" class="padding10 first-collumn">
</td>
<td class="padding10 first-collumn" style="width: 20%;">
HAProxy-WI will try to install the latest Nginx Exporter version
</td>
<td class="padding10 first-collumn">
<select autofocus required name="nginx_exp_addserv" id="nginx_exp_addserv">
<option disabled selected>Choose server</option>
{% for select in servers %}
<option value="{{ select.2 }}">{{ select.1 }}</option>
{% endfor %}
</select>
</td>
<td>
</td>
<td>
<a class="ui-button ui-widget ui-corner-all" id="nginx_exp_install" title="Install Nginx Exporter">Install</a>
</td>
</tr>
</table>
<div id="ajax"></div>
</div>
@ -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 );