From 8386df91de1dd72c80533ebf6c8bbe09552e7291 Mon Sep 17 00:00:00 2001 From: Micke Nordin Date: Fri, 24 Mar 2023 14:36:07 +0100 Subject: [PATCH] Fix for multinode --- templates/proxysql/insert_server_in_proxysql.erb.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/templates/proxysql/insert_server_in_proxysql.erb.sh b/templates/proxysql/insert_server_in_proxysql.erb.sh index a819ab2..bf361c7 100644 --- a/templates/proxysql/insert_server_in_proxysql.erb.sh +++ b/templates/proxysql/insert_server_in_proxysql.erb.sh @@ -1,8 +1,14 @@ #!/bin/bash PATH="${PATH}:/usr/local/bin" restarted="false" +domain=$(hostname -d) +prefix="intern-db" +if [[ ${domain} =~ ^drive ]]; then + prefix="multinode-db" +fi + for index in 1 2 3; do - db_ip=$(host "intern-db${index}.$(hostname -d)" | awk '/has address/ {print $NF}') + db_ip=$(host "${prefix}${index}.${domain}" | awk '/has address/ {print $NF}') result=$(proxysql "select * from main.mysql_servers where hostname = '${db_ip}' and hostgroup_id = 10") if [[ -z ${result} ]]; then query="INSERT INTO main.mysql_servers (hostgroup_id, hostname, max_connections, comment) VALUES( 10, '${db_ip}', 100, 'Inserted by script at $(date)')"