Pavel Loginov 2021-08-06 10:46:05 +06:00
parent d1e931d8d1
commit f0da84e4ba
3 changed files with 58 additions and 48 deletions

View File

@ -6,28 +6,31 @@ from db_model import *
def default_values(): def default_values():
data_source = [ data_source = [
{'param': 'time_zone', 'value': 'UTC', 'section': 'main', 'desc': 'Time Zone', 'group': '1'}, {'param': 'time_zone', 'value': 'UTC', 'section': 'main', 'desc': 'Time Zone', 'group': '1'},
{'param': 'proxy', 'value': '', 'section': 'main', 'desc': 'Proxy server. Use proto://ip:port', 'group': '1'}, {'param': 'proxy', 'value': '', 'section': 'main', 'desc': 'IP address and port of the proxy server. Use proto://ip:port', 'group': '1'},
{'param': 'session_ttl', 'value': '5', 'section': 'main', 'desc': 'Time to live users sessions. In days', {'param': 'session_ttl', 'value': '5', 'section': 'main', 'desc': 'TTL for a user session (in days)',
'group': '1'}, 'group': '1'},
{'param': 'token_ttl', 'value': '5', 'section': 'main', 'desc': 'Time to live users tokens. In days', {'param': 'token_ttl', 'value': '5', 'section': 'main', 'desc': 'TTL for a user token (in days)',
'group': '1'}, 'group': '1'},
{'param': 'tmp_config_path', 'value': '/tmp/', 'section': 'main', {'param': 'tmp_config_path', 'value': '/tmp/', 'section': 'main',
'desc': 'Temp store configs, for check. Path must exist', 'group': '1'}, 'desc': 'Path to the directory with SSL certificates. An existing path should be specified as the value of this parameter. The directory must be owned by the user specified in SSH settings.',
'group': '1'},
{'param': 'cert_path', 'value': '/etc/ssl/certs/', 'section': 'main', {'param': 'cert_path', 'value': '/etc/ssl/certs/', 'section': 'main',
'desc': 'Path to SSL dir. Folder owner must be a user which set in the SSH settings. Path must exist', 'desc': 'Path to SSL dir. Folder owner must be a user which set in the SSH settings. Path must exist',
'group': '1'}, 'group': '1'},
{'param': 'ssl_local_path', 'value': 'certs', 'section': 'main', {'param': 'ssl_local_path', 'value': 'certs', 'section': 'main',
'desc': 'Path to dir for local save SSL certs. This is a relative path, begins with $HOME_ROXY-WI/app/', 'desc': 'Path to the directory with the saved local SSL certificates. The value of this parameter is specified as a relative path beginning with $HOME_ROXY_WI/app/',
'group': '1'}, 'group': '1'},
{'param': 'lists_path', 'value': 'lists', 'section': 'main', {'param': 'lists_path', 'value': 'lists', 'section': 'main',
'desc': 'Path to black/white lists. This is a relative path, begins with $HOME_ROXY-WI', 'desc': 'Path to the black and the wild list. The value of this paramer should be specified as a relative path beginning with $HOME_ROXY-WI',
'group': '1'}, 'group': '1'},
{'param': 'local_path_logs', 'value': '/var/log/haproxy.log', 'section': 'logs', {'param': 'local_path_logs', 'value': '/var/log/haproxy.log', 'section': 'logs',
'desc': 'Logs save locally, enabled by default', 'group': '1'}, 'desc': 'The default local path for saving logs', 'group': '1'},
{'param': 'syslog_server_enable', 'value': '0', 'section': 'logs', {'param': 'syslog_server_enable', 'value': '0', 'section': 'logs',
'desc': 'If exist syslog server for HAProxy logs, enable this option', 'group': '1'}, 'desc': 'Use the syslog server for HAProxy logs; (0 - no, 1 - yes)', 'group': '1'},
{'param': 'syslog_server', 'value': '', 'section': 'logs', 'desc': 'IP address of the syslog_server',
'group': '1'},
{'param': 'log_time_storage', 'value': '14', 'section': 'logs', {'param': 'log_time_storage', 'value': '14', 'section': 'logs',
'desc': 'Storage time for user activity logs, in days', 'group': '1'}, 'desc': 'Retention period for user activity logs (in days)', 'group': '1'},
{'param': 'stats_user', 'value': 'admin', 'section': 'haproxy', 'desc': 'Username for Stats web page HAProxy', {'param': 'stats_user', 'value': 'admin', 'section': 'haproxy', 'desc': 'Username for Stats web page HAProxy',
'group': '1'}, 'group': '1'},
{'param': 'stats_password', 'value': 'password', 'section': 'haproxy', {'param': 'stats_password', 'value': 'password', 'section': 'haproxy',
@ -46,11 +49,11 @@ def default_values():
'desc': 'Path to HAProxy state file', 'group': '1'}, 'desc': 'Path to HAProxy state file', 'group': '1'},
{'param': 'haproxy_sock_port', 'value': '1999', 'section': 'haproxy', 'desc': 'HAProxy sock port', {'param': 'haproxy_sock_port', 'value': '1999', 'section': 'haproxy', 'desc': 'HAProxy sock port',
'group': '1'}, 'group': '1'},
{'param': 'apache_log_path', 'value': '/var/log/httpd/', 'section': 'logs', 'desc': 'Path to Apache logs folder', {'param': 'apache_log_path', 'value': '/var/log/httpd/', 'section': 'logs', 'desc': 'Path to Apache logs',
'group': '1'}, 'group': '1'},
{'param': 'nginx_path_error_logs', 'value': '/var/log/nginx/error.log', 'section': 'nginx', {'param': 'nginx_path_error_logs', 'value': '/var/log/nginx/error.log', 'section': 'nginx',
'desc': 'Nginx error log', 'group': '1'}, 'desc': 'Nginx error log', 'group': '1'},
{'param': 'nginx_stats_user', 'value': 'admin', 'section': 'nginx', 'desc': 'Username for Stats web page Nginx', {'param': 'nginx_stats_user', 'value': 'admin', 'section': 'nginx', 'desc': 'Username for accessing Nginx stats page',
'group': '1'}, 'group': '1'},
{'param': 'nginx_stats_password', 'value': 'password', 'section': 'nginx', {'param': 'nginx_stats_password', 'value': 'password', 'section': 'nginx',
'desc': 'Password for Stats web page Ngin', 'group': '1'}, 'desc': 'Password for Stats web page Ngin', 'group': '1'},
@ -62,25 +65,25 @@ def default_values():
'group': '1'}, 'group': '1'},
{'param': 'nginx_config_path', 'value': '/etc/nginx/conf.d/default.conf', 'section': 'nginx', {'param': 'nginx_config_path', 'value': '/etc/nginx/conf.d/default.conf', 'section': 'nginx',
'desc': 'Path to Nginx config', 'group': '1'}, 'desc': 'Path to Nginx config', 'group': '1'},
{'param': 'ldap_enable', 'value': '0', 'section': 'ldap', 'desc': 'If 1 ldap enabled', 'group': '1'}, {'param': 'ldap_enable', 'value': '0', 'section': 'ldap', 'desc': 'Enable LDAP (1 - yes, 0 - no)',
{'param': 'ldap_server', 'value': '', 'section': 'ldap', 'desc': 'IP address ldap server', 'group': '1'}, 'group': '1'},
{'param': 'ldap_port', 'value': '389', 'section': 'ldap', 'desc': 'Default port: 389 or 636', 'group': '1'}, {'param': 'ldap_server', 'value': '', 'section': 'ldap', 'desc': 'IP address of the LDAP server', 'group': '1'},
{'param': 'ldap_port', 'value': '389', 'section': 'ldap', 'desc': 'LDAP port (port 389 or 636 is used by default)',
'group': '1'},
{'param': 'ldap_user', 'value': '', 'section': 'ldap', {'param': 'ldap_user', 'value': '', 'section': 'ldap',
'desc': 'Login to connect to LDAP server. Format: user@domain.com', 'group': '1'}, 'desc': 'Loging for connecting to LDAP server. Format: user@domain.com', 'group': '1'},
{'param': 'ldap_password', 'value': '', 'section': 'ldap', 'desc': 'Password to connect to LDAP server', {'param': 'ldap_password', 'value': '', 'section': 'ldap', 'desc': 'Password to connect to LDAP server',
'group': '1'}, 'group': '1'},
{'param': 'ldap_base', 'value': '', 'section': 'ldap', 'desc': 'Base domain. Example: dc=domain, dc=com', {'param': 'ldap_base', 'value': '', 'section': 'ldap', 'desc': 'Base domain. Example: dc=domain, dc=com',
'group': '1'}, 'group': '1'},
{'param': 'ldap_domain', 'value': '', 'section': 'ldap', {'param': 'ldap_domain', 'value': '', 'section': 'ldap', 'desc': 'LDAP domain for the login', 'group': '1'},
'desc': 'Domain for login, like user@domain.com, without user@', 'group': '1'}, {'param': 'ldap_class_search', 'value': 'user', 'section': 'ldap', 'desc': 'Class for searching the user',
{'param': 'ldap_class_search', 'value': 'user', 'section': 'ldap', 'desc': 'Class to search user',
'group': '1'}, 'group': '1'},
{'param': 'ldap_user_attribute', 'value': 'sAMAccountName', 'section': 'ldap', {'param': 'ldap_user_attribute', 'value': 'sAMAccountName', 'section': 'ldap',
'desc': 'User attribute for searching', 'group': '1'}, 'desc': 'User attribute for search', 'group': '1'},
{'param': 'ldap_search_field', 'value': 'mail', 'section': 'ldap', 'desc': 'Field where an user e-mail saved', {'param': 'ldap_search_field', 'value': 'mail', 'section': 'ldap',
'group': '1'}, 'desc': 'The field for saving the user\'s e-mail address', 'group': '1'},
{'param': 'ldap_type', 'value': '0', 'section': 'ldap', {'param': 'ldap_type', 'value': '0', 'section': 'ldap', 'desc': 'Use LDAP (0) or LDAPS (1)', 'group': '1'},
'desc': 'If 0 then will be used LDAP, if 1 then will be used LDAPS', 'group': '1'},
{'param': 'haproxy_enterprise', 'value': '0', 'section': 'haproxy', {'param': 'haproxy_enterprise', 'value': '0', 'section': 'haproxy',
'desc': 'Use this option if your HAProxy is enterprise. It changes service name for rebooting/reloading', 'desc': 'Use this option if your HAProxy is enterprise. It changes service name for rebooting/reloading',
'group': '1'}, 'group': '1'},
@ -614,12 +617,12 @@ def update_db_v_4_5_8_2(**kwargs):
def update_db_v_4_5_9(**kwargs): def update_db_v_4_5_9(**kwargs):
data_source = [ data_source = [
{'param': 'smon_check_interval', 'value': '1', 'section': 'monitoring', 'desc': 'SMON check interval, in minutes', {'param': 'smon_check_interval', 'value': '1', 'section': 'monitoring', 'desc': 'Check interval for SMON (in minutes)',
'group': '1'}, 'group': '1'},
{'param': 'checker_check_interval', 'value': '1', 'section': 'monitoring', {'param': 'checker_check_interval', 'value': '1', 'section': 'monitoring',
'desc': 'Checker check interval, in minutes', 'group': '1'}, 'desc': 'Check interval for Checker (in minutes)', 'group': '1'},
{'param': 'port_scan_interval', 'value': '5', 'section': 'monitoring', {'param': 'port_scan_interval', 'value': '5', 'section': 'monitoring',
'desc': 'Port scanner check interval, in minutes', 'group': '1'}, 'desc': 'Check interval for Port scanner (in minutes)', 'group': '1'},
] ]
try: try:

View File

@ -110,21 +110,24 @@ def add_setting_for_new_group(group_id):
group_id = str(group_id) group_id = str(group_id)
data_source = [ data_source = [
{'param': 'time_zone', 'value': 'UTC', 'section': 'main', 'desc': 'Time Zone', 'group': group_id}, {'param': 'time_zone', 'value': 'UTC', 'section': 'main', 'desc': 'Time Zone', 'group': group_id},
{'param': 'proxy', 'value': '', 'section': 'main', 'desc': 'Proxy server. Use proto://ip:port', {'param': 'proxy', 'value': '', 'section': 'main', 'desc': 'IP address and port of the proxy server . Use proto://ip:port',
'group': group_id}, 'group': group_id},
{'param': 'session_ttl', 'value': '5', 'section': 'main', 'desc': 'Time to live users sessions. In days', {'param': 'session_ttl', 'value': '5', 'section': 'main', 'desc': 'TTL for a user session (in days)',
'group': group_id}, 'group': group_id},
{'param': 'token_ttl', 'value': '5', 'section': 'main', 'desc': 'Time to live users tokens. In days', {'param': 'token_ttl', 'value': '5', 'section': 'main', 'desc': 'TTL for a user token (in days)',
'group': group_id}, 'group': group_id},
{'param': 'tmp_config_path', 'value': '/tmp/', 'section': 'main', {'param': 'tmp_config_path', 'value': '/tmp/', 'section': 'main',
'desc': 'Temp store configs, for check. Path must exist', 'group': group_id}, 'desc': 'Path to the directory with SSL certificates. An existing path should be specified as the value of this parameter. The directory must be owned by the user specified in SSH settings.',
'group': group_id},
{'param': 'cert_path', 'value': '/etc/ssl/certs/', 'section': 'main', {'param': 'cert_path', 'value': '/etc/ssl/certs/', 'section': 'main',
'desc': 'Path to SSL dir. Folder owner must be a user which set in the SSH settings. Path must exist', 'desc': 'Path to SSL dir. Folder owner must be a user which set in the SSH settings. Path must exist',
'group': group_id}, 'group': group_id},
{'param': 'local_path_logs', 'value': '/var/log/haproxy.log', 'section': 'logs', {'param': 'local_path_logs', 'value': '/var/log/haproxy.log', 'section': 'logs',
'desc': 'Logs save locally, enabled by default', 'group': group_id}, 'desc': 'The default local path for saving logs', 'group': group_id},
{'param': 'syslog_server_enable', 'value': '0', 'section': 'logs', {'param': 'syslog_server_enable', 'value': '0', 'section': 'logs',
'desc': 'If exist syslog server for HAProxy logs, enable this option', 'group': group_id}, 'desc': 'Use the syslog server for HAProxy logs; (0 - no, 1 - yes)', 'group': group_id},
{'param': 'syslog_server', 'value': '', 'section': 'logs', 'desc': 'IP address of the syslog_server',
'group': group_id},
{'param': 'stats_user', 'value': 'admin', 'section': 'haproxy', 'desc': 'Username for Stats web page HAProxy', {'param': 'stats_user', 'value': 'admin', 'section': 'haproxy', 'desc': 'Username for Stats web page HAProxy',
'group': group_id}, 'group': group_id},
{'param': 'stats_password', 'value': 'password', 'section': 'haproxy', {'param': 'stats_password', 'value': 'password', 'section': 'haproxy',
@ -145,10 +148,10 @@ def add_setting_for_new_group(group_id):
'group': group_id}, 'group': group_id},
{'param': 'nginx_path_error_logs', 'value': '/var/log/nginx/error.log', 'section': 'nginx', {'param': 'nginx_path_error_logs', 'value': '/var/log/nginx/error.log', 'section': 'nginx',
'desc': 'Nginx error log', 'group': group_id}, 'desc': 'Nginx error log', 'group': group_id},
{'param': 'nginx_stats_user', 'value': 'admin', 'section': 'nginx', 'desc': 'Username for Stats web page Nginx', {'param': 'nginx_stats_user', 'value': 'admin', 'section': 'nginx', 'desc': 'Username for accessing Nginx stats page',
'group': group_id}, 'group': group_id},
{'param': 'nginx_stats_password', 'value': 'password', 'section': 'nginx', {'param': 'nginx_stats_password', 'value': 'password', 'section': 'nginx',
'desc': 'Password for Stats web page Nginx', 'group': group_id}, 'desc': 'Password for accessing Nginx stats page', 'group': group_id},
{'param': 'nginx_stats_port', 'value': '8086', 'section': 'nginx', 'desc': 'Stats port for web page Nginx', {'param': 'nginx_stats_port', 'value': '8086', 'section': 'nginx', 'desc': 'Stats port for web page Nginx',
'group': group_id}, 'group': group_id},
{'param': 'nginx_stats_page', 'value': 'stats', 'section': 'nginx', 'desc': 'URI Stats for web page Nginx', {'param': 'nginx_stats_page', 'value': 'stats', 'section': 'nginx', 'desc': 'URI Stats for web page Nginx',
@ -157,26 +160,25 @@ def add_setting_for_new_group(group_id):
'group': group_id}, 'group': group_id},
{'param': 'nginx_config_path', 'value': '/etc/nginx/conf.d/default.conf', 'section': 'nginx', {'param': 'nginx_config_path', 'value': '/etc/nginx/conf.d/default.conf', 'section': 'nginx',
'desc': 'Path to Nginx config', 'group': group_id}, 'desc': 'Path to Nginx config', 'group': group_id},
{'param': 'ldap_enable', 'value': '0', 'section': 'ldap', 'desc': 'If 1 ldap enabled', 'group': group_id}, {'param': 'ldap_enable', 'value': '0', 'section': 'ldap', 'desc': 'Enable LDAP (1 - yes, 0 - no)',
{'param': 'ldap_server', 'value': '', 'section': 'ldap', 'desc': 'IP address ldap server', 'group': group_id}, 'group': group_id},
{'param': 'ldap_port', 'value': '389', 'section': 'ldap', 'desc': 'Default port: 389 or 636', {'param': 'ldap_server', 'value': '', 'section': 'ldap', 'desc': 'IP address of the LDAP server', 'group': group_id},
{'param': 'ldap_port', 'value': '389', 'section': 'ldap', 'desc': 'LDAP port (port 389 or 636 is used by default)',
'group': group_id}, 'group': group_id},
{'param': 'ldap_user', 'value': '', 'section': 'ldap', {'param': 'ldap_user', 'value': '', 'section': 'ldap',
'desc': 'Login to connect to LDAP server. Format: user@domain.com', 'group': group_id}, 'desc': 'Loging for connecting to LDAP server. Format: user@domain.com', 'group': group_id},
{'param': 'ldap_password', 'value': '', 'section': 'ldap', 'desc': 'Password to connect to LDAP server', {'param': 'ldap_password', 'value': '', 'section': 'ldap', 'desc': 'Password to connect to LDAP server',
'group': group_id}, 'group': group_id},
{'param': 'ldap_base', 'value': '', 'section': 'ldap', 'desc': 'Base domain. Example: dc=domain, dc=com', {'param': 'ldap_base', 'value': '', 'section': 'ldap', 'desc': 'Base domain. Example: dc=domain, dc=com',
'group': group_id}, 'group': group_id},
{'param': 'ldap_domain', 'value': '', 'section': 'ldap', {'param': 'ldap_domain', 'value': '', 'section': 'ldap', 'desc': 'LDAP domain for the login', 'group': group_id},
'desc': 'Domain for login, like user@domain.com, without user@', 'group': group_id}, {'param': 'ldap_class_search', 'value': 'user', 'section': 'ldap', 'desc': 'Class for searching the user',
{'param': 'ldap_class_search', 'value': 'user', 'section': 'ldap', 'desc': 'Class to search user',
'group': group_id}, 'group': group_id},
{'param': 'ldap_user_attribute', 'value': 'sAMAccountName', 'section': 'ldap', {'param': 'ldap_user_attribute', 'value': 'sAMAccountName', 'section': 'ldap',
'desc': 'User attribute for searching', 'group': group_id}, 'desc': 'User attribute for search', 'group': group_id},
{'param': 'ldap_search_field', 'value': 'mail', 'section': 'ldap', 'desc': 'Field where an user e-mail saved', {'param': 'ldap_search_field', 'value': 'mail', 'section': 'ldap',
'group': group_id}, 'desc': 'The field for saving the user\'s e-mail address', 'group': group_id},
{'param': 'ldap_type', 'value': '0', 'section': 'ldap', {'param': 'ldap_type', 'value': '0', 'section': 'ldap', 'desc': 'Use LDAP (0) or LDAPS (1)', 'group': group_id},
'desc': 'If 0 then will be used LDAP, if 1 then will be used LDAPS', 'group': group_id},
{'param': 'haproxy_enterprise', 'value': '0', 'section': 'haproxy', {'param': 'haproxy_enterprise', 'value': '0', 'section': 'haproxy',
'desc': 'Use this option if your HAProxy is enterprise. It changes service name for rebooting/reloading', 'desc': 'Use this option if your HAProxy is enterprise. It changes service name for rebooting/reloading',
'group': group_id}, 'group': group_id},
@ -1901,7 +1903,6 @@ def select_smon(user_group, **kwargs):
%s order by `group`""" % user_group %s order by `group`""" % user_group
else: else:
sql = """select * from `smon` %s """ % user_group sql = """select * from `smon` %s """ % user_group
print(sql)
try: try:
cursor.execute(sql) cursor.execute(sql)
except Exception as e: except Exception as e:

View File

@ -4,7 +4,13 @@
{% for set in settings %} {% for set in settings %}
{% if section.section|string() != set.section|string() %} {% if section.section|string() != set.section|string() %}
<th colspan="3" title="Show {{ set.section }} section" id="{{set.section}}-section-head" style="cursor: pointer; padding-top: 10px;"> <th colspan="3" title="Show {{ set.section }} section" id="{{set.section}}-section-head" style="cursor: pointer; padding-top: 10px;">
<h3 class="plus-after" id="{{set.section}}-section-h3" style="font-size: 1em; padding-left: 15px;">{{ set.section[0]|upper}}{{set.section[1:] }} section</h3> <h3 class="plus-after" id="{{set.section}}-section-h3" style="font-size: 1em; padding-left: 15px;">
{% if set.section == 'ldap' %}
{{ set.section|upper}}
{% else %}
{{ set.section[0]|upper}}{{set.section[1:] }}
{% endif %}
</h3>
</th> </th>
<tr class="overviewHead {{set.section}}-section" style="display: none"> <tr class="overviewHead {{set.section}}-section" style="display: none">
<td class="padding10 first-collumn">Parameter</td> <td class="padding10 first-collumn">Parameter</td>