mirror of https://github.com/Aidaho12/haproxy-wi
parent
56b2c8639b
commit
ecaff8ef7a
|
@ -170,8 +170,10 @@ def get_status(server_id, service):
|
||||||
apache_stats_password = sql.get_setting('apache_stats_password')
|
apache_stats_password = sql.get_setting('apache_stats_password')
|
||||||
apache_stats_port = sql.get_setting('apache_stats_port')
|
apache_stats_port = sql.get_setting('apache_stats_port')
|
||||||
apache_stats_page = sql.get_setting('apache_stats_page')
|
apache_stats_page = sql.get_setting('apache_stats_page')
|
||||||
cmd = "curl -s -u %s:%s http://%s:%s/%s?auto |grep 'ServerVersion\|Processes\|ServerUptime:'" % (
|
cmd = "curl -s -u %s:%s http://%s:%s/%s?auto |grep 'ServerVersion\|Processes\|ServerUptime:'" % \
|
||||||
apache_stats_user, apache_stats_password, s[2], apache_stats_port, apache_stats_page)
|
(
|
||||||
|
apache_stats_user, apache_stats_password, s[2], apache_stats_port, apache_stats_page
|
||||||
|
)
|
||||||
servers_with_status = list()
|
servers_with_status = list()
|
||||||
try:
|
try:
|
||||||
out = funct.subprocess_execute(cmd)
|
out = funct.subprocess_execute(cmd)
|
||||||
|
|
|
@ -28,32 +28,40 @@ if service == 'nginx':
|
||||||
if serv:
|
if serv:
|
||||||
if funct.check_is_server_in_group(serv):
|
if funct.check_is_server_in_group(serv):
|
||||||
server_id = sql.select_server_id_by_ip(serv)
|
server_id = sql.select_server_id_by_ip(serv)
|
||||||
history = sql.select_action_history_by_server_id_and_service(server_id,
|
history = sql.select_action_history_by_server_id_and_service(
|
||||||
service)
|
server_id,
|
||||||
|
service
|
||||||
|
)
|
||||||
elif service == 'keepalived':
|
elif service == 'keepalived':
|
||||||
if funct.check_login(service=3):
|
if funct.check_login(service=3):
|
||||||
title = 'Keepalived service history'
|
title = 'Keepalived service history'
|
||||||
if serv:
|
if serv:
|
||||||
if funct.check_is_server_in_group(serv):
|
if funct.check_is_server_in_group(serv):
|
||||||
server_id = sql.select_server_id_by_ip(serv)
|
server_id = sql.select_server_id_by_ip(serv)
|
||||||
history = sql.select_action_history_by_server_id_and_service(server_id,
|
history = sql.select_action_history_by_server_id_and_service(
|
||||||
service)
|
server_id,
|
||||||
|
service
|
||||||
|
)
|
||||||
elif service == 'apache':
|
elif service == 'apache':
|
||||||
if funct.check_login(service=4):
|
if funct.check_login(service=4):
|
||||||
title = 'Apache service history'
|
title = 'Apache service history'
|
||||||
if serv:
|
if serv:
|
||||||
if funct.check_is_server_in_group(serv):
|
if funct.check_is_server_in_group(serv):
|
||||||
server_id = sql.select_server_id_by_ip(serv)
|
server_id = sql.select_server_id_by_ip(serv)
|
||||||
history = sql.select_action_history_by_server_id_and_service(server_id,
|
history = sql.select_action_history_by_server_id_and_service(
|
||||||
service)
|
server_id,
|
||||||
|
service
|
||||||
|
)
|
||||||
elif service == 'haproxy':
|
elif service == 'haproxy':
|
||||||
if funct.check_login(service=1):
|
if funct.check_login(service=1):
|
||||||
title = "HAProxy service history"
|
title = "HAProxy service history"
|
||||||
if serv:
|
if serv:
|
||||||
if funct.check_is_server_in_group(serv):
|
if funct.check_is_server_in_group(serv):
|
||||||
server_id = sql.select_server_id_by_ip(serv)
|
server_id = sql.select_server_id_by_ip(serv)
|
||||||
history = sql.select_action_history_by_server_id_and_service(server_id,
|
history = sql.select_action_history_by_server_id_and_service(
|
||||||
service)
|
server_id,
|
||||||
|
service
|
||||||
|
)
|
||||||
elif service == 'server':
|
elif service == 'server':
|
||||||
if serv:
|
if serv:
|
||||||
title = serv + ' history'
|
title = serv + ' history'
|
||||||
|
@ -67,7 +75,8 @@ elif service == 'user':
|
||||||
|
|
||||||
users = sql.select_users()
|
users = sql.select_users()
|
||||||
|
|
||||||
template = template.render(h2=1,
|
template = template.render(
|
||||||
|
h2=1,
|
||||||
autorefresh=0,
|
autorefresh=0,
|
||||||
title=title,
|
title=title,
|
||||||
role=role,
|
role=role,
|
||||||
|
@ -77,5 +86,6 @@ template = template.render(h2=1,
|
||||||
service=service,
|
service=service,
|
||||||
history=history,
|
history=history,
|
||||||
user_services=user_services,
|
user_services=user_services,
|
||||||
token=token)
|
token=token
|
||||||
|
)
|
||||||
print(template)
|
print(template)
|
|
@ -17,7 +17,7 @@ try:
|
||||||
geoip_country_codes = sql.select_geoip_country_codes()
|
geoip_country_codes = sql.select_geoip_country_codes()
|
||||||
services = sql.select_services()
|
services = sql.select_services()
|
||||||
gits = sql.select_gits()
|
gits = sql.select_gits()
|
||||||
except Exception as e:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
17
app/sql.py
17
app/sql.py
|
@ -339,22 +339,17 @@ def select_users(**kwargs):
|
||||||
query = User.select().where(User.user_id == kwargs.get("id"))
|
query = User.select().where(User.user_id == kwargs.get("id"))
|
||||||
elif kwargs.get("group") is not None:
|
elif kwargs.get("group") is not None:
|
||||||
query = (User.
|
query = (User.
|
||||||
select(
|
select(User, UserGroups, Case(0, [((
|
||||||
User,
|
|
||||||
UserGroups,
|
|
||||||
Case(0, [((
|
|
||||||
User.last_login_date >= funct.get_data('regular', timedelta_minutes_minus=15)
|
User.last_login_date >= funct.get_data('regular', timedelta_minutes_minus=15)
|
||||||
), 0)], 1).alias('last_login')).
|
), 0)], 1).
|
||||||
|
alias('last_login')).
|
||||||
join(UserGroups, on=(User.user_id == UserGroups.user_id)).
|
join(UserGroups, on=(User.user_id == UserGroups.user_id)).
|
||||||
where(UserGroups.user_group_id == kwargs.get("group"))
|
where(UserGroups.user_group_id == kwargs.get("group"))
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
query = User.select(
|
query = User.select(User,Case(0, [((
|
||||||
User,
|
|
||||||
Case(0, [((
|
|
||||||
User.last_login_date >= funct.get_data('regular', timedelta_minutes_minus=15)
|
User.last_login_date >= funct.get_data('regular', timedelta_minutes_minus=15)
|
||||||
), 0)], 1).alias('last_login')
|
), 0)], 1).alias('last_login')).order_by(User.user_id)
|
||||||
).order_by(User.user_id)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
query_res = query.execute()
|
query_res = query.execute()
|
||||||
|
@ -823,7 +818,7 @@ def get_dick_permit(**kwargs):
|
||||||
ip = ''
|
ip = ''
|
||||||
|
|
||||||
if kwargs.get('virt'):
|
if kwargs.get('virt'):
|
||||||
type_ip = "and type_ip = 1"
|
type_ip = ""
|
||||||
else:
|
else:
|
||||||
type_ip = "and type_ip = 0"
|
type_ip = "and type_ip = 0"
|
||||||
if kwargs.get('disable') == 0:
|
if kwargs.get('disable') == 0:
|
||||||
|
|
Loading…
Reference in New Issue