mirror of https://github.com/Aidaho12/haproxy-wi
parent
3f045650e7
commit
d6a27f8307
|
@ -6,6 +6,7 @@ import modules.roxywi.common as roxywi_common
|
|||
from modules.server import ssh_connection
|
||||
import modules.roxy_wi_tools as roxy_wi_tools
|
||||
|
||||
form = common.form
|
||||
get_config_var = roxy_wi_tools.GetConfigVar()
|
||||
|
||||
|
||||
|
@ -354,3 +355,62 @@ def get_system_info(server_ip: str) -> str:
|
|||
sql.insert_system_info(server_id, os_info, sys_info, cpu, ram, network, disks)
|
||||
except Exception as e:
|
||||
raise e
|
||||
|
||||
|
||||
def show_system_info() -> None:
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
|
||||
server_ip = form.getvalue('server_ip')
|
||||
server_ip = common.is_ip_or_dns(server_ip)
|
||||
server_id = form.getvalue('server_id')
|
||||
|
||||
if server_ip == '':
|
||||
print('error: IP or DNS name is not valid')
|
||||
return
|
||||
|
||||
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True,
|
||||
extensions=["jinja2.ext.loopcontrols", "jinja2.ext.do"])
|
||||
env.globals['string_to_dict'] = common.string_to_dict
|
||||
template = env.get_template('ajax/show_system_info.html')
|
||||
if sql.is_system_info(server_id):
|
||||
try:
|
||||
get_system_info(server_ip)
|
||||
system_info = sql.select_one_system_info(server_id)
|
||||
|
||||
template = template.render(system_info=system_info, server_ip=server_ip, server_id=server_id)
|
||||
print(template)
|
||||
except Exception as e:
|
||||
print(f'Cannot update server info: {e}')
|
||||
else:
|
||||
system_info = sql.select_one_system_info(server_id)
|
||||
|
||||
template = template.render(system_info=system_info, server_ip=server_ip, server_id=server_id)
|
||||
print(template)
|
||||
|
||||
|
||||
def update_system_info() -> None:
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
|
||||
server_ip = form.getvalue('server_ip')
|
||||
server_ip = common.is_ip_or_dns(server_ip)
|
||||
server_id = form.getvalue('server_id')
|
||||
|
||||
if server_ip == '':
|
||||
print('error: IP or DNS name is not valid')
|
||||
return
|
||||
|
||||
sql.delete_system_info(server_id)
|
||||
|
||||
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True,
|
||||
extensions=["jinja2.ext.loopcontrols", "jinja2.ext.do"])
|
||||
env.globals['string_to_dict'] = common.string_to_dict
|
||||
template = env.get_template('ajax/show_system_info.html')
|
||||
|
||||
try:
|
||||
get_system_info(server_ip)
|
||||
system_info = sql.select_one_system_info(server_id)
|
||||
|
||||
template = template.render(system_info=system_info, server_ip=server_ip, server_id=server_id)
|
||||
print(template)
|
||||
except Exception as e:
|
||||
print(f'error: Cannot update server info: {e}')
|
||||
|
|
|
@ -4064,60 +4064,11 @@ if act == 'showListOfVersion':
|
|||
|
||||
if act == 'getSystemInfo':
|
||||
import modules.server.server as server_mod
|
||||
|
||||
server_ip = form.getvalue('server_ip')
|
||||
server_ip = common.is_ip_or_dns(server_ip)
|
||||
server_id = form.getvalue('server_id')
|
||||
|
||||
if server_ip == '':
|
||||
print('error: IP or DNS name is not valid')
|
||||
sys.exit()
|
||||
|
||||
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True,
|
||||
extensions=["jinja2.ext.loopcontrols", "jinja2.ext.do"])
|
||||
env.globals['string_to_dict'] = common.string_to_dict
|
||||
template = env.get_template('ajax/show_system_info.html')
|
||||
if sql.is_system_info(server_id):
|
||||
try:
|
||||
server_mod.get_system_info(server_ip)
|
||||
system_info = sql.select_one_system_info(server_id)
|
||||
|
||||
template = template.render(system_info=system_info, server_ip=server_ip, server_id=server_id)
|
||||
print(template)
|
||||
except Exception as e:
|
||||
print(f'Cannot update server info: {e}')
|
||||
else:
|
||||
system_info = sql.select_one_system_info(server_id)
|
||||
|
||||
template = template.render(system_info=system_info, server_ip=server_ip, server_id=server_id)
|
||||
print(template)
|
||||
server_mod.show_system_info()
|
||||
|
||||
if act == 'updateSystemInfo':
|
||||
import modules.server.server as server_mod
|
||||
|
||||
server_ip = form.getvalue('server_ip')
|
||||
server_ip = common.is_ip_or_dns(server_ip)
|
||||
server_id = form.getvalue('server_id')
|
||||
|
||||
if server_ip == '':
|
||||
print('error: IP or DNS name is not valid')
|
||||
sys.exit()
|
||||
|
||||
sql.delete_system_info(server_id)
|
||||
|
||||
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True,
|
||||
extensions=["jinja2.ext.loopcontrols", "jinja2.ext.do"])
|
||||
env.globals['string_to_dict'] = common.string_to_dict
|
||||
template = env.get_template('ajax/show_system_info.html')
|
||||
|
||||
try:
|
||||
server_mod.get_system_info(server_ip)
|
||||
system_info = sql.select_one_system_info(server_id)
|
||||
|
||||
template = template.render(system_info=system_info, server_ip=server_ip, server_id=server_id)
|
||||
print(template)
|
||||
except Exception as e:
|
||||
print(f'error: Cannot update server info: {e}')
|
||||
server_mod.update_system_info()
|
||||
|
||||
if act == 'findInConfigs':
|
||||
server_ip = serv
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
</ul>
|
||||
|
||||
<div id="git_tab">
|
||||
{% if user_status == 0 or user_plan == 'user' %}
|
||||
{% if user_status == 0 or user_plan != 'support' %}
|
||||
{% include 'include/no_sub.html' %}
|
||||
{% else %}
|
||||
<table class="overview" id="ajax-git-table">
|
||||
|
|
|
@ -14,10 +14,10 @@
|
|||
{% if user_status == 0 %}
|
||||
You are not subscribed. Please subscribe to have access to this feature.
|
||||
<p>
|
||||
Read <a href="https://roxy-wi.org/pricing.py" title="Roxy-WI pricing" target="_blank">here</a> about subscriptions
|
||||
Read <a href="https://roxy-wi.org/pricing" title="Roxy-WI pricing" target="_blank" class="link">here</a> about subscriptions
|
||||
</p>
|
||||
{% elif user_plan == 'user' %}
|
||||
This feature is not available for your plan. To change the plan, follow this <a href="https://roxy-wi.org/pricing.py" title="Roxy-WI pricing" target="_blank">link</a>
|
||||
{% elif user_plan == 'user' or user_plan != 'support' %}
|
||||
This feature is not available for your plan. To change the plan, follow this <a href="https://roxy-wi.org/pricing" title="Roxy-WI pricing" target="_blank" class="link">link</a>
|
||||
{% endif %}
|
||||
</h4>
|
||||
</center>
|
||||
|
|
|
@ -10,13 +10,17 @@
|
|||
{% elif smon_error != '' %}
|
||||
<div style="text-align: center;">
|
||||
<br />
|
||||
<h3>You have not installed SMON service. Read <a href="https://roxy-wi.org/services/smon"
|
||||
title="Simple monitoring network ports with alerting via Telegram and WEB panel" target="_blank">here</a> how to install SMON service</h3>
|
||||
<h3>You have not installed SMON service</h3>.
|
||||
<img src="/inc/images/no_servers.png" alt="There is no server">
|
||||
<h4>Read <a href="https://roxy-wi.org/services/smon" title="Simple monitoring network ports with alerting via Telegram and WEB panel" target="_blank">here</a>
|
||||
how to install SMON service.</h4>
|
||||
</div>
|
||||
{% elif smon_status.0 == 'failed' %}
|
||||
<div style="text-align: center;">
|
||||
<br />
|
||||
<h3>SMON service is not run. Run the SMON service <a href="users.py#services" title="Roxy-WI services" target="_blank">here</a> before use</h3>
|
||||
<h3>SMON service is not run.</h3>
|
||||
<img src="/inc/images/no_servers.png" alt="There is no server">
|
||||
<h4>Run the SMON service <a href="users.py#services" title="Roxy-WI services" target="_blank">here</a> before use</h4>
|
||||
</div>
|
||||
{% elif smon|length == 0 and action != 'add' and action != 'history' and action != 'checker_history' %}
|
||||
<div style="text-align: center;">
|
||||
|
|
Loading…
Reference in New Issue