mirror of https://github.com/Aidaho12/haproxy-wi
				
				
				
			
							parent
							
								
									a2694d8617
								
							
						
					
					
						commit
						1c157e998b
					
				| 
						 | 
				
			
			@ -158,7 +158,7 @@ def update_db_v_41(**kwargs):
 | 
			
		|||
		cursor.execute(sql)
 | 
			
		||||
	except Exception as e:
 | 
			
		||||
		if kwargs.get('silent') != 1:
 | 
			
		||||
			if e.args[0] == 'duplicate column name: nginx' or e == " 1060 (42S21): Duplicate column name 'nginx' ":
 | 
			
		||||
			if e.args[0] == 'duplicate column name: nginx'  or str(e) == '(1060, "Duplicate column name \'nginx\'")':
 | 
			
		||||
				print('Updating... one more for version 4.0.0')
 | 
			
		||||
			else:
 | 
			
		||||
				print("An error occurred:", e)
 | 
			
		||||
| 
						 | 
				
			
			@ -175,7 +175,7 @@ def update_db_v_42(**kwargs):
 | 
			
		|||
		cursor.execute(sql)
 | 
			
		||||
	except Exception as e:
 | 
			
		||||
		if kwargs.get('silent') != 1:
 | 
			
		||||
			if e.args[0] == 'duplicate column name: haproxy' or e == " 1060 (42S21): Duplicate column name 'haproxy' ":
 | 
			
		||||
			if e.args[0] == 'duplicate column name: haproxy' or str(e) == '(1060, "Duplicate column name \'haproxy\'")':
 | 
			
		||||
				print('Updating... go to version 4.2.3')
 | 
			
		||||
			else:
 | 
			
		||||
				print("An error occurred:", e)
 | 
			
		||||
| 
						 | 
				
			
			@ -190,7 +190,7 @@ def update_db_v_4_3_0(**kwargs):
 | 
			
		|||
								fields=[UserGroups.user_id, UserGroups.user_group_id]).on_conflict_ignore().execute()
 | 
			
		||||
	except Exception as e:
 | 
			
		||||
		if kwargs.get('silent') != 1:
 | 
			
		||||
			if e.args[0] == 'duplicate column name: haproxy' or e == " 1060 (42S21): Duplicate column name 'haproxy' ":
 | 
			
		||||
			if e.args[0] == 'duplicate column name: haproxy' or str(e) == '(1060, "Duplicate column name \'haproxy\'")':
 | 
			
		||||
				print('Updating... go to version 4.3.1')
 | 
			
		||||
			else:
 | 
			
		||||
				print("An error occurred:", e)
 | 
			
		||||
| 
						 | 
				
			
			@ -205,7 +205,7 @@ def update_db_v_4_3_1(**kwargs):
 | 
			
		|||
		cursor.execute(sql)
 | 
			
		||||
	except Exception as e:
 | 
			
		||||
		if kwargs.get('silent') != 1:
 | 
			
		||||
			if e.args[0] == 'duplicate column name: pos' or e == " 1060 (42S21): Duplicate column name 'pos' ":
 | 
			
		||||
			if e.args[0] == 'duplicate column name: pos' or str(e) == '(1060, "Duplicate column name \'pos\'")':
 | 
			
		||||
				print('Updating... go to version 4.3.2')
 | 
			
		||||
			else:
 | 
			
		||||
				print("An error occurred:", e)
 | 
			
		||||
| 
						 | 
				
			
			@ -221,7 +221,7 @@ def update_db_v_4_4_2_1(**kwargs):
 | 
			
		|||
		cursor.execute(sql)
 | 
			
		||||
	except Exception as e:
 | 
			
		||||
		if kwargs.get('silent') != 1:
 | 
			
		||||
			if e.args[0] == 'duplicate column name: group' or e == " 1060 (42S21): Duplicate column name 'group' ":
 | 
			
		||||
			if e.args[0] == 'duplicate column name: group' or str(e) == '(1060, "Duplicate column name \'group\'")':
 | 
			
		||||
				print('Updating... go to version 4.4.2')
 | 
			
		||||
			else:
 | 
			
		||||
				print("An error occurred:", e)
 | 
			
		||||
| 
						 | 
				
			
			@ -251,7 +251,7 @@ def update_db_v_4_3_2_1(**kwargs):
 | 
			
		|||
 | 
			
		||||
		except Exception as e:
 | 
			
		||||
			if kwargs.get('silent') != 1:
 | 
			
		||||
				if str(e) == 'columns param, group are not unique':
 | 
			
		||||
				if str(e) == 'columns param, group are not unique' or str(e) == '(1062, "Duplicate entry \'haproxy_enterprise-1\' for key \'param\'")':
 | 
			
		||||
					pass
 | 
			
		||||
				else:
 | 
			
		||||
					print("An error occurred:", e)
 | 
			
		||||
| 
						 | 
				
			
			@ -314,7 +314,7 @@ def update_db_v_4_5_7(**kwargs):
 | 
			
		|||
		cursor.execute(sql)
 | 
			
		||||
	except Exception as e:
 | 
			
		||||
		if kwargs.get('silent') != 1:
 | 
			
		||||
			if e.args[0] == 'duplicate column name: nginx_alert' or e == " 1060 (42S21): Duplicate column name 'nginx_alert' ":
 | 
			
		||||
			if e.args[0] == 'duplicate column name: nginx_alert' or str(e) == '(1060, "Duplicate column name \'nginx_alert\'")':
 | 
			
		||||
				print('Updating... go to version 4.5.8')
 | 
			
		||||
			else:
 | 
			
		||||
				print("An error occurred:", e)
 | 
			
		||||
| 
						 | 
				
			
			@ -608,7 +608,7 @@ def update_db_v_4_5_8_2(**kwargs):
 | 
			
		|||
 | 
			
		||||
		except Exception as e:
 | 
			
		||||
			if kwargs.get('silent') != 1:
 | 
			
		||||
				if str(e) == 'columns param, group are not unique':
 | 
			
		||||
				if str(e) == 'columns param, group are not unique'  or str(e) == '(1062, "Duplicate entry \'maxmind_key-1\' for key \'param\'")':
 | 
			
		||||
					pass
 | 
			
		||||
				else:
 | 
			
		||||
					print("An error occurred:", e)
 | 
			
		||||
| 
						 | 
				
			
			@ -685,7 +685,7 @@ def update_db_v_5_1_3(**kwargs):
 | 
			
		|||
		cursor.execute(sql)
 | 
			
		||||
	except Exception as e:
 | 
			
		||||
		if kwargs.get('silent') != 1:
 | 
			
		||||
			if str(e) == 'duplicate column name: protected':
 | 
			
		||||
			if str(e) == 'duplicate column name: protected' or str(e) == '(1060, "Duplicate column name \'protected\'")':
 | 
			
		||||
				print('Updating... DB has been updated to version 5.1.3')
 | 
			
		||||
			else:
 | 
			
		||||
				print("An error occurred:", e)
 | 
			
		||||
| 
						 | 
				
			
			@ -700,7 +700,7 @@ def update_db_v_5_2_0(**kwargs):
 | 
			
		|||
					   desc='How many days to keep the history for the Port scanner service').execute()
 | 
			
		||||
	except Exception as e:
 | 
			
		||||
		if kwargs.get('silent') != 1:
 | 
			
		||||
			if str(e) == 'columns param, group are not unique':
 | 
			
		||||
			if str(e) == 'columns param, group are not unique' or str(e) == '(1062, "Duplicate entry \'portscanner_keep_history_range-1\' for key \'param\'")':
 | 
			
		||||
				pass
 | 
			
		||||
			else:
 | 
			
		||||
				print("An error occurred:", e)
 | 
			
		||||
| 
						 | 
				
			
			@ -711,7 +711,7 @@ def update_db_v_5_2_0(**kwargs):
 | 
			
		|||
 | 
			
		||||
def update_db_v_5_2_4(**kwargs):
 | 
			
		||||
	cursor = conn.cursor()
 | 
			
		||||
	sql = """ALTER TABLE `user` ADD COLUMN user_services varchar DEFAULT '1 2 3';"""
 | 
			
		||||
	sql = """ALTER TABLE `user` ADD COLUMN user_services varchar(20) DEFAULT '1 2 3';"""
 | 
			
		||||
	try:
 | 
			
		||||
		cursor.execute(sql)
 | 
			
		||||
	except Exception as e:
 | 
			
		||||
| 
						 | 
				
			
			@ -731,7 +731,7 @@ def update_db_v_5_2_4_1(**kwargs):
 | 
			
		|||
		cursor.execute(sql)
 | 
			
		||||
	except Exception as e:
 | 
			
		||||
		if kwargs.get('silent') != 1:
 | 
			
		||||
			if str(e) == 'duplicate column name: user_services':
 | 
			
		||||
			if str(e) == 'duplicate column name: nginx_metrics'  or str(e) == '(1060, "Duplicate column name \'nginx_metrics\'")':
 | 
			
		||||
				print('Updating... DB has been updated to version 5.2.4')
 | 
			
		||||
			else:
 | 
			
		||||
				print("An error occurred:", e)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1069,7 +1069,7 @@ if form.getvalue('master'):
 | 
			
		|||
        sql.add_server(hostname+'-VIP', IP, group_id, '1', '1', '0', cred_id, ssh_port, 'VRRP IP for '+master, haproxy, nginx, '0')
 | 
			
		||||
 | 
			
		||||
if form.getvalue('master_slave'):
 | 
			
		||||
    master = form.getvalue('master')
 | 
			
		||||
    master = form.getvalue('master_slave')
 | 
			
		||||
    slave = form.getvalue('slave')
 | 
			
		||||
    ETH = form.getvalue('interface')
 | 
			
		||||
    IP = form.getvalue('vrrpip')
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1473,10 +1473,10 @@ def select_nginx_servers_metrics_for_master():
 | 
			
		|||
def select_servers_metrics():
 | 
			
		||||
	group_id = funct.get_user_group(id=1)
 | 
			
		||||
	if funct.check_user_group():
 | 
			
		||||
		if group_id == '1':
 | 
			
		||||
		if group_id == 1:
 | 
			
		||||
			query = Server.select(Server.ip).where((Server.enable == 1) & (Server.metrics == 1))
 | 
			
		||||
		else:
 | 
			
		||||
			query = Server.select(Server.ip).where((Server.groups == group_id) & (Server.metrics == 1))
 | 
			
		||||
			query = Server.select(Server.ip).where((Server.enable == 1) & (Server.groups == group_id) & (Server.metrics == 1))
 | 
			
		||||
		try:
 | 
			
		||||
			query_res = query.execute()
 | 
			
		||||
		except Exception as e:
 | 
			
		||||
| 
						 | 
				
			
			@ -1490,7 +1490,7 @@ def select_table_metrics():
 | 
			
		|||
	group_id = funct.get_user_group(id=1)
 | 
			
		||||
 | 
			
		||||
	if funct.check_user_group():
 | 
			
		||||
		if group_id == '1':
 | 
			
		||||
		if group_id == 1:
 | 
			
		||||
			groups = ""
 | 
			
		||||
		else:
 | 
			
		||||
			groups = "and servers.groups = '{group}' ".format(group=group_id)
 | 
			
		||||
| 
						 | 
				
			
			@ -1698,7 +1698,7 @@ def get_setting(param, **kwargs):
 | 
			
		|||
		user_group = ''
 | 
			
		||||
 | 
			
		||||
	if user_group == '' or param == 'lists_path' or param == 'ssl_local_path':
 | 
			
		||||
		user_group = '1'
 | 
			
		||||
		user_group = 1
 | 
			
		||||
 | 
			
		||||
	if kwargs.get('all'):
 | 
			
		||||
		query = Setting.select().where(Setting.group == user_group).order_by(Setting.section.desc())
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -49,7 +49,7 @@
 | 
			
		|||
			{% if page != "servers.py" %}
 | 
			
		||||
			<td>
 | 
			
		||||
				<select id="servergroup-{{server.0}}" name="servergroup-{{server.0}}">
 | 
			
		||||
					<option disabled selected>Choose group</option>
 | 
			
		||||
					<option disabled selected>------</option>
 | 
			
		||||
					{% for group in groups %}
 | 
			
		||||
					{% if server.3 == group.group_id|string() %}
 | 
			
		||||
					<option value="{{ group.group_id }}" selected>{{ group.name }}</option>
 | 
			
		||||
| 
						 | 
				
			
			@ -130,7 +130,7 @@
 | 
			
		|||
			<td>
 | 
			
		||||
				<div class="controlgroup">
 | 
			
		||||
					<select id="credentials-{{server.0}}">
 | 
			
		||||
						<option disabled selected>Choose credentials</option>
 | 
			
		||||
						<option disabled selected>------</option>
 | 
			
		||||
						{% for ssh in sshs %}
 | 
			
		||||
							{% if ssh.id == server.7 %}
 | 
			
		||||
								<option value="{{ssh.id}}" selected>{{ssh.name}}</option>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -66,7 +66,7 @@
 | 
			
		|||
		<canvas id="http_{{s.ip}}" role="img"></canvas>
 | 
			
		||||
	</div>
 | 
			
		||||
	{% else %}
 | 
			
		||||
	<div class="chart-container nginx_metrics_div" style="display: none">
 | 
			
		||||
	<div class="chart-container">
 | 
			
		||||
		<canvas id="nginx_{{s.ip}}" role="img"></canvas>
 | 
			
		||||
	</div>
 | 
			
		||||
	{% endif %}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -60,7 +60,7 @@ $( function() {
 | 
			
		|||
		   show_current_page($(this))
 | 
			
		||||
	   } else if(cur_url[0] == 'viewlogs.py' && cur_url[1].split('&')[0] == 'type=2' && link2 == 'viewlogs.py?type=2'){
 | 
			
		||||
		  	show_current_page($(this))
 | 
			
		||||
	   } else if(cur_url[0] == 'metrics.py' && cur_url[1].split('&')[0] == 'service=nginx' && link2 == 'metrics?service=nginx'){
 | 
			
		||||
	   } else if(cur_url[0] == 'metrics.py' && cur_url[1].split('&')[0] == 'service=nginx' && link2 == 'metrics.py?service=nginx'){
 | 
			
		||||
		   show_current_page($(this))
 | 
			
		||||
	   }
 | 
			
		||||
   });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue