pull/42/head
Aidaho12 2018-09-17 17:22:44 +06:00
parent c5fb798a37
commit d38f1f2981
2 changed files with 9 additions and 28 deletions

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import os import os
import sql import sql
import http import http.cookies
import funct import funct
import sql import sql
from jinja2 import Environment, FileSystemLoader from jinja2 import Environment, FileSystemLoader

View File

@ -108,7 +108,6 @@ if form.getvalue('showif'):
funct.ssh_command(serv, commands, ip="1") funct.ssh_command(serv, commands, ip="1")
if form.getvalue('action_hap') is not None and serv is not None: if form.getvalue('action_hap') is not None and serv is not None:
serv = form.getvalue('serv')
action = form.getvalue('action_hap') action = form.getvalue('action_hap')
if funct.check_haproxy_config(serv): if funct.check_haproxy_config(serv):
@ -275,7 +274,6 @@ if form.getvalue('servaction') is not None:
haproxy_sock = sql.get_setting('haproxy_sock') haproxy_sock = sql.get_setting('haproxy_sock')
enable = form.getvalue('servaction') enable = form.getvalue('servaction')
backend = form.getvalue('servbackend') backend = form.getvalue('servbackend')
cmd='echo "%s %s" |sudo socat stdio %s | cut -d "," -f 1-2,5-10,18,34-36 | column -s, -t' % (enable, backend, haproxy_sock) cmd='echo "%s %s" |sudo socat stdio %s | cut -d "," -f 1-2,5-10,18,34-36 | column -s, -t' % (enable, backend, haproxy_sock)
if form.getvalue('save') == "on": if form.getvalue('save') == "on":
@ -299,12 +297,8 @@ if act == "showCompareConfigs":
left = form.getvalue('left') left = form.getvalue('left')
right = form.getvalue('right') right = form.getvalue('right')
output_from_parsed_template = template.render(serv = serv, template = template.render(serv=serv, right=right, left=left, return_files=funct.get_files())
right = right, print(template)
left = left,
return_files = funct.get_files())
print(output_from_parsed_template)
if serv is not None and form.getvalue('right') is not None: if serv is not None and form.getvalue('right') is not None:
from jinja2 import Environment, FileSystemLoader from jinja2 import Environment, FileSystemLoader
@ -330,7 +324,6 @@ if serv is not None and act == "configShow":
else: else:
cfg = hap_configs_dir + form.getvalue('configver') cfg = hap_configs_dir + form.getvalue('configver')
try: try:
conf = open(cfg, "r") conf = open(cfg, "r")
except IOError: except IOError:
@ -340,10 +333,7 @@ if serv is not None and act == "configShow":
env = Environment(loader=FileSystemLoader('templates/ajax'),extensions=['jinja2.ext.loopcontrols']) env = Environment(loader=FileSystemLoader('templates/ajax'),extensions=['jinja2.ext.loopcontrols'])
template = env.get_template('config_show.html') template = env.get_template('config_show.html')
template = template.render(conf=conf, template = template.render(conf=conf, view=form.getvalue('view'), serv=serv, configver=form.getvalue('configver'))
view=form.getvalue('view'),
serv=serv,
configver=form.getvalue('configver'))
print(template) print(template)
if form.getvalue('configver') is None: if form.getvalue('configver') is None:
@ -495,20 +485,13 @@ if form.getvalue('metrics'):
p[serv].y_range.end = int(df['curr_con'].max()) + 150 p[serv].y_range.end = int(df['curr_con'].max()) + 150
p[serv].add_tools(hover) p[serv].add_tools(hover)
p[serv].title.text_font_size = "20px" p[serv].title.text_font_size = "20px"
p[serv].line("Date", "curr_con", source=source, alpha=0.5, color='#5cb85c', line_width=2, legend="Conn") p[serv].line("Date", "curr_con", source=source, alpha=0.5, color='#5cb85c', line_width=2, legend="Conn")
p[serv].line("Date", "curr_ssl_con", source=source, alpha=0.5, color="#5d9ceb", line_width=2, legend="SSL con") p[serv].line("Date", "curr_ssl_con", source=source, alpha=0.5, color="#5d9ceb", line_width=2, legend="SSL con")
p[serv].line("Date", "sess_rate", source=source, alpha=0.5, color="#33414e", line_width=2, legend="Sessions") p[serv].line("Date", "sess_rate", source=source, alpha=0.5, color="#33414e", line_width=2, legend="Sessions")
#p[serv].line("Date", "max_sess_rate", source=source, alpha=0.5, color="red", line_width=2, legend="Max sess")
p[serv].legend.orientation = "horizontal" p[serv].legend.orientation = "horizontal"
p[serv].legend.location = "top_left" p[serv].legend.location = "top_left"
p[serv].legend.padding = 5 p[serv].legend.padding = 5
#select = Select(title="Option:", value="foo", options=["foo", "bar", "baz", "quux"])
#show(widgetbox(select, width=300))
plots = [] plots = []
i = 0 i = 0
for key, value in p.items(): for key, value in p.items():
@ -575,8 +558,6 @@ if form.getvalue('waf_metrics'):
p[serv].y_range.end = int(df['conn'].max()) + 150 p[serv].y_range.end = int(df['conn'].max()) + 150
p[serv].add_tools(hover) p[serv].add_tools(hover)
p[serv].title.text_font_size = "20px" p[serv].title.text_font_size = "20px"
p[serv].line("Date", "conn", source=source, alpha=0.5, color='#5cb85c', line_width=2, legend="Conn") p[serv].line("Date", "conn", source=source, alpha=0.5, color='#5cb85c', line_width=2, legend="Conn")
p[serv].legend.orientation = "horizontal" p[serv].legend.orientation = "horizontal"
p[serv].legend.location = "top_left" p[serv].legend.location = "top_left"