Pavel Loginov 4 years ago
parent 7d428fe0f6
commit f2de51507a

@ -701,12 +701,34 @@ def update_db_v_4_5_4(**kwargs):
pass
else:
if kwargs.get('silent') != 1:
print('Updating... go to version 4.5.6')
print('Updating... go to version 4.5.7')
cur.close()
con.close()
def update_db_v_4_5_7(**kwargs):
con, cur = get_cur()
sql = """
ALTER TABLE `servers` ADD COLUMN nginx_alert INTEGER NOT NULL DEFAULT 0;
"""
try:
cur.execute(sql)
con.commit()
except sqltool.Error as e:
if kwargs.get('silent') != 1:
if e.args[0] == 'duplicate column name: nginx_alert' or e == " 1060 (42S21): Duplicate column name 'nginx_alert' ":
print('Updating... go to version 4.5.8')
else:
print("An error occurred:", e)
else:
print("DB was update to 4.3.1")
cur.close()
con.close()
def update_ver(**kwargs):
con, cur = get_cur()
sql = """update version set version = '4.5.7.0'; """
@ -744,6 +766,7 @@ def update_all():
update_db_v_4_5()
update_db_v_4_5_1()
update_db_v_4_5_4()
update_db_v_4_5_7()
update_ver()
@ -772,6 +795,7 @@ def update_all_silent():
update_db_v_4_5(silent=1)
update_db_v_4_5_1(silent=1)
update_db_v_4_5_4(silent=1)
update_db_v_4_5_7(silent=1)
update_ver()

@ -76,6 +76,7 @@ for s in servers:
h = (out1,)
servers_with_status.append(h)
servers_with_status.append(h)
servers_with_status.append(s[17])
else:
cmd = 'echo "show info" |nc %s %s -w 1 |grep -e "Ver\|Uptime:\|Process_num"' % (s[2], haproxy_sock_port)
out = funct.subprocess_execute(cmd)
@ -85,10 +86,9 @@ for s in servers:
else:
out1 = False
servers_with_status.append(out1)
if service == 'haproxy':
servers_with_status.append(s[12])
else:
servers_with_status.append(s[17])
servers_with_status.append(sql.is_master(s[2]))
servers_with_status.append(sql.select_servers(server=s[2]))

@ -346,15 +346,15 @@ def delete_server(id):
def update_hapwi_server(server_id, alert, metrics, active, service_name):
con, cur = get_cur()
updated_service = 'active'
updated_service = ''
if service_name == 'nginx':
updated_service = 'nginx_active'
updated_service = 'nginx_'
sql = """ update servers set
alert = '%s',
'%salert' = '%s',
metrics = '%s',
'%s' = '%s'
where id = '%s'""" % (alert, metrics, updated_service, active, server_id)
'%sactive' = '%s'
where id = '%s'""" % (updated_service, alert, metrics, updated_service, active, server_id)
try:
cur.execute(sql)
@ -1872,6 +1872,21 @@ def select_alert(**kwargs):
con.close()
def select_nginx_alert(**kwargs):
con, cur = get_cur()
sql = """select ip from servers where nginx_alert = 1 """
if kwargs.get("group") is not None:
sql = """select ip from servers where nginx_alert = 1 and `groups` = '%s' """ % kwargs.get("group")
try:
cur.execute(sql)
except sqltool.Error as e:
funct.out_error(e)
else:
return cur.fetchall()
cur.close()
con.close()
def select_keep_alive(**kwargs):
con, cur = get_cur()
sql = """select ip from servers where active = 1 """
@ -1885,6 +1900,19 @@ def select_keep_alive(**kwargs):
con.close()
def select_nginx_keep_alive(**kwargs):
con, cur = get_cur()
sql = """select ip from servers where nginx_active = 1 """
try:
cur.execute(sql)
except sqltool.Error as e:
funct.out_error(e)
else:
return cur.fetchall()
cur.close()
con.close()
def select_keealived(serv, **kwargs):
con, cur = get_cur()
sql = """select keepalived from `servers` where ip='%s' """ % serv

@ -110,7 +110,8 @@
{% endif %}
{% if service == 'nginx' %}
{% set checker_desc = 'Checker monitors Nginx services. If Nginx service is down, Checker will alert via Telegram' %}
{% set is_checker_enabled = s.8.0.17 %}
{% set is_auto_start_enabled = s.8.0.17 %}
{% set is_checker_enabled = s.8.0.19 %}
{% if s.5.0.3 == 'active' %}
{% set additional_status_class = 'div-server-head-up' %}
{% else %}
@ -118,7 +119,8 @@
{% endif %}
{% else %}
{% set checker_desc = 'Checker monitors HAProxy services and its backends. If some backend or HAProxy service is down, Checker will alert via Telegram' %}
{% set is_checker_enabled = s.8.0.12 %}
{% set is_auto_start_enabled = s.8.0.12 %}
{% set is_checker_enabled = s.8.0.8 %}
{% if s.5 != False %}
{% set additional_status_class = 'div-server-head-up' %}
{% else %}
@ -187,8 +189,8 @@
Uptime: {% else %} Downtime: {% endif %} {{s.5.0.4}}
{% else %}
{% if s.5.0 is defined %}
{{s.5.0.0}} {{s.5.0.1}}
<br />{{s.5.0.2}}
{{s.5.0.0}} {{s.5.0.1}}
{{s.5.0.2}}
{% else %}
Cannot get information about HAProxy
{% endif %}
@ -205,28 +207,26 @@
</div>
<div class="server-act-links" id="server-{{s.8.0.0|string()}}-{{service}}">
{% if role <= 2 %}
{% if service == 'haproxy' %}
{% set id = 'alert-' + s.8.0.0|string() %}
{% if s.8.0.8 == 1 %}
{% if is_checker_enabled == 1 %}
{{ checkbox(id, title=checker_desc, value='1', desc='Checker', checked='checked') }}
{% else %}
{{ checkbox(id, title=checker_desc, value='1', desc='Checker') }}
{% endif %}
{% if service == 'haproxy' %}
{% set id = 'metrics-' + s.8.0.0|string() %}
{% if s.8.0.9 == 1 %}
{{ checkbox(id, title='Collecting metrics is enabled', value='1', desc='Metrics', checked='checked') }}
{% else %}
{{ checkbox(id, title='Enable collecting metrics', value='1', desc='Metrics') }}
{% endif %}
{% endif %}
{% endif %}
{% set id = 'active-' + s.8.0.0|string() %}
{% if is_checker_enabled == 1 %}
{% if is_auto_start_enabled == 1 %}
{{ checkbox(id, title='Auto Start is enabled', value='1', desc='Auto Start', checked='checked') }}
{% else %}
{{ checkbox(id, title='Enable Auto Start', value='1', desc='Auto Start') }}
{% endif %}
</div>
{% endif %}
<div class="server-act-links">

Loading…
Cancel
Save