Pavel Loginov 2022-05-23 21:23:01 +03:00
parent 56b2c8639b
commit ecaff8ef7a
5 changed files with 171 additions and 164 deletions

View File

@ -170,8 +170,10 @@ def get_status(server_id, service):
apache_stats_password = sql.get_setting('apache_stats_password')
apache_stats_port = sql.get_setting('apache_stats_port')
apache_stats_page = sql.get_setting('apache_stats_page')
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)
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
)
servers_with_status = list()
try:
out = funct.subprocess_execute(cmd)

View File

@ -28,32 +28,40 @@ if service == 'nginx':
if serv:
if funct.check_is_server_in_group(serv):
server_id = sql.select_server_id_by_ip(serv)
history = sql.select_action_history_by_server_id_and_service(server_id,
service)
history = sql.select_action_history_by_server_id_and_service(
server_id,
service
)
elif service == 'keepalived':
if funct.check_login(service=3):
title = 'Keepalived service history'
if serv:
if funct.check_is_server_in_group(serv):
server_id = sql.select_server_id_by_ip(serv)
history = sql.select_action_history_by_server_id_and_service(server_id,
service)
history = sql.select_action_history_by_server_id_and_service(
server_id,
service
)
elif service == 'apache':
if funct.check_login(service=4):
title = 'Apache service history'
if serv:
if funct.check_is_server_in_group(serv):
server_id = sql.select_server_id_by_ip(serv)
history = sql.select_action_history_by_server_id_and_service(server_id,
service)
history = sql.select_action_history_by_server_id_and_service(
server_id,
service
)
elif service == 'haproxy':
if funct.check_login(service=1):
title = "HAProxy service history"
if serv:
if funct.check_is_server_in_group(serv):
server_id = sql.select_server_id_by_ip(serv)
history = sql.select_action_history_by_server_id_and_service(server_id,
service)
history = sql.select_action_history_by_server_id_and_service(
server_id,
service
)
elif service == 'server':
if serv:
title = serv + ' history'
@ -67,7 +75,8 @@ elif service == 'user':
users = sql.select_users()
template = template.render(h2=1,
template = template.render(
h2=1,
autorefresh=0,
title=title,
role=role,
@ -77,5 +86,6 @@ template = template.render(h2=1,
service=service,
history=history,
user_services=user_services,
token=token)
token=token
)
print(template)

View File

@ -17,7 +17,7 @@ try:
geoip_country_codes = sql.select_geoip_country_codes()
services = sql.select_services()
gits = sql.select_gits()
except Exception as e:
except Exception:
pass
try:

View File

@ -339,22 +339,17 @@ def select_users(**kwargs):
query = User.select().where(User.user_id == kwargs.get("id"))
elif kwargs.get("group") is not None:
query = (User.
select(
User,
UserGroups,
Case(0, [((
select(User, UserGroups, Case(0, [((
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)).
where(UserGroups.user_group_id == kwargs.get("group"))
)
else:
query = User.select(
User,
Case(0, [((
query = User.select(User,Case(0, [((
User.last_login_date >= funct.get_data('regular', timedelta_minutes_minus=15)
), 0)], 1).alias('last_login')
).order_by(User.user_id)
), 0)], 1).alias('last_login')).order_by(User.user_id)
try:
query_res = query.execute()
@ -823,7 +818,7 @@ def get_dick_permit(**kwargs):
ip = ''
if kwargs.get('virt'):
type_ip = "and type_ip = 1"
type_ip = ""
else:
type_ip = "and type_ip = 0"
if kwargs.get('disable') == 0: