You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
haproxy-wi/app/smon.py

49 lines
1.3 KiB

#!/usr/bin/env python3
import funct
import sql
from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True)
template = env.get_template('smon.html')
smon_status = ''
stderr = ''
form = funct.form
action = form.getvalue('action')
sort = form.getvalue('sort')
print('Content-type: text/html\n')
funct.check_login()
try:
user, user_id, role, token, servers = funct.get_users_params()
import http.cookies
import os
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
group = cookie.get('group')
user_group = group.value
cmd = "systemctl status smon |grep Active |awk '{print $2}'"
smon_status, stderr = funct.subprocess_execute(cmd)
except:
pass
if action == 'add':
smon = sql.select_smon(user_group=user_group,action='add')
funct.page_for_admin(level=2)
title = "SMON Admin"
else:
smon = sql.smon_list(user_group)
title = "SMON Dashboard"
template = template.render(h2 = 1, title = title,
autoreœfresh = 1,
role = role,
user = user,
group = user_group,
telegrams = sql.get_user_telegram_by_group(user_group),
versions = funct.versions(),
smon = smon,
smon_status = smon_status,
smon_error = stderr,
action = action,
sort = sort,
token = token)
print(template)