v.2.7.2.2

Checker alert message improved
pull/26/head
Aidaho12 2018-07-29 00:14:12 +06:00
parent b24eb38a3f
commit eebbf4354f
6 changed files with 11 additions and 47 deletions

View File

@ -16,7 +16,7 @@ if mysql_enable == '1':
import mysql.connector as sqltool
else:
fullpath = funct.get_config_var('main', 'fullpath')
db = fullpath+"/app/haproxy-wi.db"
db = funct.get_app_dir()+"/haproxy-wi.db"
import sqlite3 as sqltool
def check_db():
@ -133,7 +133,6 @@ def create_table(**kwargs):
`token` varchar(64),
`exp` DATETIME default '0000-00-00 00:00:00'
);
insert into cred('enable','username','password') values ('1', 'root','password');
"""
try:
cur.executescript(sql)
@ -246,34 +245,6 @@ def update_db_v_2_4(**kwargs):
cur.close()
con.close()
def update_db_v_2_5_3(**kwargs):
con, cur = get_cur()
sql = """
CREATE TABLE IF NOT EXISTS `cred` (`id` integer primary key autoincrement, `enable` INTEGER NOT NULL DEFAULT 1, `username` VARCHAR ( 64 ) NOT NULL, `password` VARCHAR ( 64 ) NOT NULL );
"""
try:
cur.execute(sql)
con.commit()
except sqltool.Error as e:
print(kwargs.get('silent'))
if kwargs.get('silent') != 1:
if e.args[0] == 'duplicate column name: enable':
print('Updating... go to version 2.5.6')
else:
print("An error occurred:", e)
return False
else:
if kwargs.get('silent') != 1:
print("DB was update to 2.5.3<br />")
sql2 = """
insert or ignore into `cred` (id, `enable`,`username`,`password`) values ('1', '1', 'root','password');
"""
cur.execute(sql2)
con.commit()
return True
cur.close()
con.close()
def update_db_v_2_5_6(**kwargs):
con, cur = get_cur()
if mysql_enable == '1':
@ -328,7 +299,7 @@ def update_db_v_2_5_6_1(**kwargs):
def update_db_v_2_6(**kwargs):
con, cur = get_cur()
sql = """ select id from cred limit 1 """
sql = """ select name from cred limit 1 """
try:
cur.execute(sql)
except sqltool.Error as e:
@ -469,7 +440,6 @@ def update_all():
update_db_v_2_0_1_1()
update_db_v_2_0_5()
update_db_v_2_4()
update_db_v_2_5_3()
update_db_v_2_5_6()
update_db_v_2_5_6_1()
update_db_v_2_6()
@ -483,7 +453,6 @@ def update_all_silent():
update_db_v_2_0_1_1(silent=1)
update_db_v_2_0_5(silent=1)
update_db_v_2_4(silent=1)
update_db_v_2_5_3(silent=1)
update_db_v_2_5_6(silent=1)
update_db_v_2_5_6_1(silent=1)
update_db_v_2_6(silent=1)

View File

@ -12,14 +12,12 @@ session_ttl = 5
token_ttl = 5
[configs]
#Server for save configs from HAproxy servers
haproxy_configs_server = localhost
#Dir where configs will be save
haproxy_save_configs_dir = ${main:fullpath}/configs/hap_config/
kp_save_configs_dir = ${main:fullpath}/configs/kp_config/
[mysql]
#Enable MySQL DB. If default will be used Sqlite DB. Default disable
#Enable MySQL DB. Default will be used Sqlite DB. Default disable
enable = 0
mysql_user = haproxy-wi
mysql_password = haproxy-wi
@ -27,7 +25,7 @@ mysql_db = haproxywi
mysql_host = 127.0.0.1
[logs]
#Logs save locally, disable by default
#Logs save locally, enable by default
local_path_logs = /var/log/haproxy.log
#If exist syslog server for HAproxy logs
syslog_server_enable = 0

View File

@ -166,9 +166,6 @@ def show_compare_configs(serv):
template = env.get_template('/show_compare_configs.html')
left = form.getvalue('left')
right = form.getvalue('right')
haproxy_configs_server = funct.get_config_var('configs', 'haproxy_configs_server')
output_from_parsed_template = template.render(serv = serv,
right = right,
@ -181,7 +178,6 @@ def comapre_show():
import subprocess
left = form.getvalue('left')
right = form.getvalue('right')
haproxy_configs_server = funct.get_config_var('configs', 'haproxy_configs_server')
cmd='diff -ub %s%s %s%s' % (hap_configs_dir, left, hap_configs_dir, right)
output, stderr = funct.subprocess_execute(cmd)

View File

@ -9,8 +9,6 @@ from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('templates/'))
template = env.get_template('viewsettings.html')
form = cgi.FieldStorage()
path_config = "haproxy-webintarface.config"
config = ConfigParser(interpolation=ExtendedInterpolation())
config.read(path_config)

View File

@ -3,7 +3,8 @@ import subprocess
import time
import argparse
import os, sys
sys.path.append(os.path.join(sys.path[0], '../'))
sys.path.append(os.path.join(sys.path[0], os.path.dirname(os.getcwd())))
sys.path.append(os.path.join(sys.path[0], os.getcwd()))
import funct
import sql
import signal
@ -69,7 +70,7 @@ if __name__ == "__main__":
while True:
main()
time.sleep(30)
time.sleep(20)
if killer.kill_now:
break

View File

@ -3,7 +3,8 @@ import subprocess
import time
import argparse
import os, sys
sys.path.append(os.path.join(sys.path[0], '/var/www/haproxy-wi/app'))
sys.path.append(os.path.join(sys.path[0], os.path.dirname(os.getcwd())))
sys.path.append(os.path.join(sys.path[0], os.getcwd()))
import funct
import signal
@ -47,7 +48,8 @@ def main(serv, port):
servername = str(vips[i])
servername = servername.split(",")
realserver = servername[0]
alert = realserver[2:]+ " has changed status and is now "+ currentstat[i] + " at " + serv
server = servername[1]
alert = "Backend: "+realserver[2:]+", server: "+server+" has changed status and is now "+ currentstat[i] + " at " + serv
funct.telegram_send_mess(str(alert), ip=serv)
funct.logging("localhost", " "+alert, alerting=1)
firstrun = False