haproxy-wi/app/viewsttats.py

42 lines
1.1 KiB
Python
Raw Normal View History

2018-01-15 06:16:04 +00:00
#!/usr/bin/env python3
import funct
import sql
from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True)
template = env.get_template('viewstats.html')
2019-12-04 13:38:07 +00:00
form = funct.form
serv = form.getvalue('serv')
service = form.getvalue('service')
print('Content-type: text/html\n')
funct.check_login()
try:
user, user_id, role, token, servers, user_services = funct.get_users_params(virt=1, haproxy=1)
2018-05-31 14:25:20 +00:00
if serv is None:
first_serv = servers
2018-05-31 14:25:20 +00:00
for i in first_serv:
serv = i[2]
break
except Exception:
pass
2019-09-15 11:51:09 +00:00
if service == 'nginx':
if funct.check_login(service=2):
title = 'NGINX stats page'
servers = sql.get_dick_permit(nginx=1)
elif service == 'apache':
if funct.check_login(service=4):
title = 'Apache stats page'
servers = sql.get_dick_permit(apache=1)
else:
if funct.check_login(service=1):
title = 'HAProxy stats page'
rendered_template = template.render(
h2=1, autorefresh=1, title=title, role=role, user=user, onclick="showStats()", select_id="serv",
selects=servers, serv=serv, service=service, user_services=user_services, token=token
)
print(rendered_template)