Pavel Loginov 2021-05-02 09:58:22 +06:00
parent 0f02f84588
commit a9e45aff70
11 changed files with 300 additions and 144 deletions

View File

@ -43,10 +43,11 @@ def check_db():
else: else:
print(err) print(err)
print('</div>') print('</div>')
con.close()
return True return True
else: else:
return False
con.close() con.close()
return False
def get_cur(): def get_cur():
@ -204,7 +205,42 @@ def create_table(**kwargs):
`create_date` DATETIME default '0000-00-00 00:00:00', `create_date` DATETIME default '0000-00-00 00:00:00',
`expire_date` DATETIME default '0000-00-00 00:00:00' `expire_date` DATETIME default '0000-00-00 00:00:00'
); );
CREATE TABLE IF NOT EXISTS `slack` (`id` integer primary key autoincrement, `token` VARCHAR (64), `chanel_name` INTEGER NOT NULL DEFAULT 1, `groups` INTEGER NOT NULL DEFAULT 1); CREATE TABLE IF NOT EXISTS `metrics_http_status` (`serv` varchar(64), `2xx` INTEGER, `3xx` INTEGER, `4xx` INTEGER, `5xx` INTEGER,`date` timestamp default '0000-00-00 00:00:00');
CREATE TABLE IF NOT EXISTS `slack` (`id` INTEGER NOT NULL, `token` VARCHAR (64), `chanel_name` INTEGER NOT NULL DEFAULT 1, `groups` INTEGER NOT NULL DEFAULT 1, PRIMARY KEY(`id`));
CREATE TABLE IF NOT EXISTS `settings` (`param` varchar(64), value varchar(64), section varchar(64), `desc` varchar(100), `group` INTEGER NOT NULL DEFAULT 1, UNIQUE(param, `group`));
INSERT INTO settings (param, value, section, `desc`) values('time_zone', 'UTC', 'main', 'Time Zone');
INSERT INTO settings (param, value, section, `desc`) values('proxy', '', 'main', 'Proxy server. Use proto://ip:port');
INSERT INTO settings (param, value, section, `desc`) values('session_ttl', '5', 'main', 'Time to live users sessions. In days');
INSERT INTO settings (param, value, section, `desc`) values('token_ttl', '5', 'main', 'Time to live users tokens. In days');
INSERT INTO settings (param, value, section, `desc`) values('tmp_config_path', '/tmp/', 'main', 'A temp folder of configs, for checking. The path must exist');
INSERT INTO settings (param, value, section, `desc`) values('cert_path', '/etc/ssl/certs/', 'main', 'A path to SSL dir. The folder owner must be an user who set in the SSH settings. The path must exist');
INSERT INTO settings (param, value, section, `desc`) values('ssl_local_path', 'certs', 'main', 'Path to dir for local save SSL certs. This is a relative path, begins with $HOME_HAPROXY-WI/app/');
INSERT INTO settings (param, value, section, `desc`) values('lists_path', 'lists', 'main', 'Path to black/white lists. This is a relative path, begins with $HOME_HAPROXY-WI');
INSERT INTO settings (param, value, section, `desc`) values('local_path_logs', '/var/log/haproxy.log', 'logs', 'Logs save locally, enabled by default');
INSERT INTO settings (param, value, section, `desc`) values('syslog_server_enable', '0', 'logs', 'If exist syslog server for HAProxy logs, enable this option');
INSERT INTO settings (param, value, section, `desc`) values('syslog_server', '0', 'logs', 'IP address of syslog server');
INSERT INTO settings (param, value, section, `desc`) values('log_time_storage', '14', 'logs', 'Storage time for user activity logs, in days');
INSERT INTO settings (param, value, section, `desc`) values('stats_user', 'admin', 'haproxy', 'Username for the HAProxy Stats web page');
INSERT INTO settings (param, value, section, `desc`) values('stats_password', 'password', 'haproxy', 'Password for the HAProxy Stats web page');
INSERT INTO settings (param, value, section, `desc`) values('stats_port', '8085', 'haproxy', 'Port for the HAProxy Stats web page');
INSERT INTO settings (param, value, section, `desc`) values('stats_page', 'stats', 'haproxy', 'URI for the HAProxy Stats web page');
INSERT INTO settings (param, value, section, `desc`) values('haproxy_dir', '/etc/haproxy/', 'haproxy', 'Path to HAProxy dir');
INSERT INTO settings (param, value, section, `desc`) values('haproxy_config_path', '/etc/haproxy/haproxy.cfg', 'haproxy', 'Path to HAProxy config');
INSERT INTO settings (param, value, section, `desc`) values('server_state_file', '/etc/haproxy/haproxy.state', 'haproxy', 'Path to HAProxy state file');
INSERT INTO settings (param, value, section, `desc`) values('haproxy_sock', '/var/run/haproxy.sock', 'haproxy', 'Path to HAProxy sock file');
INSERT INTO settings (param, value, section, `desc`) values('haproxy_sock_port', '1999', 'haproxy', 'HAProxy sock port');
INSERT INTO settings (param, value, section, `desc`) values('apache_log_path', '/var/log/httpd/', 'logs', 'Path to Apache logs folder');
INSERT INTO settings (param, value, section, `desc`) values('ldap_enable', '0', 'ldap', 'If 1 LDAP is enabled');
INSERT INTO settings (param, value, section, `desc`) values('ldap_server', '', 'ldap', 'LDAP server IP address');
INSERT INTO settings (param, value, section, `desc`) values('ldap_port', '389', 'ldap', 'Default port is 389 or 636');
INSERT INTO settings (param, value, section, `desc`) values('ldap_user', '', 'ldap', 'Username to connect to the LDAP server. Enter: user@domain.com');
INSERT INTO settings (param, value, section, `desc`) values('ldap_password', '', 'ldap', 'Password for connect to LDAP server');
INSERT INTO settings (param, value, section, `desc`) values('ldap_base', '', 'ldap', 'Base domain. Example: dc=domain, dc=com');
INSERT INTO settings (param, value, section, `desc`) values('ldap_domain', '', 'ldap', 'Domain for login, that after @, like user@domain.com, without user@');
INSERT INTO settings (param, value, section, `desc`) values('ldap_class_search', 'user', 'ldap', 'Class to search user');
INSERT INTO settings (param, value, section, `desc`) values('ldap_user_attribute', 'sAMAccountName', 'ldap', 'User attribute for searching');
INSERT INTO settings (param, value, section, `desc`) values('ldap_search_field', 'mail', 'ldap', 'Field where user e-mails are saved');
CREATE TABLE IF NOT EXISTS `version` (`version` varchar(64));
""" """
try: try:
cur.executescript(sql) cur.executescript(sql)
@ -217,6 +253,9 @@ def create_table(**kwargs):
return False return False
else: else:
return True return True
finally:
cur.close()
con.close()
else: else:
try: try:
for line in open("haproxy-wi.db.sql"): for line in open("haproxy-wi.db.sql"):
@ -228,76 +267,7 @@ def create_table(**kwargs):
return False return False
else: else:
return True return True
cur.close() finally:
con.close()
def update_db_v_31(**kwargs):
con, cur = get_cur()
sql = list()
sql.append("CREATE TABLE IF NOT EXISTS `settings` (`param` varchar(64), value varchar(64), section varchar(64), `desc` varchar(100), `group` INTEGER NOT NULL DEFAULT 1, UNIQUE(param, `group`));")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('time_zone', 'UTC', 'main', 'Time Zone');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('proxy', '', 'main', 'Proxy server. Use proto://ip:port');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('session_ttl', '5', 'main', 'Time to live users sessions. In days');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('token_ttl', '5', 'main', 'Time to live users tokens. In days');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('tmp_config_path', '/tmp/', 'main', 'Temp store configs, for check. Path must exist');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('cert_path', '/etc/ssl/certs/', 'main', 'Path to SSL dir. Folder owner must be a user which set in the SSH settings. Path must exist');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('ssl_local_path', 'certs', 'main', 'Path to dir for local save SSL certs. This is a relative path, begins with $HOME_HAPROXY-WI/app/');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('lists_path', 'lists', 'main', 'Path to black/white lists. This is a relative path, begins with $HOME_HAPROXY-WI');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('local_path_logs', '/var/log/haproxy.log', 'logs', 'Logs save locally, enabled by default');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('syslog_server_enable', '0', 'logs', 'If exist syslog server for HAproxy logs, enable this option');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('syslog_server', '0', 'logs', 'IP address syslog server');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('log_time_storage', '14', 'logs', 'Time of storage of logs of user activity, in days');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('stats_user', 'admin', 'haproxy', 'Username for Stats web page HAproxy');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('stats_password', 'password', 'haproxy', 'Password for Stats web page HAproxy');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('stats_port', '8085', 'haproxy', 'Port Stats web page HAproxy');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('stats_page', 'stats', 'haproxy', 'URI Stats web page HAproxy');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('haproxy_dir', '/etc/haproxy/', 'haproxy', 'Path to HAProxy dir');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('haproxy_config_path', '/etc/haproxy/haproxy.cfg', 'haproxy', 'Path to HAProxy config');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('server_state_file', '/etc/haproxy/haproxy.state', 'haproxy', 'Path to HAProxy state file');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('haproxy_sock', '/var/run/haproxy.sock', 'haproxy', 'Path to HAProxy sock file');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('haproxy_sock_port', '1999', 'haproxy', 'HAProxy sock port');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('apache_log_path', '/var/log/httpd/', 'logs', 'Path to Apache logs');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('ldap_enable', '0', 'ldap', 'If 1 ldap enabled');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('ldap_server', '', 'ldap', 'IP address ldap server');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('ldap_port', '389', 'ldap', 'Default port is 389 or 636');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('ldap_user', '', 'ldap', 'Login for connect to LDAP server. Enter: user@domain.com');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('ldap_password', '', 'ldap', 'Password for connect to LDAP server');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('ldap_base', '', 'ldap', 'Base domain. Example: dc=domain, dc=com');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('ldap_domain', '', 'ldap', 'Domain for login, that after @, like user@domain.com, without user@');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('ldap_class_search', 'user', 'ldap', 'Class to search user');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('ldap_user_attribute', 'sAMAccountName', 'ldap', 'User attribute for searching');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('ldap_search_field', 'mail', 'ldap', 'Field where user e-mail saved');")
for i in sql:
try:
cur.execute(i)
con.commit()
except sqltool.Error as e:
pass
else:
if kwargs.get('silent') != 1:
print('Updating... go to version 3.2')
return True
cur.close()
con.close()
def update_db_v_3_4_5_2(**kwargs):
con, cur = get_cur()
sql = """CREATE TABLE IF NOT EXISTS `version` (`version` varchar(64)); """
try:
cur.execute(sql)
con.commit()
except sqltool.Error as e:
if kwargs.get('silent') != 1:
if e.args[0] == 'duplicate column name: version' or e == "1060 (42S21): Duplicate column name 'version' ":
print('Updating... go to version 3.4.7')
else:
print("DB was update to 3.4.5.3")
return False
else:
return True
cur.close() cur.close()
con.close() con.close()
@ -320,8 +290,6 @@ def update_db_v_3_4_5_22(**kwargs):
def update_db_v_4(**kwargs): def update_db_v_4(**kwargs):
con, cur = get_cur() con, cur = get_cur()
sql = list() sql = list()
sql.append("update settings set section = 'main', `desc` = 'Temp store configs, for check' where param = 'tmp_config_path';")
sql.append("update settings set section = 'main' where param = 'cert_path';")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('nginx_path_error_logs', '/var/log/nginx/error.log', 'nginx', 'Nginx error log');") sql.append("INSERT INTO settings (param, value, section, `desc`) values('nginx_path_error_logs', '/var/log/nginx/error.log', 'nginx', 'Nginx error log');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('nginx_stats_user', 'admin', 'nginx', 'Username for Stats web page Nginx');") sql.append("INSERT INTO settings (param, value, section, `desc`) values('nginx_stats_user', 'admin', 'nginx', 'Username for Stats web page Nginx');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('nginx_stats_password', 'password', 'nginx', 'Password for Stats web page Nginx');") sql.append("INSERT INTO settings (param, value, section, `desc`) values('nginx_stats_password', 'password', 'nginx', 'Password for Stats web page Nginx');")
@ -443,7 +411,7 @@ def update_db_v_4_3_1(**kwargs):
else: else:
print("An error occurred:", e) print("An error occurred:", e)
else: else:
print("DB was update to 4.3.1") print("DB has been updated to 4.3.1")
cur.close() cur.close()
con.close() con.close()
@ -452,7 +420,7 @@ def update_db_v_4_3_1(**kwargs):
def update_db_v_4_3_2(**kwargs): def update_db_v_4_3_2(**kwargs):
con, cur = get_cur() con, cur = get_cur()
sql = """ sql = """
INSERT INTO settings (param, value, section, `desc`) values('ldap_type', '0', 'ldap', 'If 0 then will be used LDAP, if 1 then will be used LDAPS '); INSERT INTO settings (param, value, section, `desc`) values('ldap_type', '0', 'ldap', 'If 0 then LDAP is be used , if 1 then LDAPS');
""" """
try: try:
cur.execute(sql) cur.execute(sql)
@ -546,7 +514,7 @@ def update_db_v_4_4_2_1(**kwargs):
else: else:
print("An error occurred:", e) print("An error occurred:", e)
else: else:
print("DB was update to 4.4.2") print("DB has been updated to 4.4.2")
cur.close() cur.close()
con.close() con.close()
@ -634,7 +602,7 @@ def update_db_v_4_5_1(**kwargs):
pass pass
else: else:
if kwargs.get('silent') != 1: if kwargs.get('silent') != 1:
print('DB was update to 4.5.0') print('DB has been updated to 4.5.0')
cur.close() cur.close()
con.close() con.close()
@ -674,7 +642,7 @@ def update_db_v_4_5_7(**kwargs):
else: else:
print("An error occurred:", e) print("An error occurred:", e)
else: else:
print("DB was update to 4.3.1") print("DB has been updated to 4.3.1")
cur.close() cur.close()
con.close() con.close()
@ -1223,10 +1191,11 @@ def update_db_v_5_1_0_1(**kwargs):
def update_db_v_5_1_1(**kwargs): def update_db_v_5_1_1(**kwargs):
con, cur = get_cur() con, cur = get_cur()
sql = """CREATE TABLE IF NOT EXISTS `slack` ( sql = """CREATE TABLE IF NOT EXISTS `slack` (
`id` integer primary key autoincrement, `id` INTEGER NOT NULL,
`token` VARCHAR (64), `token` VARCHAR (64),
`chanel_name` INTEGER NOT NULL DEFAULT 1, `chanel_name` INTEGER NOT NULL DEFAULT 1,
`groups` INTEGER NOT NULL DEFAULT 1 `groups` INTEGER NOT NULL DEFAULT 1,
PRIMARY KEY(`id`)
); );
""" """
try: try:
@ -1245,7 +1214,7 @@ def update_db_v_5_1_1(**kwargs):
def update_ver(): def update_ver():
con, cur = get_cur() con, cur = get_cur()
sql = """update version set version = '5.1.1.0'; """ sql = """update version set version = '5.1.2.0'; """
try: try:
cur.execute(sql) cur.execute(sql)
con.commit() con.commit()
@ -1256,8 +1225,6 @@ def update_ver():
def update_all(): def update_all():
update_db_v_31()
update_db_v_3_4_5_2()
if funct.check_ver() is None: if funct.check_ver() is None:
update_db_v_3_4_5_22() update_db_v_3_4_5_22()
update_db_v_4() update_db_v_4()
@ -1292,8 +1259,6 @@ def update_all():
def update_all_silent(): def update_all_silent():
update_db_v_31(silent=1)
update_db_v_3_4_5_2(silent=1)
if funct.check_ver() is None: if funct.check_ver() is None:
update_db_v_3_4_5_22() update_db_v_3_4_5_22()
update_db_v_4(silent=1) update_db_v_4(silent=1)

View File

@ -28,4 +28,38 @@ CREATE TABLE IF NOT EXISTS port_scanner_history (`serv` varchar(64), port INTEGE
CREATE TABLE IF NOT EXISTS providers_creds (`id` INTEGER NOT NULL, `name` VARCHAR ( 64 ), `type` VARCHAR ( 64 ), `group` VARCHAR ( 64 ), `key` VARCHAR ( 64 ), `secret` VARCHAR ( 64 ), `create_date` DATETIME default '0000-00-00 00:00:00', `edit_date` DATETIME default '0000-00-00 00:00:00', PRIMARY KEY(`id`)); CREATE TABLE IF NOT EXISTS providers_creds (`id` INTEGER NOT NULL, `name` VARCHAR ( 64 ), `type` VARCHAR ( 64 ), `group` VARCHAR ( 64 ), `key` VARCHAR ( 64 ), `secret` VARCHAR ( 64 ), `create_date` DATETIME default '0000-00-00 00:00:00', `edit_date` DATETIME default '0000-00-00 00:00:00', PRIMARY KEY(`id`));
CREATE TABLE IF NOT EXISTS provisioned_servers (`id` INTEGER NOT NULL, `region` VARCHAR ( 64 ), `instance_type` VARCHAR ( 64 ), `public_ip` INTEGER, `floating_ip` INTEGER, `volume_size` INTEGER, `backup` INTEGER, `monitoring` INTEGER, `private_networking` INTEGER, `ssh_key_name` VARCHAR ( 64 ), `ssh_ids` VARCHAR ( 64 ), `name` VARCHAR ( 64 ), `os` VARCHAR ( 64 ), `firewall` INTEGER, `provider_id` INTEGER, `type` VARCHAR ( 64 ), `status` VARCHAR ( 64 ), `group_id` INTEGER NOT NULL, `date` DATETIME default '0000-00-00 00:00:00', `IP` VARCHAR ( 64 ), `last_error` VARCHAR ( 256 ), `delete_on_termination` INTEGER, PRIMARY KEY(`id`)); CREATE TABLE IF NOT EXISTS provisioned_servers (`id` INTEGER NOT NULL, `region` VARCHAR ( 64 ), `instance_type` VARCHAR ( 64 ), `public_ip` INTEGER, `floating_ip` INTEGER, `volume_size` INTEGER, `backup` INTEGER, `monitoring` INTEGER, `private_networking` INTEGER, `ssh_key_name` VARCHAR ( 64 ), `ssh_ids` VARCHAR ( 64 ), `name` VARCHAR ( 64 ), `os` VARCHAR ( 64 ), `firewall` INTEGER, `provider_id` INTEGER, `type` VARCHAR ( 64 ), `status` VARCHAR ( 64 ), `group_id` INTEGER NOT NULL, `date` DATETIME default '0000-00-00 00:00:00', `IP` VARCHAR ( 64 ), `last_error` VARCHAR ( 256 ), `delete_on_termination` INTEGER, PRIMARY KEY(`id`));
CREATE TABLE IF NOT EXISTS api_tokens (`token` varchar(64), `user_name` varchar(64), `user_group_id` INTEGER NOT NULL, `user_role` INTEGER NOT NULL, `create_date` DATETIME default '0000-00-00 00:00:00', `expire_date` DATETIME default '0000-00-00 00:00:00'); CREATE TABLE IF NOT EXISTS api_tokens (`token` varchar(64), `user_name` varchar(64), `user_group_id` INTEGER NOT NULL, `user_role` INTEGER NOT NULL, `create_date` DATETIME default '0000-00-00 00:00:00', `expire_date` DATETIME default '0000-00-00 00:00:00');
CREATE TABLE IF NOT EXISTS `slack` (`id` integer primary key autoincrement, `token` VARCHAR (64), `chanel_name` INTEGER NOT NULL DEFAULT 1, `groups` INTEGER NOT NULL DEFAULT 1); CREATE TABLE IF NOT EXISTS `slack` (`id` INTEGER NOT NULL, `token` VARCHAR (64), `chanel_name` INTEGER NOT NULL DEFAULT 1, `groups` INTEGER NOT NULL DEFAULT 1, PRIMARY KEY(`id`));
CREATE TABLE IF NOT EXISTS `settings` (`param` varchar(64), value varchar(64), section varchar(64), `desc` varchar(100), `group` INTEGER NOT NULL DEFAULT 1, UNIQUE(param, `group`));
INSERT INTO settings (param, value, section, `desc`) values('time_zone', 'UTC', 'main', 'Time Zone');
INSERT INTO settings (param, value, section, `desc`) values('proxy', '', 'main', 'Proxy server. Use proto://ip:port');
INSERT INTO settings (param, value, section, `desc`) values('session_ttl', '5', 'main', 'Time to live users sessions. In days');
INSERT INTO settings (param, value, section, `desc`) values('token_ttl', '5', 'main', 'Time to live users tokens. In days');
INSERT INTO settings (param, value, section, `desc`) values('tmp_config_path', '/tmp/', 'main', 'A temp folder of configs, for checking. The path must exist');
INSERT INTO settings (param, value, section, `desc`) values('cert_path', '/etc/ssl/certs/', 'main', 'A path to SSL dir. The folder owner must be an user who set in the SSH settings. The path must exist');
INSERT INTO settings (param, value, section, `desc`) values('ssl_local_path', 'certs', 'main', 'Path to dir for local save SSL certs. This is a relative path, begins with $HOME_HAPROXY-WI/app/');
INSERT INTO settings (param, value, section, `desc`) values('lists_path', 'lists', 'main', 'Path to black/white lists. This is a relative path, begins with $HOME_HAPROXY-WI');
INSERT INTO settings (param, value, section, `desc`) values('local_path_logs', '/var/log/haproxy.log', 'logs', 'Logs save locally, enabled by default');
INSERT INTO settings (param, value, section, `desc`) values('syslog_server_enable', '0', 'logs', 'If exist syslog server for HAProxy logs, enable this option');
INSERT INTO settings (param, value, section, `desc`) values('syslog_server', '0', 'logs', 'IP address of syslog server');
INSERT INTO settings (param, value, section, `desc`) values('log_time_storage', '14', 'logs', 'Storage time for user activity logs, in days');
INSERT INTO settings (param, value, section, `desc`) values('stats_user', 'admin', 'haproxy', 'Username for the HAProxy Stats web page');
INSERT INTO settings (param, value, section, `desc`) values('stats_password', 'password', 'haproxy', 'Password for the HAProxy Stats web page');
INSERT INTO settings (param, value, section, `desc`) values('stats_port', '8085', 'haproxy', 'Port for the HAProxy Stats web page');
INSERT INTO settings (param, value, section, `desc`) values('stats_page', 'stats', 'haproxy', 'URI for the HAProxy Stats web page');
INSERT INTO settings (param, value, section, `desc`) values('haproxy_dir', '/etc/haproxy/', 'haproxy', 'Path to HAProxy dir');
INSERT INTO settings (param, value, section, `desc`) values('haproxy_config_path', '/etc/haproxy/haproxy.cfg', 'haproxy', 'Path to HAProxy config');
INSERT INTO settings (param, value, section, `desc`) values('server_state_file', '/etc/haproxy/haproxy.state', 'haproxy', 'Path to HAProxy state file');
INSERT INTO settings (param, value, section, `desc`) values('haproxy_sock', '/var/run/haproxy.sock', 'haproxy', 'Path to HAProxy sock file');
INSERT INTO settings (param, value, section, `desc`) values('haproxy_sock_port', '1999', 'haproxy', 'HAProxy sock port');
INSERT INTO settings (param, value, section, `desc`) values('apache_log_path', '/var/log/httpd/', 'logs', 'Path to Apache logs folder');
INSERT INTO settings (param, value, section, `desc`) values('ldap_enable', '0', 'ldap', 'If 1 LDAP is enabled');
INSERT INTO settings (param, value, section, `desc`) values('ldap_server', '', 'ldap', 'LDAP server IP address');
INSERT INTO settings (param, value, section, `desc`) values('ldap_port', '389', 'ldap', 'Default port is 389 or 636');
INSERT INTO settings (param, value, section, `desc`) values('ldap_user', '', 'ldap', 'Username to connect to the LDAP server. Enter: user@domain.com');
INSERT INTO settings (param, value, section, `desc`) values('ldap_password', '', 'ldap', 'Password for connect to LDAP server');
INSERT INTO settings (param, value, section, `desc`) values('ldap_base', '', 'ldap', 'Base domain. Example: dc=domain, dc=com');
INSERT INTO settings (param, value, section, `desc`) values('ldap_domain', '', 'ldap', 'Domain for login, that after @, like user@domain.com, without user@');
INSERT INTO settings (param, value, section, `desc`) values('ldap_class_search', 'user', 'ldap', 'Class to search user');
INSERT INTO settings (param, value, section, `desc`) values('ldap_user_attribute', 'sAMAccountName', 'ldap', 'User attribute for searching');
INSERT INTO settings (param, value, section, `desc`) values('ldap_search_field', 'mail', 'ldap', 'Field where user e-mails are saved');
CREATE TABLE IF NOT EXISTS `version` (`version` varchar(64));

View File

@ -918,6 +918,12 @@ if serv is not None and form.getvalue('right') is not None:
print(stderr) print(stderr)
if serv is not None and act == "configShow": if serv is not None and act == "configShow":
import http.cookies
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
user_uuid = cookie.get('uuid')
role_id = sql.get_user_role_by_uuid(user_uuid.value)
if form.getvalue('service') == 'keepalived': if form.getvalue('service') == 'keepalived':
configs_dir = funct.get_config_var('configs', 'kp_save_configs_dir') configs_dir = funct.get_config_var('configs', 'kp_save_configs_dir')
cfg = '.conf' cfg = '.conf'
@ -941,6 +947,8 @@ if serv is not None and act == "configShow":
except IOError: except IOError:
print('<div class="alert alert-danger">Can\'t read config file</div>') print('<div class="alert alert-danger">Can\'t read config file</div>')
is_serv_protected = sql.is_serv_protected(serv)
from jinja2 import Environment, FileSystemLoader from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True, trim_blocks=True, lstrip_blocks=True, env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True, trim_blocks=True, lstrip_blocks=True,
@ -950,8 +958,9 @@ if serv is not None and act == "configShow":
template = template.render(conf=conf, template = template.render(conf=conf,
serv=serv, serv=serv,
configver=form.getvalue('configver'), configver=form.getvalue('configver'),
role=funct.is_admin(level=3), role=role_id,
service=form.getvalue('service')) service=form.getvalue('service'),
is_serv_protected=is_serv_protected)
print(template) print(template)
if form.getvalue('configver') is None: if form.getvalue('configver') is None:
@ -1227,6 +1236,35 @@ if form.getvalue('nginx_exp_install'):
os.system("rm -f %s" % script) os.system("rm -f %s" % script)
if form.getvalue('node_exp_install'):
serv = form.getvalue('node_exp_install')
script = "install_node_exporter.sh"
proxy = sql.get_setting('proxy')
ssh_enable, ssh_user_name, ssh_user_password, ssh_key_name = funct.return_ssh_keys_path(serv)
if ssh_enable == 0:
ssh_key_name = ''
servers = sql.select_servers(server=serv)
for server in servers:
ssh_port = str(server[10])
os.system("cp scripts/%s ." % script)
if proxy is not None and proxy != '' and proxy != 'None':
proxy_serv = proxy
else:
proxy_serv = ''
commands = ["chmod +x " + script + " && ./" + script + " PROXY=" + proxy_serv + " SSH_PORT=" + ssh_port +
" HOST=" + serv + " USER=" + ssh_user_name + " PASS=" + ssh_user_password + " KEY=" + ssh_key_name]
output, error = funct.subprocess_execute(commands[0])
funct.show_installation_output(error, output, 'Node exporter')
os.system("rm -f %s" % script)
if form.getvalue('backup') or form.getvalue('deljob') or form.getvalue('backupupdate'): if form.getvalue('backup') or form.getvalue('deljob') or form.getvalue('backupupdate'):
serv = form.getvalue('server') serv = form.getvalue('server')
rpath = form.getvalue('rpath') rpath = form.getvalue('rpath')
@ -1757,12 +1795,13 @@ if form.getvalue('updateserver') is not None:
serv_id = form.getvalue('id') serv_id = form.getvalue('id')
cred = form.getvalue('cred') cred = form.getvalue('cred')
port = form.getvalue('port') port = form.getvalue('port')
protected = form.getvalue('protected')
desc = form.getvalue('desc') desc = form.getvalue('desc')
if name is None or port is None: if name is None or port is None:
print(error_mess) print(error_mess)
else: else:
sql.update_server(name, group, typeip, enable, master, serv_id, cred, port, desc, haproxy, nginx, firewall) sql.update_server(name, group, typeip, enable, master, serv_id, cred, port, desc, haproxy, nginx, firewall, protected)
funct.logging('the server ' + name, ' has been updated ', haproxywi=1, login=1) funct.logging('the server ' + name, ' has been updated ', haproxywi=1, login=1)
if form.getvalue('serverdel') is not None: if form.getvalue('serverdel') is not None:

View File

@ -151,13 +151,16 @@
{{s.1}} {{s.1}}
{% endif %} {% endif %}
{% if s.6|int() >= 1 %} {% if s.6|int() >= 1 %}
<img <span
{% if keep_alive|int() >= 1 %} {% if keep_alive|int() >= 1 %}
src="/inc/images/shield.png" title="Auto start enabled" class="shield green" title="Auto start enabled">
{% else %} {% else %}
src="/inc/images/shield-red.png" title="Auto start enabled, but keep alive service does not work" class="shield red" title="Auto start enabled, but keep alive service does not work">
{% endif %} {% endif %}
width=18 style="margin-bottom: -3px;" /> </span>
{% endif %}
{% if s.8.0.20 == 1 %}
<span class="lock" title="This server is inaccessible for editing by everyone except the admin role"></span>
{% endif %} {% endif %}
{% if role <= 2 %} {% if role <= 2 %}
<span class="server-action"> <span class="server-action">
@ -197,7 +200,7 @@
Cannot get information about HAProxy Cannot get information about HAProxy
{% endif %} {% endif %}
{% endif %} {% endif %}
<span title="Date of last configuration edit" > <span title="Date of last configuration edit">
Last edit: Last edit:
<span id="{{s.1}}"></span> <span id="{{s.1}}"></span>
</span> </span>

View File

@ -3,7 +3,7 @@
<caption><h3>Installing Grafana and Prometheus servers</h3></caption> <caption><h3>Installing Grafana and Prometheus servers</h3></caption>
<tr class="overviewHead"> <tr class="overviewHead">
<td class="padding10 first-collumn">Current installation</td> <td class="padding10 first-collumn">Current installation</td>
<td class="padding10 first-collumn" style="width: 30%;">Available Versions</td> <td class="padding10 first-collumn" style="width: 40%;">Available Versions</td>
<td class="padding10 first-collumn" style="width: 30%;">Note</td> <td class="padding10 first-collumn" style="width: 30%;">Note</td>
<td></td> <td></td>
<td></td> <td></td>
@ -35,7 +35,7 @@
<caption><h3>Install HAProxy Exporter</h3></caption> <caption><h3>Install HAProxy Exporter</h3></caption>
<tr class="overviewHead"> <tr class="overviewHead">
<td class="padding10 first-collumn">Current installation</td> <td class="padding10 first-collumn">Current installation</td>
<td class="padding10 first-collumn" style="width: 30%;">Available Versions</td> <td class="padding10 first-collumn" style="width: 40%;">Available Versions</td>
<td class="padding10 first-collumn" style="width: 30%;">Server</td> <td class="padding10 first-collumn" style="width: 30%;">Server</td>
<td></td> <td></td>
<td></td> <td></td>
@ -65,7 +65,7 @@
<caption><h3>Install Nginx Exporter</h3></caption> <caption><h3>Install Nginx Exporter</h3></caption>
<tr class="overviewHead"> <tr class="overviewHead">
<td class="padding10 first-collumn">Current installation</td> <td class="padding10 first-collumn">Current installation</td>
<td class="padding10 first-collumn" style="width: 30%;">Available Versions</td> <td class="padding10 first-collumn" style="width: 40%;">Available Versions</td>
<td class="padding10 first-collumn" style="width: 30%;">Server</td> <td class="padding10 first-collumn" style="width: 30%;">Server</td>
<td></td> <td></td>
<td></td> <td></td>
@ -91,4 +91,34 @@
</td> </td>
</tr> </tr>
</table> </table>
<table style="margin-top: 20px">
<caption><h3>Install Node Exporter</h3></caption>
<tr class="overviewHead">
<td class="padding10 first-collumn">Current installation</td>
<td class="padding10 first-collumn" style="width: 40%;">Available Versions</td>
<td class="padding10 first-collumn" style="width: 30%;">Server</td>
<td></td>
<td></td>
</tr>
<tr>
<td id="cur_node_exp_ver" class="padding10 first-collumn">
</td>
<td class="padding10 first-collumn" style="width: 20%;">
HAProxy-WI will try to install the latest Node Exporter version
</td>
<td class="padding10 first-collumn">
<select autofocus required name="node_exp_addserv" id="node_exp_addserv">
<option disabled selected>Choose server</option>
{% for select in servers %}
<option value="{{ select.2 }}">{{ select.1 }}</option>
{% endfor %}
</select>
</td>
<td>
</td>
<td>
<span class="ui-button ui-widget ui-corner-all" id="node_exp_install" title="Install Node Exporter">Install</span>
</td>
</tr>
</table>
<div id="ajaxmon"></div> <div id="ajaxmon"></div>

View File

@ -321,3 +321,26 @@
font-family: "Font Awesome 5 Solid"; font-family: "Font Awesome 5 Solid";
content: "\f7d9"; content: "\f7d9";
} }
.shield::before {
display: none;
font-family: "Font Awesome 5 Solid";
content: "\f3ed";
}
.lock::before {
display: none;
font-family: "Font Awesome 5 Solid";
content: "\f023";
}
.server-name .lock .fa-lock,
.server-name .green .fa-shield-alt,
.server-name .red .fa-shield-alt {
color: #d2d2d2;
margin-bottom: -1px;
width: 14px;
}
.server-name .green .fa-shield-alt {
color: var(--green-color);
}
.server-name .red .fa-shield-alt {
color: var(--red-color);
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

View File

@ -198,7 +198,8 @@ function ajaxActionWafServers(action, id) {
} ); } );
} }
$( function() { $( function() {
if ((cur_url[0] == 'hapservers.py' && cur_url[1].split('=')[0] == 'service') || cur_url[0] == 'overview.py') { try {
if ((cur_url[0] == 'hapservers.py' && cur_url[1].split('&')[1].split('=')[0] == 'serv') || cur_url[0] == 'overview.py') {
ChartsIntervalId = setInterval(updatingCpuRamCharts, 30000); ChartsIntervalId = setInterval(updatingCpuRamCharts, 30000);
$(window).focus(function () { $(window).focus(function () {
ChartsIntervalId = setInterval(updatingCpuRamCharts, 30000); ChartsIntervalId = setInterval(updatingCpuRamCharts, 30000);
@ -207,6 +208,9 @@ $( function() {
clearInterval(ChartsIntervalId); clearInterval(ChartsIntervalId);
}); });
} }
} catch (e) {
console.log(e);
}
$( "#show-all-users" ).click( function() { $( "#show-all-users" ).click( function() {
$( ".show-users" ).show("fast"); $( ".show-users" ).show("fast");
$( "#show-all-users" ).text("Hide"); $( "#show-all-users" ).text("Hide");

View File

@ -1,5 +1,8 @@
:root { :root {
--green-color: #5ad05a; --green-color: #5ad05a;
--red-color: #be2424;
--blue-color: #5d9ceb;
--link-dark-blue: #23527c;
} }
html { html {
font-size: 10px; font-size: 10px;
@ -16,11 +19,9 @@ body {
height:100% height:100%
} }
h2 { h2 {
font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 1.5em; font-size: 1.5em;
font-style: normal; background: var(--blue-color);
background: #5D9CEB; border: 1px solid var(--blue-color);
border: 1px solid #5D9CEB;
padding: 3px 3px 3px 2%; padding: 3px 3px 3px 2%;
color: #fff; color: #fff;
margin-top: 0; margin-top: 0;
@ -155,7 +156,7 @@ pre {
margin-right: 20px; margin-right: 20px;
} }
.footer-link, .footer-copyright { .footer-link, .footer-copyright {
color: #5d9ceb; color: var(--blue-color);
font-size: 0.9em; font-size: 0.9em;
padding: 12px 5px 20px 20px; padding: 12px 5px 20px 20px;
} }
@ -334,7 +335,7 @@ pre {
.addSuc { .addSuc {
padding-left: 20px; padding-left: 20px;
padding-top: 20px; padding-top: 20px;
color: #23527c; color: var(--blue-color);
} }
.add-note { .add-note {
width: 30%; width: 30%;
@ -422,7 +423,7 @@ pre {
font-size: 13px; font-size: 13px;
} }
.serverDown { .serverDown {
background-color: #be2424; background-color: var(--red-color);
} }
.padding10 { .padding10 {
padding: 10px 10px 10px 0; padding: 10px 10px 10px 0;
@ -492,7 +493,7 @@ ul{
background: #48505A; background: #48505A;
padding: 10px 0 10px 20px; padding: 10px 0 10px 20px;
color: #fff; color: #fff;
border-left: 4px solid #5D9CEB; border-left: 4px solid var(--blue-color);
} }
.menu li:first-child a, .menu li .v_menu li:first-child a{ .menu li:first-child a, .menu li .v_menu li:first-child a{
border-radius: 3px 3px 0 0; border-radius: 3px 3px 0 0;
@ -545,7 +546,7 @@ ul{
@keyframes shadow-red { @keyframes shadow-red {
from {box-shadow: 0 0 0 red inset;} from {box-shadow: 0 0 0 red inset;}
50% {text-shadow: 0 0 30px black;} 50% {text-shadow: 0 0 30px black;}
to {box-shadow: 0 -5px 5px -5px #5D9CEB inset} to {box-shadow: 0 -5px 5px -5px var(--blue-color) inset}
} }
.form-control:hover { .form-control:hover {
animation: shadow-red 0.3s forwards; animation: shadow-red 0.3s forwards;
@ -589,7 +590,7 @@ ul{
} }
.ui-state-active { .ui-state-active {
background-color: #4A89D8 !important; background-color: #4A89D8 !important;
border: none #5D9CEB !important; border: none var(--blue-color) !important;
} }
.ui-tabs-nav { .ui-tabs-nav {
border-radius: 0 !important; border-radius: 0 !important;
@ -606,7 +607,7 @@ ul{
margin-left: -2px; margin-left: -2px;
} }
.ui-widget-header { .ui-widget-header {
background: #5d9ceb !important; background: var(--blue-color) !important;
} }
.ui-menu, .ui-menu-item { .ui-menu, .ui-menu-item {
background: #EBF1F1 !important; background: #EBF1F1 !important;
@ -624,7 +625,7 @@ ul{
border-bottom: none !important; border-bottom: none !important;
} }
.need-field { .need-field {
color: red; color: var(--red-color);
} }
a:active, a:hover { a:active, a:hover {
outline: 0; outline: 0;
@ -633,12 +634,12 @@ a, a:visited {
text-decoration: underline; text-decoration: underline;
} }
a { a {
color: #23527c; color: var(--link-dark-blue);
text-decoration: none; text-decoration: none;
background-color: transparent; background-color: transparent;
} }
a:hover, a:focus { a:hover, a:focus {
color: #23527c; color: var(--link-dark-blue);
text-decoration: underline; text-decoration: underline;
} }
a:focus { a:focus {
@ -646,9 +647,12 @@ a:focus {
outline-offset: -2px; outline-offset: -2px;
} }
.logs_link, .accordion-link, .link { .logs_link, .accordion-link, .link {
color: #23527c !important; color: var(--blue-color) !important;
cursor: pointer; cursor: pointer;
} }
.logs_link {
color: var(--link-dark-blue) !important;
}
table { table {
border-spacing: 0; border-spacing: 0;
border-collapse: collapse; border-collapse: collapse;
@ -684,7 +688,7 @@ td,th {
.alert a { .alert a {
cursor: pointer; cursor: pointer;
margin-bottom: 10px; margin-bottom: 10px;
color: #23527c !important; color: var(--blue-color) !important;
} }
.alert-danger, .alert-info, .alert-success, .alert-warning, .added { .alert-danger, .alert-info, .alert-success, .alert-warning, .added {
margin-left: 15px; margin-left: 15px;
@ -764,7 +768,7 @@ label {
border-top: 3px solid var(--green-color) !important; border-top: 3px solid var(--green-color) !important;
} }
.div-server-head-down { .div-server-head-down {
border-top: 3px solid #be2424 !important; border-top: 3px solid var(--red-color) !important;
} }
.div-server-head-dis { .div-server-head-dis {
border-top: 3px solid #aaa !important; border-top: 3px solid #aaa !important;
@ -787,7 +791,7 @@ label {
.server-name { .server-name {
padding-bottom: 3px; padding-bottom: 3px;
font-size: 1.4em; font-size: 1.4em;
color: #5d9ceb; color: var(--blue-color);
border-bottom: 1px solid #A4C7F5; border-bottom: 1px solid #A4C7F5;
width: 99%; width: 99%;
} }
@ -921,7 +925,7 @@ label {
font-size: 18px; font-size: 18px;
padding-top: 5px; padding-top: 5px;
padding-bottom: 3px; padding-bottom: 3px;
color: #5d9ceb; color: var(--blue-color);
border-bottom: 1px solid #A4C7F5; border-bottom: 1px solid #A4C7F5;
width: 93%; width: 93%;
margin-bottom: 5px; margin-bottom: 5px;
@ -947,7 +951,7 @@ label {
border-color: #d6e9c6; border-color: #d6e9c6;
} }
.down { .down {
color: #a94442; color: var(--red-color);
background-color: #f2dede; background-color: #f2dede;
border-color: #ebccd1; border-color: #ebccd1;
font-size: 22px; font-size: 22px;

View File

@ -176,7 +176,7 @@ $( function() {
} else if (data.indexOf('success') != '-1' ){ } else if (data.indexOf('success') != '-1' ){
toastr.clear(); toastr.clear();
toastr.success(data); toastr.success(data);
$('#cur_haproxy_exp_ver').text('HAProxy expoter is installed'); $('#cur_haproxy_exp_ver').text('HAProxy exporter is installed');
$('#haproxy_exp_install').text('Update'); $('#haproxy_exp_install').text('Update');
$("#haproxy_exp_addserv").trigger( "selectmenuchange" ); $("#haproxy_exp_addserv").trigger( "selectmenuchange" );
} else if (data.indexOf('Info') != '-1' ){ } else if (data.indexOf('Info') != '-1' ){
@ -207,7 +207,7 @@ $( function() {
} else if (data.indexOf('success') != '-1' ){ } else if (data.indexOf('success') != '-1' ){
toastr.clear(); toastr.clear();
toastr.success(data); toastr.success(data);
$('#cur_nginx_exp_ver').text('Nginx expoter is installed'); $('#cur_nginx_exp_ver').text('Nginx exporter is installed');
$('#nginx_exp_install').text('Update'); $('#nginx_exp_install').text('Update');
$("#nginx_exp_addserv").trigger( "selectmenuchange" ); $("#nginx_exp_addserv").trigger( "selectmenuchange" );
} else if (data.indexOf('Info') != '-1' ){ } else if (data.indexOf('Info') != '-1' ){
@ -220,6 +220,37 @@ $( function() {
} }
} ); } );
}); });
$('#node_exp_install').click(function() {
$("#ajaxmon").html('')
$("#ajaxmon").html(wait_mess);
$.ajax( {
url: "options.py",
data: {
node_exp_install: $('#node_exp_addserv').val(),
token: $('#token').val()
},
type: "POST",
success: function( data ) {
data = data.replace(/\s+/g,' ');
$("#ajaxmon").html('');
if (data.indexOf('error:') != '-1' || data.indexOf('FAILED') != '-1') {
toastr.error(data);
} else if (data.indexOf('success') != '-1' ){
toastr.clear();
toastr.success(data);
$('#cur_node_exp_ver').text('Node exporter is installed');
$('#node_exp_install').text('Update');
$("#node_exp_addserv").trigger( "selectmenuchange" );
} else if (data.indexOf('Info') != '-1' ){
toastr.clear();
toastr.info(data);
} else {
toastr.clear();
toastr.info(data);
}
}
} );
});
$( "#haproxyaddserv" ).on('selectmenuchange',function() { $( "#haproxyaddserv" ).on('selectmenuchange',function() {
$.ajax( { $.ajax( {
url: "options.py", url: "options.py",
@ -279,13 +310,13 @@ $( function() {
success: function( data ) { success: function( data ) {
data = data.replace(/^\s+|\s+$/g,''); data = data.replace(/^\s+|\s+$/g,'');
if(data == 'active') { if(data == 'active') {
$('#cur_haproxy_exp_ver').text('HAProxy expoter is installed'); $('#cur_haproxy_exp_ver').text('HAProxy exporter is installed');
$('#haproxy_exp_install').text('Update'); $('#haproxy_exp_install').text('Update');
$('#haproxy_exp_install').attr('title', 'Update HAProxy expoter'); $('#haproxy_exp_install').attr('title', 'Update HAProxy exporter');
} else { } else {
$('#cur_haproxy_exp_ver').text('HAProxy expoter has not installed'); $('#cur_haproxy_exp_ver').text('HAProxy exporter has not installed');
$('#haproxy_exp_install').text('Install'); $('#haproxy_exp_install').text('Install');
$('#haproxy_exp_install').attr('title', 'Install HAProxy expoter'); $('#haproxy_exp_install').attr('title', 'Install HAProxy exporter');
} }
} }
} ); } );
@ -302,13 +333,36 @@ $( function() {
success: function( data ) { success: function( data ) {
data = data.replace(/^\s+|\s+$/g,''); data = data.replace(/^\s+|\s+$/g,'');
if(data == 'active') { if(data == 'active') {
$('#cur_nginx_exp_ver').text('Nginx expoter is installed'); $('#cur_nginx_exp_ver').text('Nginx exporter is installed');
$('#nginx_exp_install').text('Update'); $('#nginx_exp_install').text('Update');
$('#nginx_exp_install').attr('title', 'Update Nginx expoter'); $('#nginx_exp_install').attr('title', 'Update Nginx exporter');
} else { } else {
$('#cur_nginx_exp_ver').text('Nginx expoter has not installed'); $('#cur_nginx_exp_ver').text('Nginx exporter has not installed');
$('#nginx_exp_install').text('Install'); $('#nginx_exp_install').text('Install');
$('#nginx_exp_install').attr('title', 'Install Nginx expoter'); $('#nginx_exp_install').attr('title', 'Install Nginx exporter');
}
}
} );
});
$( "#node_exp_addserv" ).on('selectmenuchange',function() {
$.ajax( {
url: "options.py",
data: {
get_exporter_v: 'node_exporter',
serv: $('#node_exp_addserv option:selected').val(),
token: $('#token').val()
},
type: "POST",
success: function( data ) {
data = data.replace(/^\s+|\s+$/g,'');
if(data == 'active') {
$('#cur_node_exp_ver').text('Node exporter is installed');
$('#node_exp_install').text('Update');
$('#node_exp_install').attr('title', 'Update Node exporter');
} else {
$('#cur_node_exp_ver').text('Node exporter has not installed');
$('#node_exp_install').text('Install');
$('#node_exp_install').attr('title', 'Install Node exporter');
} }
} }
} ); } );