diff --git a/cgi-bin/diff.py b/cgi-bin/diff.py
index ea7420a4..93d165ab 100644
--- a/cgi-bin/diff.py
+++ b/cgi-bin/diff.py
@@ -69,6 +69,6 @@ if form.getvalue('serv') is not None and form.getvalue('open') is not None :
if form.getvalue('serv') is not None and form.getvalue('right') is not None:
commands = [ 'diff -ub %s%s %s%s' % (hap_configs_dir, left, hap_configs_dir, right) ]
- funct.ssh_command(haproxy_configs_server, commands, compare="compare")
+ funct.ssh_command(haproxy_configs_server, commands, compare="1")
funct.footer()
\ No newline at end of file
diff --git a/cgi-bin/funct.py b/cgi-bin/funct.py
index b53e62cf..d5119cea 100644
--- a/cgi-bin/funct.py
+++ b/cgi-bin/funct.py
@@ -301,38 +301,33 @@ def show_ip(stdout):
for line in stdout:
print(line)
+def server_status(stdout):
+ if " " not in stdout.read().decode(encoding='UTF-8'):
+ print(' UP running 3 processes')
+ else:
+ print(' DOWN running 0 processes')
+
def ssh_command(serv, commands, **kwargs):
ssh = ssh_connect(serv)
-
- ip = 0
- compare_funct = 0
- show_log_funct = 0
-
- for k in kwargs:
- if "ip" in kwargs[k]:
- ip = 1
- if "compare" in kwargs[k]:
- compare_funct = 1
- if "show_log" in kwargs[k]:
- show_log_funct = 1
-
+
for command in commands:
try:
stdin, stdout, stderr = ssh.exec_command(command)
except:
continue
- if ip is 1:
+ if kwargs.get("ip") == "1":
show_ip(stdout)
- if compare_funct is 1:
+ if kwargs.get("compare") == "1":
compare(stdout)
- if show_log_funct is 1:
+ if kwargs.get("show_log") == "1":
show_log(stdout)
+ if kwargs.get("server_status") == "1":
+ server_status(stdout)
else:
print(stdout.read().decode(encoding='UTF-8'))
print(stderr.read().decode(encoding='UTF-8'))
- #ssh.close()
def chooseServer(formName, title, note):
print('
' + title + '
')
diff --git a/cgi-bin/haproxy-webintarface.config b/cgi-bin/haproxy-webintarface.config
new file mode 100644
index 00000000..41282f18
--- /dev/null
+++ b/cgi-bin/haproxy-webintarface.config
@@ -0,0 +1,54 @@
+[main]
+#Path to files destination
+fullpath = /var/www/haproxy-wi/
+server_bind_ip = 0.0.0.0
+server_port = 8000
+log_path = %(fullpath)s/log/
+time_zone = UTC
+#Enable logo on top menu. Default disable
+logo_enable = 0
+logo_path = /logo.png
+
+[configs]
+#Server for save configs from HAproxy servers
+haproxy_configs_server = localhost
+#Dir where configs will be save
+haproxy_save_configs_dir = /var/www/haproxy-wi/cgi-bin/hap_config/
+
+[ssh]
+#If ssh connect disable entare password for ssh connect. Default enable
+ssh_keys_enable = 1
+#SSH keys to connect without password to HAproxy servers
+ssh_keys = /var/www/haproxy-wi/cgi-bin/id_rsa.pem
+#Username for connect ssh
+ssh_user_name = root
+ssh_pass =
+
+[logs]
+#Logs save locally, disable by default
+local_path_logs = /var/log/haproxy.log
+#If exist syslog server for HAproxy logs
+syslog_server_enable = 0
+syslog_server =
+
+[telegram]
+#Send log message to telegram channel
+#Default bot send message disable
+enable = 0
+token =
+channel_name =
+proxy =
+
+[haproxy]
+#Command for restart HAproxy service
+restart_command = service haproxy restart
+#Username and password for Stats web page HAproxy
+user = admin
+password = password
+stats_port = 8085
+stats_page = stats
+haproxy_config_path = /etc/haproxy/haproxy.cfg
+#Temp store configs, for haproxy check
+tmp_config_path = /tmp
+#Time in seconds for auto refresh view stats_port
+refresh_time = 120
diff --git a/cgi-bin/logs.py b/cgi-bin/logs.py
index 1afea9a1..14e6718d 100644
--- a/cgi-bin/logs.py
+++ b/cgi-bin/logs.py
@@ -71,6 +71,6 @@ if form.getvalue('serv') is not None:
commands = [ 'sudo tail -%s /var/log/%s/syslog.log %s %s' % (rows, serv, grep_act, grep) ]
syslog_server = config.get('logs', 'syslog_server')
- funct.ssh_command(syslog_server, commands, show_log="show_log")
+ funct.ssh_command(syslog_server, commands, show_log="1")
funct.footer()
\ No newline at end of file
diff --git a/cgi-bin/options.py b/cgi-bin/options.py
index a87003dd..80e045e7 100644
--- a/cgi-bin/options.py
+++ b/cgi-bin/options.py
@@ -10,7 +10,6 @@ form = cgi.FieldStorage()
req = form.getvalue('req')
serv = form.getvalue('serv')
print('Content-type: text/html\n')
-#print('Content-type: application/json\n')
if req is not None:
if req is 1:
@@ -43,7 +42,7 @@ if backend is not None:
if form.getvalue('ip') is not None and serv is not None:
commands = [ "ip a |grep inet |egrep -v '::1' |awk '{ print $2 }' |awk -F'/' '{ print $1 }'" ]
- funct.ssh_command(serv, commands, ip="ip")
+ funct.ssh_command(serv, commands, ip="1")
if form.getvalue('name') is not None:
name = form.getvalue('name')
diff --git a/cgi-bin/overview.py b/cgi-bin/overview.py
index 00903d36..ffe79c5f 100644
--- a/cgi-bin/overview.py
+++ b/cgi-bin/overview.py
@@ -13,11 +13,20 @@ path_config = "haproxy-webintarface.config"
config = configparser.ConfigParser()
config.read(path_config)
-commands = [ "cat /etc/haproxy/haproxy.cfg |grep -E '^listen|^backend|^frontend' |wc -l", "haproxy -v |head -1", "top -u haproxy -b -n 1" ]
print('