Aidaho 2024-04-17 11:06:29 +03:00
parent 73563a047e
commit b205d47372
26 changed files with 523 additions and 60 deletions

View File

@ -205,7 +205,6 @@ def haproxy_log(haproxy_id):
def get_section(haproxy_id):
if not check_login(required_service=1):
return dict(error=_error_auth)
print(str(request.headers.get('section-name')))
return api_funct.get_section(haproxy_id)

View File

@ -733,9 +733,29 @@ def update_db_v_7_2_0_1():
print("Updating... DB has been updated to version 7.2.0-1")
def update_db_v_7_2_3():
try:
if mysql_enable:
migrate(
migrator.add_column('checker_setting', 'mm_id', IntegerField(default=0)),
migrator.add_column('smon', 'mm_channel_id', IntegerField(default=0)),
)
else:
migrate(
migrator.add_column('checker_setting', 'mm_id', IntegerField(constraints=[SQL('DEFAULT 0')])),
migrator.add_column('smon', 'mm_channel_id', IntegerField(constraints=[SQL('DEFAULT 0')])),
)
except Exception as e:
if e.args[0] == 'duplicate column name: mm_id' or str(e) == '(1060, "Duplicate column name \'mm_id\'")':
print('Updating... DB has been updated to version 7.2.3')
else:
print("An error occurred:", e)
def update_ver():
try:
Version.update(version='7.2.2.0').execute()
Version.update(version='7.2.3.0').execute()
except Exception:
print('Cannot update version')
@ -771,6 +791,7 @@ def update_all():
update_db_v_7_1_2_1()
update_db_v_7_2_0()
update_db_v_7_2_0_1()
update_db_v_7_2_3()
update_ver()

View File

@ -1,4 +1,4 @@
from app.modules.db.db_model import Telegram, Slack, PD, Server
from app.modules.db.db_model import Telegram, Slack, PD, Server, MM
from app.modules.db.common import out_error
@ -51,6 +51,13 @@ def get_user_pd_by_group(group):
out_error(e)
def get_user_mm_by_group(group):
try:
return MM.select().where(MM.groups == group).execute()
except Exception as e:
out_error(e)
def get_pd_by_ip(ip):
query = PD.select().join(Server, on=(Server.groups == PD.groups)).where(Server.ip == ip)
try:
@ -201,3 +208,65 @@ def update_pd(token, chanel, group, pd_id):
return False
else:
return True
def insert_new_mm(token, chanel, group):
try:
MM.insert(token=token, chanel_name=chanel, groups=group).execute()
except Exception as e:
out_error(e)
return False
else:
return True
def update_mm(token, chanel, group, mm_id):
try:
MM.update(token=token, chanel_name=chanel, groups=group).where(MM.id == mm_id).execute()
except Exception as e:
out_error(e)
return False
else:
return True
def delete_mm(pd_id):
try:
MM.delete().where(MM.id == pd_id).execute()
except Exception as e:
out_error(e)
return False
else:
return True
def select_mm(**kwargs):
if kwargs.get('token'):
query = MM.select().where(MM.token == kwargs.get('token'))
elif kwargs.get('id'):
query = MM.select().where(MM.id == kwargs.get('id'))
else:
query = MM.select()
try:
query_res = query.execute()
except Exception as e:
out_error(e)
else:
return query_res
def get_mm_by_ip(ip):
query = MM.select().join(Server, on=(Server.groups == MM.groups)).where(Server.ip == ip)
try:
query_res = query.execute()
except Exception as e:
out_error(e)
else:
return query_res
def get_mm_by_id(pd_id):
try:
return MM.select().where(MM.id == pd_id).execute()
except Exception as e:
out_error(e)

View File

@ -41,11 +41,11 @@ def insert_new_checker_setting_for_server(server_ip: str) -> None:
def update_haproxy_checker_settings(
email: int, telegram_id: int, slack_id: int, pd_id: int, service_alert: int, backend_alert: int,
email: int, telegram_id: int, slack_id: int, pd_id: int, mm_id: int, service_alert: int, backend_alert: int,
maxconn_alert: int, setting_id: int
) -> bool:
settings_update = CheckerSetting.update(
email=email, telegram_id=telegram_id, slack_id=slack_id, pd_id=pd_id, service_alert=service_alert,
email=email, telegram_id=telegram_id, slack_id=slack_id, pd_id=pd_id, mm_id=mm_id, service_alert=service_alert,
backend_alert=backend_alert, maxconn_alert=maxconn_alert
).where(CheckerSetting.id == setting_id)
try:
@ -57,11 +57,11 @@ def update_haproxy_checker_settings(
def update_keepalived_checker_settings(
email: int, telegram_id: int, slack_id: int, pd_id: int, service_alert: int, backend_alert: int,
email: int, telegram_id: int, slack_id: int, pd_id: int, mm_id: int, service_alert: int, backend_alert: int,
setting_id: int
) -> bool:
settings_update = CheckerSetting.update(
email=email, telegram_id=telegram_id, slack_id=slack_id, pd_id=pd_id,
email=email, telegram_id=telegram_id, slack_id=slack_id, pd_id=pd_id, mm_id=mm_id,
service_alert=service_alert, backend_alert=backend_alert
).where(CheckerSetting.id == setting_id)
try:
@ -73,10 +73,10 @@ def update_keepalived_checker_settings(
def update_service_checker_settings(
email: int, telegram_id: int, slack_id: int, pd_id: int, service_alert: int, setting_id: int
email: int, telegram_id: int, slack_id: int, pd_id: int, mm_id: int, service_alert: int, setting_id: int
) -> bool:
settings_update = CheckerSetting.update(
email=email, telegram_id=telegram_id, slack_id=slack_id, pd_id=pd_id, service_alert=service_alert
email=email, telegram_id=telegram_id, slack_id=slack_id, pd_id=pd_id, mm_id=mm_id, service_alert=service_alert
).where(CheckerSetting.id == setting_id)
try:
settings_update.execute()

View File

@ -123,6 +123,16 @@ class Slack(BaseModel):
table_name = 'slack'
class MM(BaseModel):
id = AutoField()
token = CharField()
chanel_name = CharField()
groups = IntegerField()
class Meta:
table_name = 'mattermost'
class PD(BaseModel):
id = AutoField()
token = CharField()
@ -406,6 +416,7 @@ class SMON(BaseModel):
ssl_expire_date = CharField(null=True)
pd_channel_id = IntegerField(null=True)
check_type = CharField(constraints=[SQL('DEFAULT "tcp"')])
mm_channel_id = IntegerField(null=True)
class Meta:
table_name = 'smon'
@ -540,6 +551,7 @@ class CheckerSetting(BaseModel):
backend_alert = IntegerField(constraints=[SQL('DEFAULT 1')])
maxconn_alert = IntegerField(constraints=[SQL('DEFAULT 1')])
pd_id = IntegerField(constraints=[SQL('DEFAULT 0')])
mm_id = IntegerField(constraints=[SQL('DEFAULT 0')])
class Meta:
table_name = 'checker_setting'
@ -763,5 +775,5 @@ def create_tables():
NginxMetrics, SystemInfo, Services, UserName, GitSetting, CheckerSetting, ApacheMetrics, WafNginx, ServiceStatus,
KeepaliveRestart, PD, SmonHistory, SmonAgent, SmonTcpCheck, SmonHttpCheck, SmonPingCheck, SmonDnsCheck, S3Backup, RoxyTool,
SmonStatusPage, SmonStatusPageCheck, HaCluster, HaClusterSlave, HaClusterVip, HaClusterVirt, HaClusterService,
HaClusterRouter]
HaClusterRouter, MM]
)

View File

@ -212,11 +212,11 @@ def select_one_smon(smon_id: int, check_id: int) -> tuple:
return query_res
def insert_smon(name, enable, group, desc, telegram, slack, pd, user_group, check_type):
def insert_smon(name, enable, group, desc, telegram, slack, pd, mm, user_group, check_type):
try:
last_id = SMON.insert(
name=name, en=enable, desc=desc, group=group, telegram_channel_id=telegram, slack_channel_id=slack,
pd_channel_id=pd, user_group=user_group, status='3', check_type=check_type
pd_channel_id=pd, mm_channel_id=mm, user_group=user_group, status='3', check_type=check_type
).execute()
except Exception as e:
out_error(e)
@ -512,9 +512,9 @@ def select_smon_history(smon_id: int) -> object:
return query_res
def update_smon(smon_id, name, telegram, slack, pd, group, desc, en):
def update_smon(smon_id, name, telegram, slack, pd, mm, group, desc, en):
query = (SMON.update(
name=name, telegram_channel_id=telegram, slack_channel_id=slack, pd_channel_id=pd, group=group, desc=desc, en=en
name=name, telegram_channel_id=telegram, slack_channel_id=slack, pd_channel_id=pd, mm_channel_id=mm, group=group, desc=desc, en=en
).where(SMON.id == smon_id))
try:
query.execute()

View File

@ -1,6 +1,7 @@
import json
import pika
import requests
from flask import render_template, request, abort
import app.modules.db.sql as sql
@ -69,6 +70,10 @@ def alert_routing(
pd_send_mess(mes, level, server_ip, service_id, alert_type, channel_id=setting.pd_id)
except Exception as e:
roxywi_common.logging('Roxy-WI server', f'error: unable to send message to PagerDuty: {e}', roxywi=1)
try:
mm_send_mess(mes, level, server_ip, service_id, alert_type, channel_id=setting.mm_id)
except Exception as e:
roxywi_common.logging('Roxy-WI server', f'error: unable to send message to Mattermost: {e}', roxywi=1)
if setting.email:
send_email_to_server_group(subject, mes, level, group_id)
@ -86,6 +91,10 @@ def alert_routing(
pd_send_mess(mes, level, server_ip, service_id, alert_type, channel_id=setting.pd_id)
except Exception as e:
roxywi_common.logging('Roxy-WI server', f'error: unable to send message to PagerDuty: {e}', roxywi=1)
try:
mm_send_mess(mes, level, server_ip, service_id, alert_type, channel_id=setting.mm_id)
except Exception as e:
roxywi_common.logging('Roxy-WI server', f'error: unable to send message to Mattermost: {e}', roxywi=1)
if setting.email:
send_email_to_server_group(subject, mes, level, group_id)
@ -103,6 +112,10 @@ def alert_routing(
pd_send_mess(mes, level, server_ip, service_id, alert_type, channel_id=setting.pd_id)
except Exception as e:
roxywi_common.logging('Roxy-WI server', f'error: unable to send message to PagerDuty: {e}', roxywi=1)
try:
mm_send_mess(mes, level, server_ip, service_id, alert_type, channel_id=setting.mm_id)
except Exception as e:
roxywi_common.logging('Roxy-WI server', f'error: unable to send message to Mattermost: {e}', roxywi=1)
if setting.email:
send_email_to_server_group(subject, mes, level, group_id)
@ -263,6 +276,74 @@ def pd_send_mess(mess, level, server_ip=None, service_id=None, alert_type=None,
raise Exception(f'error: {e}')
def mm_send_mess(mess, level, server_ip=None, service_id=None, alert_type=None, **kwargs):
print('send mess to mm', kwargs.get('channel_id'))
token = ''
if kwargs.get('channel_id') == 0:
return
if kwargs.get('channel_id'):
try:
mms = channel_sql.get_mm_by_id(kwargs.get('channel_id'))
except Exception as e:
print(e)
else:
try:
mms = channel_sql.get_mm_by_ip(kwargs.get('ip'))
except Exception as e:
print(e)
for pd in mms:
token = pd.token
channel = pd.chanel_name
# try:
# proxy = sql.get_setting('proxy')
# session = pdpyras.EventsAPISession(token)
# dedup_key = f'{server_ip} {service_id} {alert_type}'
# except Exception as e:
# roxywi_common.logging('Roxy-WI server', str(e), roxywi=1)
# raise Exception(f'error: {e}')
#
# if proxy is not None and proxy != '' and proxy != 'None':
# proxies = dict(https=proxy, http=proxy)
# session.proxies.update(proxies)
headers = {'Content-Type': 'application/json'}
if level == "info":
color = "51A347"
else:
color = "c20707"
attach = {
"fallback": f"{alert_type}",
"color": f"#{color}",
"text": f"{mess}",
"author_name": "Roxy-WI",
"title": f"{level} alert",
"fields": [
{
"short": "true",
"title": "Level",
"value": f"{level}",
},
{
"short": "true",
"title": "Server",
"value": f"{server_ip}",
},
]
}
attach = str(json.dumps(attach))
values = f'{{"channel": "{channel}", "username": "Roxy-WI", "attachments": [{attach}]}}'
try:
requests.post(token, headers=headers, data=str(values))
return 'ok'
except Exception as e:
roxywi_common.logging('Roxy-WI server', str(e), roxywi=1)
raise Exception(f'error: {e}')
def check_rabbit_alert() -> str:
try:
user_group_id = request.cookies.get('group')
@ -331,12 +412,24 @@ def add_pd_channel(token: str, channel: str, group: str, page: str) -> str:
else:
if channel_sql.insert_new_pd(token, channel, group):
lang = roxywi_common.get_user_lang_for_flask()
channels = channel_sql.select_slack(token=token)
channels = channel_sql.select_pd(token=token)
groups = group_sql.select_groups()
roxywi_common.logging('Roxy-WI server', f'A new PagerDuty channel {channel} has been created ', roxywi=1, login=1)
return render_template('ajax/new_receiver.html', groups=groups, lang=lang, channels=channels, page=page, receiver='pd')
def add_mm_channel(token: str, channel: str, group: str, page: str) -> str:
if token is None or channel is None or group is None:
return error_mess
else:
if channel_sql.insert_new_mm(token, channel, group):
lang = roxywi_common.get_user_lang_for_flask()
channels = channel_sql.select_mm(token=token)
groups = group_sql.select_groups()
roxywi_common.logging('Roxy-WI server', f'A new Mattermost channel {channel} has been created ', roxywi=1, login=1)
return render_template('ajax/new_receiver.html', groups=groups, lang=lang, channels=channels, page=page, receiver='mm')
def delete_telegram_channel(channel_id) -> str:
telegram = channel_sql.select_telegram(id=channel_id)
channel_name = ''
@ -367,6 +460,16 @@ def delete_pd_channel(channel_id) -> str:
return 'ok'
def delete_mm_channel(channel_id) -> str:
pd = channel_sql.select_mm(id=channel_id)
channel_name = ''
for t in pd:
channel_name = t.chanel_name
if channel_sql.delete_mm(channel_id):
roxywi_common.logging('Roxy-WI server', f'The Mattermost channel {channel_name} has been deleted ', roxywi=1, login=1)
return 'ok'
def update_telegram(token: str, channel: str, group: str, user_id: int) -> str:
channel_sql.update_telegram(token, channel, group, user_id)
roxywi_common.logging('group ' + group, f'The Telegram token has been updated for channel: {channel}', roxywi=1, login=1)
@ -385,11 +488,18 @@ def update_pd(token: str, channel: str, group: str, user_id: int) -> str:
return 'ok'
def update_mm(token: str, channel: str, group: str, user_id: int) -> str:
channel_sql.update_mm(token, channel, group, user_id)
roxywi_common.logging(f'group {group}', f'The Mattermost token has been updated for channel: {channel}', roxywi=1, login=1)
return 'ok'
def delete_receiver_channel(channel_id: int, receiver_name: str) -> None:
delete_functions = {
"telegram": delete_telegram_channel,
"slack": delete_slack_channel,
"pd": delete_pd_channel,
"mm": delete_mm_channel,
}
return delete_functions[receiver_name](channel_id)
@ -399,6 +509,7 @@ def add_receiver_channel(receiver_name: str, token: str, channel: str, group: id
"telegram": add_telegram_channel,
"slack": add_slack_channel,
"pd": add_pd_channel,
"mm": add_mm_channel,
}
try:
@ -412,6 +523,7 @@ def update_receiver_channel(receiver_name: str, token: str, channel: str, group:
"telegram": update_telegram,
"slack": update_slack,
"pd": update_pd,
"mm": update_mm,
}
return update_functions[receiver_name](token, channel, group, user_id)
@ -421,6 +533,7 @@ def check_receiver(channel_id: int, receiver_name: str) -> str:
"telegram": telegram_send_mess,
"slack": slack_send_mess,
"pd": pd_send_mess,
"mm": mm_send_mess,
}
mess = 'Test message from Roxy-WI'
@ -457,6 +570,7 @@ def load_channels():
user_group = roxywi_common.get_user_group(id=1)
kwargs.setdefault('telegrams', channel_sql.get_user_telegram_by_group(user_group))
kwargs.setdefault('pds', channel_sql.get_user_pd_by_group(user_group))
kwargs.setdefault('mms', channel_sql.get_user_mm_by_group(user_group))
kwargs.setdefault('groups', group_sql.select_groups())
kwargs.setdefault('slacks', channel_sql.get_user_slack_by_group(user_group))
kwargs.setdefault('user_subscription', user_subscription)

View File

@ -30,6 +30,7 @@ def load_checker() -> str:
kwargs.setdefault('services', tools_common.get_services_status())
kwargs.setdefault('telegrams', channel_sql.get_user_telegram_by_group(user_group))
kwargs.setdefault('pds', channel_sql.get_user_pd_by_group(user_group))
kwargs.setdefault('mms', channel_sql.get_user_mm_by_group(user_group))
kwargs.setdefault('groups', group_sql.select_groups())
kwargs.setdefault('slacks', channel_sql.get_user_slack_by_group(user_group))
kwargs.setdefault('haproxy_servers', roxywi_common.get_dick_permit(haproxy=1, only_group=1))
@ -47,24 +48,24 @@ def load_checker() -> str:
return render_template('ajax/load_checker.html', **kwargs)
def update_haproxy_settings(setting_id, email, service_alert, backend_alert, maxconn_alert, telegram_id, slack_id, pd_id) -> str:
if checker_sql.update_haproxy_checker_settings(email, telegram_id, slack_id, pd_id, service_alert, backend_alert,
def update_haproxy_settings(setting_id, email, service_alert, backend_alert, maxconn_alert, telegram_id, slack_id, pd_id, mm_id) -> str:
if checker_sql.update_haproxy_checker_settings(email, telegram_id, slack_id, pd_id, mm_id, service_alert, backend_alert,
maxconn_alert, setting_id):
return 'ok'
else:
return 'error: Cannot update Checker settings'
def update_keepalived_settings(setting_id, email, service_alert, backend_alert, telegram_id, slack_id, pd_id) -> str:
if checker_sql.update_keepalived_checker_settings(email, telegram_id, slack_id, pd_id, service_alert, backend_alert,
def update_keepalived_settings(setting_id, email, service_alert, backend_alert, telegram_id, slack_id, pd_id, mm_id) -> str:
if checker_sql.update_keepalived_checker_settings(email, telegram_id, slack_id, pd_id, mm_id, service_alert, backend_alert,
setting_id):
return 'ok'
else:
return 'error: Cannot update Checker settings'
def update_service_settings(setting_id, email, service_alert, telegram_id, slack_id, pd_id) -> str:
if checker_sql.update_service_checker_settings(email, telegram_id, slack_id, pd_id, service_alert, setting_id):
def update_service_settings(setting_id, email, service_alert, telegram_id, slack_id, pd_id, mm_id) -> str:
if checker_sql.update_service_checker_settings(email, telegram_id, slack_id, pd_id, mm_id, service_alert, setting_id):
return 'ok'
else:
return 'error: Cannot update Checker settings'

View File

@ -2,6 +2,7 @@ from flask import render_template, abort
import app.modules.db.smon as smon_sql
import app.modules.common.common as common
import app.modules.server.server as server_mod
import app.modules.tools.smon_agent as smon_agent
import app.modules.roxywi.common as roxywi_common
@ -19,6 +20,7 @@ def create_smon(json_data, user_group, show_new=1) -> bool:
telegram = common.checkAjaxInput(json_data['tg'])
slack = common.checkAjaxInput(json_data['slack'])
pd = common.checkAjaxInput(json_data['pd'])
mm = common.checkAjaxInput(json_data['mm'])
resolver = common.checkAjaxInput(json_data['resolver'])
record_type = common.checkAjaxInput(json_data['record_type'])
packet_size = common.checkAjaxInput(json_data['packet_size'])
@ -46,7 +48,7 @@ def create_smon(json_data, user_group, show_new=1) -> bool:
if int(packet_size) < 16:
raise Exception('SMON error: a packet size cannot be less than 16')
last_id = smon_sql.insert_smon(name, enable, group, desc, telegram, slack, pd, user_group, check_type)
last_id = smon_sql.insert_smon(name, enable, group, desc, telegram, slack, pd, mm, user_group, check_type)
if check_type == 'ping':
smon_sql.insert_smon_ping(last_id, hostname, packet_size, interval, agent_id)
@ -85,6 +87,7 @@ def update_smon(smon_id, json_data) -> str:
telegram = common.checkAjaxInput(json_data['tg'])
slack = common.checkAjaxInput(json_data['slack'])
pd = common.checkAjaxInput(json_data['pd'])
mm = common.checkAjaxInput(json_data['mm'])
resolver = common.checkAjaxInput(json_data['resolver'])
record_type = common.checkAjaxInput(json_data['record_type'])
packet_size = common.checkAjaxInput(json_data['packet_size'])
@ -117,7 +120,7 @@ def update_smon(smon_id, json_data) -> str:
return f'{e}'
try:
if smon_sql.update_smon(smon_id, name, telegram, slack, pd, group, desc, enabled):
if smon_sql.update_smon(smon_id, name, telegram, slack, pd, mm, group, desc, enabled):
if check_type == 'http':
is_edited = smon_sql.update_smonHttp(smon_id, url, body, http_method, interval, agent_id)
elif check_type == 'tcp':
@ -300,3 +303,10 @@ def avg_status_page_status(page_id: int) -> str:
return '0'
return '1'
def change_smon_port(new_port: int) -> None:
cmd = f"sudo sed -i 's/\(^ExecStart.*$\)/ExecStart=gunicorn --workers 1 --bind 0.0.0.0:{new_port} -m 007 smon:app/' /etc/systemd/system/roxy-wi-smon.service"
server_mod.subprocess_execute(cmd)
cmd = 'sudo systemctl daemon-reload && sudo systemctl restart roxy-wi-smon'
server_mod.subprocess_execute(cmd)

View File

@ -76,12 +76,22 @@ def update_agent(json_data):
name = common.checkAjaxInput(json_data.get("name"))
desc = common.checkAjaxInput(json_data.get("desc"))
enabled = int(json_data.get("enabled"))
reconfigure = int(json_data.get("reconfigure"))
try:
smon_sql.update_agent(agent_id, name, desc, enabled)
except Exception as e:
roxywi_common.handle_exceptions(e, 'Roxy-WI server', f'Cannot update SMON agent: {agent_id}', roxywi=1, login=1)
if reconfigure:
agent_uuid = smon_sql.get_agent_uuid(agent_id)
server_ip = smon_sql.select_server_ip_by_agent_id(agent_id)
try:
inv, server_ips = generate_agent_inc(server_ip, 'install', agent_uuid)
run_ansible(inv, server_ips, 'smon_agent')
except Exception as e:
roxywi_common.handle_exceptions(e, server_ip, 'Cannot reconfigure SMON agent', roxywi=1, login=1)
def get_agent_headers(agent_id: int) -> dict:
try:

View File

@ -19,6 +19,7 @@ import app.modules.roxywi.roxy as roxy
import app.modules.roxywi.auth as roxywi_auth
import app.modules.roxywi.common as roxywi_common
import app.modules.server.server as server_mod
import app.modules.tools.smon as smon_mod
import app.modules.tools.common as tools_common
@ -210,4 +211,10 @@ def update_settings(param):
if sql.update_setting(param, val, user_group):
roxywi_common.logging('Roxy-WI server', f'The {param} setting has been changed to: {val}', roxywi=1, login=1)
if param == 'master_port':
try:
smon_mod.change_smon_port(val)
except Exception as e:
return f'{e}'
return 'Ok'

View File

@ -32,18 +32,19 @@ def update_settings():
telegram_id = int(request.form.get('telegram_id'))
slack_id = int(request.form.get('slack_id'))
pd_id = int(request.form.get('pd_id'))
mm_id = int(request.form.get('mm_id'))
if service == 'haproxy':
maxconn_alert = int(request.form.get('maxconn'))
backend_alert = int(request.form.get('backend'))
return checker_mod.update_haproxy_settings(
setting_id, email, service_alert, backend_alert, maxconn_alert, telegram_id, slack_id, pd_id
setting_id, email, service_alert, backend_alert, maxconn_alert, telegram_id, slack_id, pd_id, mm_id
)
elif service in ('nginx', 'apache'):
return checker_mod.update_service_settings(setting_id, email, service_alert, telegram_id, slack_id, pd_id)
return checker_mod.update_service_settings(setting_id, email, service_alert, telegram_id, slack_id, pd_id, mm_id)
else:
backend_alert = int(request.form.get('backend'))
return checker_mod.update_keepalived_settings(setting_id, email, service_alert, backend_alert, telegram_id, slack_id, pd_id)
return checker_mod.update_keepalived_settings(setting_id, email, service_alert, backend_alert, telegram_id, slack_id, pd_id, mm_id)
@bp.route('/settings/load')

View File

@ -37,8 +37,9 @@ def smon_main_dashboard():
'smon_status': tools_common.is_tool_active('roxy-wi-smon'),
'user_subscription': roxywi_common.return_user_subscription(),
'telegrams': channel_sql.get_user_telegram_by_group(group_id),
'slacks': channel_sql.get_user_pd_by_group(group_id),
'pds': channel_sql.get_user_slack_by_group(group_id),
'slacks': channel_sql.get_user_slack_by_group(group_id),
'pds': channel_sql.get_user_pd_by_group(group_id),
'mms': channel_sql.get_user_mm_by_group(group_id),
'sort': request.args.get('sort', None)
}
@ -166,6 +167,7 @@ def check(smon_id, check_type_id):
'tg': s.smon_id.telegram_channel_id,
'slack': s.smon_id.slack_channel_id,
'pd': s.smon_id.pd_channel_id,
'mm': s.smon_id.mm_channel_id,
'check_type': s.smon_id.check_type,
'group': s.smon_id.group,
}

View File

@ -14,6 +14,9 @@ $( function() {
$('#add-pd-button').click(function() {
addPDDialog.dialog('open');
});
$('#add-mm-button').click(function() {
addMMDialog.dialog('open');
});
var telegram_tabel_title = $( "#telegram-add-table-overview" ).attr('title');
var addTelegramDialog = $( "#telegram-add-table" ).dialog({
autoOpen: false,
@ -101,6 +104,35 @@ $( function() {
}
}]
});
var mm_tabel_title = $( "#mm-add-table-overview" ).attr('title');
var addMMDialog = $( "#mm-add-table" ).dialog({
autoOpen: false,
resizable: false,
height: "auto",
width: 600,
modal: true,
title: mm_tabel_title,
show: {
effect: "fade",
duration: 200
},
hide: {
effect: "fade",
duration: 200
},
buttons: [{
text: add_word,
click: function () {
addRecevier(this, 'mm');
}
}, {
text: cancel_word,
click: function () {
$(this).dialog("close");
clearTips();
}
}]
});
$( "#checker_telegram_table input" ).change(function() {
var id = $(this).attr('id').split('-');
updateReceiver(id[2], 'telegram')

View File

@ -157,7 +157,59 @@
</tr>
{% endfor %}
</table>
<br /><span class="add-button" title="{{lang.words.add|title()}} PagerDuty {{lang.words.channel|title()}}" id="add-pd-button">+ {{lang.words.add|title()}}</span>
<br /><span class="add-button" title="{{lang.words.add|title()}} PagerDuty {{lang.words.channel}}" id="add-pd-button">+ {{lang.words.add|title()}}</span>
<br /><br />
<table id="checker_mm_table" class="overview-overflow">
<caption><i class="fas fa-power-off caption-icon"></i><h3>Mattermost {{lang.words.channels|title()}}</h3></caption>
<tr class="overviewHead" style="width: 50%;">
<td class="padding10 first-collumn" style="width: 25%;">
{{lang.words.key|title()}}
</td>
<td style="width: 20%;">{{lang.words.name|title()}}</td>
{% if user_params['role']|int() == 1 %}
<td style="width: 25%;">{{lang.words.group|title()}}</td>
{% endif %}
<td style="width: 100%;"></td>
<td></td>
<td><span onclick="loadChannel()" class="refresh" title="{{lang.words.refresh2|title()}} Mattermost {{lang.words.channels}}"></span></td>
</tr>
{% for mm in mms %}
<tr id="mm-table-{{mm.id}}" class="{{ loop.cycle('odd', 'even') }}">
<td class="padding10 first-collumn">
{% set id = 'mm-token-' + mm.id|string() %}
{{ input(id, value=mm.token, size='30') }}
</td>
<td>
{% set id = 'mm-chanel-' + mm.id|string() %}
{{ input(id, value=mm.chanel_name, size='30') }}
</td>
{% if user_params['role']|int() == 1 %}
<td>
<select id="pdgroup-{{mm.id}}" name="pdgroup-{{mm.id}}">
<option disabled selected>------</option>
{% for group in groups %}
{% if mm.groups|string() == group.group_id|string() %}
<option value="{{ group.group_id }}" selected>{{ group.name }}</option>
{% else %}
<option value="{{ group.group_id }}">{{ group.name }}</option>
{% endif %}
{% endfor %}
</select>
</td>
{% endif %}
<td>
<button title="{{lang.phrases.send_test_mes}}" onclick="checkReceiver({{mm.id}}, 'mm')">{{lang.words.test|title()}}</button>
</td>
<td>
<a class="add" onclick="cloneReceiver({{mm.id}}, 'mm')" id="clone-{{mm.id}}" title="{{lang.words.w_copy|title()}} {{lang.words.the}} {{lang.words.settings}} {{mm.chanel_name}}" style="cursor: pointer;"></a>
</td>
<td>
<a class="delete" onclick="confirmDeleteReceiver({{mm.id}}, 'mm')" title="{{lang.words.delete|title()}} {{lang.words.channel}} {{mm.chanel_name}}" style="cursor: pointer;"></a>
</td>
</tr>
{% endfor %}
</table>
<br /><span class="add-button" title="{{lang.words.add|title()}} Mattermost {{lang.words.channel}}" id="add-mm-button">+ {{lang.words.add|title()}}</span>
<br /><br />
<table class="overflow">
<caption><i class="fas fa-envelope-open-text caption-icon"></i><h3>{{lang.words.test2|title()}} {{lang.words.message}}</h3></caption>

View File

@ -26,9 +26,10 @@
<caption><i class="fas fa-network-wired caption-icon"></i><h3>HAProxy {{lang.words.servers}}</h3></caption>
<tr class="overviewHead">
<td class="padding10 first-collumn">{{lang.words.server|title()}}</td>
<td class="first-collumn" title="{{lang.words.alert|title()}} {{lang.words.via}} Telegram" style="width: 15%;">Telegram</td>
<td class="first-collumn" title="{{lang.words.alert|title()}} {{lang.words.via}} Slack" style="width: 15%;">Slack</td>
<td class="first-collumn" title="{{lang.words.alert|title()}} {{lang.words.via}} PagerDuty" style="width: 15%;">PagerDuty</td>
<td class="first-collumn" title="{{lang.words.alert|title()}} {{lang.words.via}} Telegram" style="width: 10%;">Telegram</td>
<td class="first-collumn" title="{{lang.words.alert|title()}} {{lang.words.via}} Slack" style="width: 10%;">Slack</td>
<td class="first-collumn" title="{{lang.words.alert|title()}} {{lang.words.via}} PagerDuty" style="width: 10%;">PagerDuty</td>
<td class="first-collumn" title="{{lang.words.alert|title()}} {{lang.words.via}} Mattermost" style="width: 10%;">Mattermost</td>
<td class="checkbox-head" style="width: 10%;" title="{{lang.words.alert|title()}} {{lang.words.via}} {{lang.words.email}}">{{lang.words.email|title()}}</td>
<td class="checkbox-head" style="width: 10%;" title="{{lang.phrases.alert_service_change_status}}">{{lang.words.service|title()}}</td>
<td class="checkbox-head" style="width: 10%;" title="{{lang.phrases.alert_backend_change_status}}">{{lang.words.backend|title()}}</td>
@ -76,6 +77,18 @@
{% endfor %}
</select>
</td>
<td id="haproxy_server_mm-{{s.0}}" title="{{lang.words.alert|title()}} {{lang.words.via}} {{lang.words.this3}} {{lang.words.channel}}">
<select id="haproxy_server_mm_channel-{{h.id}}">
<option value="0">{{lang.words.disabled|title()}}</option>
{% for t in mms %}
{% if h.mm_id|int() == t.id|int() %}
<option value="{{t.id}}" selected>{{t.chanel_name}}</option>
{% else %}
<option value="{{t.id}}">{{t.chanel_name}}</option>
{% endif %}
{% endfor %}
</select>
</td>
<td class="checkbox" title="{{lang.words.alert|title()}} {{lang.words.via}} {{lang.words.email}}">
{% set id = 'haproxy_server_email-' + h.id|string() %}
{% if h.email == 1 %}
@ -118,9 +131,10 @@
<caption><i class="fas fa-sitemap caption-icon"></i><h3>NGINX {{lang.words.servers}}</h3></caption>
<tr class="overviewHead">
<td class="padding10 first-collumn">{{lang.words.server|title()}}</td>
<td class="first-collumn" title="{{lang.words.alert|title()}} {{lang.words.via}} Telegram" style="width: 15%;">Telegram</td>
<td class="first-collumn" title="{{lang.words.alert|title()}} {{lang.words.via}} Slack" style="width: 15%;">Slack</td>
<td class="first-collumn" title="{{lang.words.alert|title()}} {{lang.words.via}} PagerDuty" style="width: 15%;">PagerDuty</td>
<td class="first-collumn" title="{{lang.words.alert|title()}} {{lang.words.via}} Telegram" style="width: 10%;">Telegram</td>
<td class="first-collumn" title="{{lang.words.alert|title()}} {{lang.words.via}} Slack" style="width: 10%;">Slack</td>
<td class="first-collumn" title="{{lang.words.alert|title()}} {{lang.words.via}} PagerDuty" style="width: 10%;">PagerDuty</td>
<td class="first-collumn" title="{{lang.words.alert|title()}} {{lang.words.via}} Mattermost" style="width: 10%;">Mattermost</td>
<td class="checkbox-head" style="width: 10%;" title="{{lang.words.alert|title()}} {{lang.words.via}} {{lang.words.email}}">{{lang.words.email|title()}}</td>
<td class="checkbox-head" style="width: 100%;" title={{lang.phrases.alert_service_change_status}}>{{lang.words.service|title()}}</td>
<td><span onclick="loadchecker(1)" class="refresh" title="{{lang.words.refresh2|title()}}"></span></td>
@ -166,6 +180,18 @@
{% endfor %}
</select>
</td>
<td id="nginx_server_mm-{{h.id}}" title="{{lang.words.alert|title()}} {{lang.words.via}} {{lang.words.this3}} {{lang.words.channel}}">
<select id="nginx_server_mm_channel-{{h.id}}">
<option value="0">{{lang.words.disabled|title()}}</option>
{% for t in mms %}
{% if h.mm_id|int() == t.id|int() %}
<option value="{{t.id}}" selected>{{t.chanel_name}}</option>
{% else %}
<option value="{{t.id}}">{{t.chanel_name}}</option>
{% endif %}
{% endfor %}
</select>
</td>
<td class="checkbox">
{% set id = 'nginx_server_email-' + h.id|string() %}
{% if h.email == 1 %}
@ -192,9 +218,10 @@
<caption><i class="fas fa-feather-alt caption-icon"></i><h3>Apache {{lang.words.servers}}</h3></caption>
<tr class="overviewHead">
<td class="padding10 first-collumn">{{lang.words.server|title()}}</td>
<td class="first-collumn" title="{{lang.words.alert|title()}} {{lang.words.via}} Telegram" style="width: 15%;">Telegram</td>
<td class="first-collumn" title="{{lang.words.alert|title()}} {{lang.words.via}} Slack" style="width: 15%;">Slack</td>
<td class="first-collumn" title="{{lang.words.alert|title()}} {{lang.words.via}} PagerDuty" style="width: 15%;">PagerDuty</td>
<td class="first-collumn" title="{{lang.words.alert|title()}} {{lang.words.via}} Telegram" style="width: 10%;">Telegram</td>
<td class="first-collumn" title="{{lang.words.alert|title()}} {{lang.words.via}} Slack" style="width: 10%;">Slack</td>
<td class="first-collumn" title="{{lang.words.alert|title()}} {{lang.words.via}} PagerDuty" style="width: 10%;">PagerDuty</td>
<td class="first-collumn" title="{{lang.words.alert|title()}} {{lang.words.via}} Mattermost" style="width: 10%;">Mattermost</td>
<td class="checkbox-head" style="width: 10%;">{{lang.words.email|title()}}</td>
<td class="checkbox-head" style="width: 100%;" title="{{lang.phrases.alert_service_change_status}}">{{lang.words.service|title()}}</td>
<td><span onclick="loadchecker(1)" class="refresh" title="{{lang.words.refresh2|title()}}"></span></td>
@ -240,6 +267,18 @@
{% endfor %}
</select>
</td>
<td id="apache_server_mm-{{h.id}}" title="{{lang.words.alert|title()}} {{lang.words.via}} {{lang.words.this3}} {{lang.words.channel}}">
<select id="apache_server_mm_channel-{{h.id}}">
<option value="0">{{lang.words.disabled|title()}}</option>
{% for t in mms %}
{% if h.mm_id|int() == t.id|int() %}
<option value="{{t.id}}" selected>{{t.chanel_name}}</option>
{% else %}
<option value="{{t.id}}">{{t.chanel_name}}</option>
{% endif %}
{% endfor %}
</select>
</td>
<td class="checkbox">
{% set id = 'apache_server_email-' + h.id|string() %}
{% if h.email == 1 %}
@ -266,9 +305,10 @@
<caption><i class="fas fa-cloud caption-icon"></i><h3>Keepalived {{lang.words.servers}}</h3></caption>
<tr class="overviewHead">
<td class="padding10 first-collumn">{{lang.words.server|title()}}</td>
<td class="first-collumn" title="{{lang.words.alert|title()}} {{lang.words.via}} Telegram" style="width: 15%;">Telegram</td>
<td class="first-collumn" title="{{lang.words.alert|title()}} {{lang.words.via}} Slack" style="width: 15%;">Slack</td>
<td class="first-collumn" title="{{lang.words.alert|title()}} {{lang.words.via}} PagerDuty" style="width: 15%;">PagerDuty</td>
<td class="first-collumn" title="{{lang.words.alert|title()}} {{lang.words.via}} Telegram" style="width: 10%;">Telegram</td>
<td class="first-collumn" title="{{lang.words.alert|title()}} {{lang.words.via}} Slack" style="width: 10%;">Slack</td>
<td class="first-collumn" title="{{lang.words.alert|title()}} {{lang.words.via}} PagerDuty" style="width: 10%;">PagerDuty</td>
<td class="first-collumn" title="{{lang.words.alert|title()}} {{lang.words.via}} Mattermost" style="width: 10%;">Mattermost</td>
<td class="checkbox-head" style="width: 10%;">{{lang.words.email|title()}}</td>
<td class="checkbox-head" style="width: 10%;" title="{{lang.phrases.alert_service_change_status}}">{{lang.words.service|title()}}</td>
<td class="checkbox-head" style="width: 100%;" title="{{lang.phrases.alert_master_backup}}">{{lang.words.status|title()}}</td>
@ -315,6 +355,18 @@
{% endfor %}
</select>
</td>
<td id="keepalived_server_mm-{{h.id}}" title="{{lang.words.alert|title()}} {{lang.words.via}} {{lang.words.this3}} {{lang.words.channel}}">
<select id="keepalived_server_mm_channel-{{h.id}}">
<option value="0">{{lang.words.disabled|title()}}</option>
{% for t in mms %}
{% if h.mm_id|int() == t.id|int() %}
<option value="{{t.id}}" selected>{{t.chanel_name}}</option>
{% else %}
<option value="{{t.id}}">{{t.chanel_name}}</option>
{% endif %}
{% endfor %}
</select>
</td>
<td class="checkbox">
{% set id = 'keepalived_server_email-' + h.id|string() %}
{% if h.email == 1 %}

View File

@ -19,7 +19,7 @@
data-raw="{{lang.words.raw|title()}}" data-resp_time="{{lang.smon_page.desc.resp_time}}" data-next="{{lang.words.next|title()}}" data-back="{{lang.words.back|title()}}"
data-installing="{{lang.words.installing|title()}}" data-creating="{{lang.words.creating|title()}}" data-roxywi_timeout="{{lang.ha_page.roxywi_timeout}}"
data-check_apache_log="{{lang.ha_page.check_apache_log}}" data-was_installed="{{lang.ha_page.was_installed}}" data-start_enter="{{lang.ha_page.start_enter}}"
data-apply="{{lang.words.apply|title()}}" />
data-apply="{{lang.words.apply|title()}}" data-reconfigure="{{lang.words.reconfigure|title()}}" />
{% include 'include/main_head.html' %}
</head>
<body>

View File

@ -47,8 +47,8 @@
{% else %}
{{ input(set.param, size='25', type='password', style='width: 210px;', placeholder='******') }}
{% endif %}
{% elif set.param in ('nginx_stats_port', 'session_ttl', 'token_ttl', 'haproxy_stats_port', 'haproxy_sock_port',
'ldap_port', 'log_time_storage', 'checker_check_interval', 'port_scan_interval', 'smon_keep_history_range',
{% elif set.param in ('nginx_stats_port', 'session_ttl', 'token_ttl', 'haproxy_stats_port', 'haproxy_sock_port', 'master_port',
'ldap_port', 'log_time_storage', 'checker_check_interval', 'port_scan_interval', 'smon_keep_history_range', 'agent_port',
'checker_keep_history_range', 'portscanner_keep_history_range', 'checker_maxconn_threshold', 'apache_stats_port',
'mail_smtp_port', 'rabbitmq_port', 'smon_ssl_expire_warning_alert', 'smon_ssl_expire_critical_alert', 'action_keep_history_range') %}
{{ input(set.param, value=set.value, style='width: 210px;', type='number') }}

View File

@ -261,6 +261,42 @@
{% endif %}
</table>
</div>
<div id="mm-add-table" style="display: none;">
<table class="overview" id="mm-add-table-overview" title="{{lang.words.add|title()}} {{lang.words.w_a}} {{lang.words.new}} Mattermost {{lang.words.channel}}">
{% include 'include/tr_validate_tips.html' %}
<tr>
<td class="padding20">
<span title="Incoming Webhook">{{lang.words.token|title()}}</span>
<span class="need-field">*</span>
</td>
<td>
{{ input('mm-token-add', size='30') }}
</td>
</tr>
<tr>
<td class="padding20">
{{lang.words.channel|title()}}
<span class="need-field">*</span>
</td>
<td>
{{ input('mm-chanel-add') }}
</td>
</tr>
{% if g.user_params['role'] == 1 %}
<tr>
<td class="padding20">{{lang.words.group|title()}}</td>
<td>
<select id="new-mm-group-add" name="new-mm-group-add">
<option disabled selected value="0">{{lang.words.select|title()}} {{lang.words.w_a}} {{lang.words.group2}}</option>
{% for group in groups %}
<option value="{{ group.group_id }}">{{ group.name }}</option>
{% endfor %}
</select>
</td>
</tr>
{% endif %}
</table>
</div>
<div id="backup-add-table" title="Add a new backup job " style="display: none;">
<table class="overview" id="backup-add-table-overview" title="{{lang.words.add|title()}} {{lang.words.w_a}} {{lang.words.new}} {{lang.words.backup}}">
{% include 'include/tr_validate_tips.html' %}

View File

@ -149,6 +149,17 @@
</select>
</td>
</tr>
<tr>
<td class="padding20">Mattermost</td>
<td>
<select id="new-smon-mm">
<option value="0">{{lang.words.disabled|title()}}</option>
{% for t in mms %}
<option value="{{t.id}}">{{t.chanel_name}}</option>
{% endfor %}
</select>
</td>
</tr>
<tr>
<td class="padding20">{{lang.words.group|title()}}</td>
<td>{{ input('new-smon-group') }}</td>

View File

@ -927,5 +927,6 @@
"next": "next",
"agent": "agent",
"agent2": "agent",
"reconfigure": "reconfigure",
}
%}

View File

@ -927,5 +927,6 @@
"next": "suivante",
"agent": "agent",
"agent2": "agent",
"reconfigure": "reconfigurer",
}
%}

View File

@ -927,5 +927,6 @@
"next": "próxima",
"agent": "agente",
"agent2": "agente",
"reconfigure": "reconfigurar",
}
%}

View File

@ -927,5 +927,6 @@
"next": "дальше",
"agent": "агент",
"agent2": "агента",
"reconfigure": "переконфигурировать",
}
%}

View File

@ -96,6 +96,7 @@ function addNewSmonServer(dialog_id, smon_id=0, edit=false) {
'tg': $('#new-smon-telegram').val(),
'slack': $('#new-smon-slack').val(),
'pd': $('#new-smon-pd').val(),
'mm': $('#new-smon-mm').val(),
'packet_size': $('#new-smon-packet_size').val(),
'http_method': $('#new-smon-method').val(),
'check_type': check_type,
@ -244,9 +245,11 @@ function getCheckSettings(smon_id, check_type) {
$('#new-smon-telegram').val(data['tg']).change()
$('#new-smon-slack').val(data['slack']).change()
$('#new-smon-pd').val(data['pd']).change()
$('#new-smon-mm').val(data['mm']).change()
$('#new-smon-telegram').selectmenu("refresh");
$('#new-smon-slack').selectmenu("refresh");
$('#new-smon-pd').selectmenu("refresh");
$('#new-smon-mm').selectmenu("refresh");
$('#new-smon-agent-id').selectmenu("refresh");
if (data['enabled']) {
$('#new-smon-enable').prop('checked', true)
@ -687,15 +690,50 @@ function checkAgentLimit() {
function addAgentDialog(agent_id=0, edit=false) {
cleanAgentAddForm();
let tabel_title = $("#add-agent-page-overview").attr('title');
let buttons = [];
if (edit) {
add_word = $('#translate').attr('data-edit');
let reconfigure_word = $('#translate').attr('data-reconfigure');
tabel_title = $("#add-agent-page-overview").attr('data-edit');
getAgentSettings(agent_id);
buttons = [
{
text: reconfigure_word,
click: function () {
console.log('reconfigure');
addAgent($(this), agent_id, true, true);
}
}, {
text: add_word,
click: function () {
addAgent($(this), agent_id, true);
}
}, {
text: cancel_word,
click: function () {
$(this).dialog("close");
}
}
]
} else {
add_word = $('#translate').attr('data-add');
if (!checkAgentLimit()) {
return false;
}
getFreeServers();
buttons = [
{
text: add_word,
click: function () {
addAgent($(this));
}
}, {
text: cancel_word,
click: function () {
$(this).dialog("close");
}
}
]
}
let dialogTable = $("#add-agent-page").dialog({
autoOpen: false,
@ -712,25 +750,11 @@ function addAgentDialog(agent_id=0, edit=false) {
effect: "fade",
duration: 200
},
buttons: [{
text: add_word,
click: function () {
if (edit) {
addAgent($(this), agent_id, true);
} else {
addAgent($(this));
}
}
}, {
text: cancel_word,
click: function () {
$(this).dialog("close");
}
}]
buttons: buttons
});
dialogTable.dialog('open');
}
function addAgent(dialog_id, agent_id=0, edit=false) {
function addAgent(dialog_id, agent_id=0, edit=false, reconfigure=false) {
let valid = true;
allFields = $([]).add($('#new-agent-name'));
allFields.removeClass("ui-state-error");
@ -749,6 +773,9 @@ function addAgent(dialog_id, agent_id=0, edit=false) {
if (edit) {
method = 'PUT'
agent_data['agent_id'] = agent_id;
if (reconfigure) {
agent_data['reconfigure'] = "1";
}
}
if (valid) {
$.ajax({

View File

@ -1559,6 +1559,7 @@ function updateHaproxyCheckerSettings(id) {
telegram_id: $('#haproxy_server_telegram_channel-' + id + ' option:selected').val(),
slack_id: $('#haproxy_server_slack_channel-' + id + ' option:selected').val(),
pd_id: $('#haproxy_server_pd_channel-' + id + ' option:selected').val(),
mm_id: $('#haproxy_server_mm_channel-' + id + ' option:selected').val(),
token: $('#token').val()
},
type: "POST",
@ -1601,6 +1602,7 @@ function updateKeepalivedCheckerSettings(id) {
telegram_id: $('#keepalived_server_telegram_channel-' + id + ' option:selected').val(),
slack_id: $('#keepalived_server_slack_channel-' + id + ' option:selected').val(),
pd_id: $('#keepalived_server_pd_channel-' + id + ' option:selected').val(),
mm_id: $('#keepalived_server_mm_channel-' + id + ' option:selected').val(),
token: $('#token').val()
},
type: "POST",
@ -1638,6 +1640,7 @@ function updateServiceCheckerSettings(id, service_name) {
telegram_id: $('#' + service_name + '_server_telegram_channel-' + id + ' option:selected').val(),
slack_id: $('#' + service_name + '_server_slack_channel-' + id + ' option:selected').val(),
pd_id: $('#' + service_name + '_server_pd_channel-' + id + ' option:selected').val(),
mm_id: $('#' + service_name + '_server_mm_channel-' + id + ' option:selected').val(),
token: $('#token').val()
},
type: "POST",