Pavel Loginov 3 years ago
parent fa4df661af
commit 7af67b4a8d

@ -694,7 +694,7 @@ def update_db_v_6_0_1(**kwargs):
def update_ver(): def update_ver():
query = Version.update(version='6.0.0.0') query = Version.update(version='6.0.1.0')
try: try:
query.execute() query.execute()
except: except:

@ -1996,3 +1996,14 @@ def return_user_status():
user_plan = sql.select_user_plan() user_plan = sql.select_user_plan()
return user_status, user_plan return user_status, user_plan
def get_correct_apache_service_name(server_ip):
import sql
server_id = sql.select_server_id_by_ip(server_ip)
os_info = sql.select_os_info(server_id)
if "CentOS" in os_info or "Redhat" in os_info:
return 'httpd'
else:
return 'apache2'

@ -187,6 +187,12 @@ for s in servers:
servers_with_status1.append(servers_with_status) servers_with_status1.append(servers_with_status)
try:
user_status, user_plan = funct.return_user_status()
except Exception as e:
user_status, user_plan = 0, 0
funct.logging('localhost', 'Cannot get a user plan: ' + str(e), haproxywi=1)
template = template.render(h2=1, template = template.render(h2=1,
autorefresh=autorefresh, autorefresh=autorefresh,
title=title, title=title,
@ -199,5 +205,7 @@ template = template.render(h2=1,
services=services, services=services,
user_services=user_services, user_services=user_services,
service_settings=service_settings, service_settings=service_settings,
user_status=user_status,
user_plan=user_plan,
token=token) token=token)
print(template) print(template)

@ -4192,6 +4192,23 @@ if act == 'check_service':
print('down') print('down')
except Exception: except Exception:
print('down') print('down')
if '4' in user_services:
if service == 'apache':
import socket
from contextlib import closing
apache_stats_port = sql.get_setting('apache_stats_port')
with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock:
sock.settimeout(5)
try:
if sock.connect_ex((serv, apache_stats_port)) == 0:
print('up')
else:
print('down')
except Exception as e:
print('down' + str(e))
if form.getvalue('show_sub_ovw'): if form.getvalue('show_sub_ovw'):
from jinja2 import Environment, FileSystemLoader from jinja2 import Environment, FileSystemLoader

@ -279,7 +279,7 @@ def update_hapwi_server(server_id, alert, metrics, active, service_name):
update_hapwi = Server.update(keepalived_alert=alert, keepalived_active=active).where( update_hapwi = Server.update(keepalived_alert=alert, keepalived_active=active).where(
Server.server_id == server_id) Server.server_id == server_id)
elif service_name == 'apache': elif service_name == 'apache':
update_hapwi = Server.update(apache_alert=alert).where( update_hapwi = Server.update(apache_alert=alert, apache_active=active).where(
Server.server_id == server_id) Server.server_id == server_id)
else: else:
update_hapwi = Server.update(alert=alert, metrics=metrics, active=active).where( update_hapwi = Server.update(alert=alert, metrics=metrics, active=active).where(
@ -1276,7 +1276,7 @@ def select_nginx_metrics(serv, **kwargs):
elif kwargs.get('time_range') == '180': elif kwargs.get('time_range') == '180':
date_from = "and date > now() - INTERVAL 180 minute group by `date` div 200" date_from = "and date > now() - INTERVAL 180 minute group by `date` div 200"
elif kwargs.get('time_range') == '360': elif kwargs.get('time_range') == '360':
date_from = "and date > now() - INTERVAL 360 minute group by `date` div 400" date_from = "and date > now() - INTERVAL 360 minute group by `date` div 300"
elif kwargs.get('time_range') == '720': elif kwargs.get('time_range') == '720':
date_from = "and date > now() - INTERVAL 720 minute group by `date` div 500" date_from = "and date > now() - INTERVAL 720 minute group by `date` div 500"
else: else:
@ -1805,7 +1805,8 @@ def get_setting(param, **kwargs):
param == 'syslog_server_enable' or param == 'smon_check_interval' or param == 'syslog_server_enable' or param == 'smon_check_interval' or
param == 'checker_check_interval' or param == 'port_scan_interval' or param == 'checker_check_interval' or param == 'port_scan_interval' or
param == 'smon_keep_history_range' or param == 'checker_keep_history_range' or param == 'smon_keep_history_range' or param == 'checker_keep_history_range' or
param == 'portscanner_keep_history_range' or param == 'checker_maxconn_threshold' param == 'portscanner_keep_history_range' or param == 'checker_maxconn_threshold' or
param == 'apache_stats_port'
): ):
return int(setting.value) return int(setting.value)
else: else:
@ -1944,6 +1945,16 @@ def select_nginx_keep_alive():
return query_res return query_res
def select_apache_keep_alive():
query = Server.select(Server.ip, Server.groups).where(Server.apache_active == 1)
try:
query_res = query.execute()
except Exception as e:
out_error(e)
else:
return query_res
def select_keepalived_keep_alive(): def select_keepalived_keep_alive():
query = Server.select(Server.ip, Server.port, Server.groups).where(Server.keepalived_active == 1) query = Server.select(Server.ip, Server.port, Server.groups).where(Server.keepalived_active == 1)
try: try:

@ -61,4 +61,15 @@
{% endif %} {% endif %}
</td> </td>
<td></td> <td></td>
<script>
{% if service.2|int() >= 1 %}
setInterval(check_service_status, 11000, '{{service.10}}', '{{service.1}}', 'haproxy');
{% endif %}
{% if service.8|int() >= 1 %}
setInterval(check_service_status, 12000, '{{service.10}}', '{{service.1}}', 'nginx');
{% endif %}
{% if service.11|int() >= 1 %}
setInterval(check_service_status, 13000, '{{service.10}}', '{{service.1}}', 'apache');
{% endif %}
</script>
{% endfor %} {% endfor %}

@ -20,6 +20,9 @@
var host = "{{s[2]}}" var host = "{{s[2]}}"
host = host.replace(/\./g, '\\.'); host = host.replace(/\./g, '\\.');
hostnamea.push(host) hostnamea.push(host)
var ip_for_check = "{{s.2}}";
ip_for_check = ip_for_check.replace(/\./g, '\\.');
setInterval(check_service_status, 11000, {{s.0}}, '{{s.2}}', '{{service}}');
{% endfor %} {% endfor %}
$( function() { $( function() {
$( ".sortable" ).sortable({ $( ".sortable" ).sortable({
@ -39,10 +42,10 @@
} }
}); });
{% for s in services %} {% for s in services %}
{% if 'is not installed' in s.1 or s.1 == '' %} {% if 'is not installed' in s.1 or s.1 == '' or user_status == 0 %}
{% if s.0 == 'roxy-wi-checker' %} {% if s.0 == 'roxy-wi-checker' %}
$(':regex(id, alert)').checkboxradio('disable'); $(':regex(id, alert-)').checkboxradio('disable');
{% elif s.0 == 'rpxy-wi-keep_alive' %} {% elif s.0 == 'roxy-wi-keep_alive' or s.0 == 'roxy-wi-keep-alive' %}
$(':regex(id, active-)').checkboxradio('disable'); $(':regex(id, active-)').checkboxradio('disable');
{% elif s.0 == 'roxy-wi-metrics' %} {% elif s.0 == 'roxy-wi-metrics' %}
$(':regex(id, metrics-)').checkboxradio('disable'); $(':regex(id, metrics-)').checkboxradio('disable');
@ -253,7 +256,7 @@
{{ checkbox(id, title='Enable collecting metrics', value='1', desc='Metrics') }} {{ checkbox(id, title='Enable collecting metrics', value='1', desc='Metrics') }}
{% endif %} {% endif %}
{% endif %} {% endif %}
{% if role <= 2 and service != 'apache' %} {% if role <= 2 %}
{% set id = 'active-' + s.8.0.0|string() %} {% set id = 'active-' + s.8.0.0|string() %}
{% if is_auto_start_enabled == 1 %} {% if is_auto_start_enabled == 1 %}
{{ checkbox(id, title='Auto Start is enabled', value='1', desc='Auto Start', checked='checked') }} {{ checkbox(id, title='Auto Start is enabled', value='1', desc='Auto Start', checked='checked') }}

Loading…
Cancel
Save