Pavel Loginov 3 years ago
parent fa4df661af
commit 7af67b4a8d

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

@ -1996,3 +1996,14 @@ def return_user_status():
user_plan = sql.select_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)
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,
autorefresh=autorefresh,
title=title,
@ -199,5 +205,7 @@ template = template.render(h2=1,
services=services,
user_services=user_services,
service_settings=service_settings,
user_status=user_status,
user_plan=user_plan,
token=token)
print(template)

@ -4192,6 +4192,23 @@ if act == 'check_service':
print('down')
except Exception:
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'):
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(
Server.server_id == server_id)
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)
else:
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':
date_from = "and date > now() - INTERVAL 180 minute group by `date` div 200"
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':
date_from = "and date > now() - INTERVAL 720 minute group by `date` div 500"
else:
@ -1805,7 +1805,8 @@ def get_setting(param, **kwargs):
param == 'syslog_server_enable' or param == 'smon_check_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 == '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)
else:
@ -1944,6 +1945,16 @@ def select_nginx_keep_alive():
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():
query = Server.select(Server.ip, Server.port, Server.groups).where(Server.keepalived_active == 1)
try:

@ -42,10 +42,10 @@
</td>
<td class="padding10 first-collumn">
{% if service.6|int() == 0 %}
<span class="serverNone server-status" title="Keepalived is not installed" style="margin-left: 4px !important;"></span>
<span class="serverNone server-status" title="Keepalived is not installed" style="margin-left: 4px !important;"></span>
{% else %}
{% if service.7|int() >= 1 %}
<span class="serverUp server-status" title="running {{service.7 }} processes" style="margin-left: 4px !important;"></span>
<span class="serverUp server-status" title="running {{service.7 }} processes" style="margin-left: 4px !important;"></span>
{% else %}
<span class="serverDown server-status" title="Keepalived is down" style="margin-left: 4px !important;"></span>
{% endif %}
@ -53,7 +53,7 @@
</td>
<td class="third-collumn-wi">
{% if service.5.0|length() == 0 %}
<span class="serverNone server-status" title="WAF is not installed" style="margin-left: 4px !important;"></span>
<span class="serverNone server-status" title="WAF is not installed" style="margin-left: 4px !important;"></span>
{% elif service.5.0 != '' and service.4|int() == 0 %}
<span class="serverDown server-status" title="WAF is down" style="margin-left: 4px !important;"></span>
{% elif service.5.0 != '' and service.4|int() >= 1 %}
@ -61,4 +61,15 @@
{% endif %}
</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 %}

@ -1,5 +1,5 @@
{% extends "base.html" %}
{% block content %}
{% block content %}
{% from 'include/input_macros.html' import input, checkbox, select, copy_to_clipboard %}
<script src="/inc/overview.js"></script>
<link href="/inc/chart.min.css" rel="stylesheet">
@ -20,6 +20,9 @@
var host = "{{s[2]}}"
host = host.replace(/\./g, '\\.');
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 %}
$( function() {
$( ".sortable" ).sortable({
@ -39,10 +42,10 @@
}
});
{% 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' %}
$(':regex(id, alert)').checkboxradio('disable');
{% elif s.0 == 'rpxy-wi-keep_alive' %}
$(':regex(id, alert-)').checkboxradio('disable');
{% elif s.0 == 'roxy-wi-keep_alive' or s.0 == 'roxy-wi-keep-alive' %}
$(':regex(id, active-)').checkboxradio('disable');
{% elif s.0 == 'roxy-wi-metrics' %}
$(':regex(id, metrics-)').checkboxradio('disable');
@ -214,13 +217,13 @@
<br />
{{s.5.0.2}}
{% else %}
Cannot get information about HAProxy
{% endif %}
Cannot get information about HAProxy
{% endif %}
{% endif %}
<span title="Date of last configuration edit">
Last edit:
<span id="edit_date_{{s.2}}"></span>
</span>
</span>
<br />
IP: {{ copy_to_clipboard(value=s.2, style='font-weight: bold') }}
{% if s.7.0.0 != None %}
@ -253,7 +256,7 @@
{{ checkbox(id, title='Enable collecting metrics', value='1', desc='Metrics') }}
{% endif %}
{% endif %}
{% if role <= 2 and service != 'apache' %}
{% if role <= 2 %}
{% set id = 'active-' + s.8.0.0|string() %}
{% if is_auto_start_enabled == 1 %}
{{ checkbox(id, title='Auto Start is enabled', value='1', desc='Auto Start', checked='checked') }}

Loading…
Cancel
Save