diff --git a/server/core/config_runtime.cc b/server/core/config_runtime.cc index 2606a0afb..3bb8b0341 100644 --- a/server/core/config_runtime.cc +++ b/server/core/config_runtime.cc @@ -209,7 +209,8 @@ bool runtime_create_server(const char* name, const char* address, const char* port, const char* protocol, - const char* authenticator) + const char* authenticator, + bool serialize) { std::lock_guard guard(crt_lock); bool rval = false; @@ -244,7 +245,7 @@ bool runtime_create_server(const char* name, Server* server = Server::server_alloc(name, ctx.parameters); - if (server && server->serialize()) + if (server && (!serialize || server->serialize())) { rval = true; MXS_NOTICE("Created server '%s' at %s:%u", diff --git a/server/core/internal/config_runtime.hh b/server/core/internal/config_runtime.hh index 908bd6afe..dfcbbe0b6 100644 --- a/server/core/internal/config_runtime.hh +++ b/server/core/internal/config_runtime.hh @@ -57,7 +57,8 @@ bool runtime_create_server(const char* name, const char* address, const char* port, const char* protocol, - const char* authenticator); + const char* authenticator, + bool serialize = true); /** * @brief Destroy a server diff --git a/server/modules/monitor/clustrixmon/clustrixmonitor.cc b/server/modules/monitor/clustrixmon/clustrixmonitor.cc index a87a05e2a..fb784a102 100644 --- a/server/modules/monitor/clustrixmon/clustrixmonitor.cc +++ b/server/modules/monitor/clustrixmon/clustrixmonitor.cc @@ -13,6 +13,7 @@ #include "clustrixmonitor.hh" #include +#include "../../../core/internal/config_runtime.hh" namespace http = mxb::http; using namespace std; @@ -149,10 +150,26 @@ void ClustrixMonitor::fetch_cluster_nodes_from(MXS_MONITORED_SERVER& ms) int health_port = row[3] ? atoi(row[3]) : DEFAULT_HEALTH_PORT; int health_check_threshold = m_config.health_check_threshold(); - node_infos.emplace_back(id, ip, mysql_port, health_port, health_check_threshold); + string name = "Clustrix-Server-" + std::to_string(id); - string health_url = "http://" + ip + ":" + std::to_string(health_port); - health_urls.push_back(health_url); + if (SERVER::find_by_unique_name(name) || + runtime_create_server(name.c_str(), + ip.c_str(), + std::to_string(mysql_port).c_str(), + "mariadbbackend", + "mysqlbackendauth", + false)) + { + node_infos.emplace_back(id, ip, mysql_port, health_port, health_check_threshold); + + string health_url = "http://" + ip + ":" + std::to_string(health_port); + health_urls.push_back(health_url); + } + else + { + MXS_ERROR("Could not create server %s at %s:%d.", + name.c_str(), ip.c_str(), mysql_port); + } } else {