MXS-2275 Always log monitor instance name

When logging something, always log the monitor instance name
as well.
This commit is contained in:
Johan Wikman
2019-01-31 16:53:29 +02:00
parent cb07687672
commit 6d60714a17
4 changed files with 46 additions and 39 deletions

View File

@ -87,7 +87,7 @@ Clustrix::SubState Clustrix::substate_from_string(const std::string& substate)
} }
} }
bool Clustrix::is_part_of_the_quorum(const SERVER& server, MYSQL* pCon) bool Clustrix::is_part_of_the_quorum(const char* zName, const SERVER& server, MYSQL* pCon)
{ {
bool rv = false; bool rv = false;
@ -124,18 +124,20 @@ bool Clustrix::is_part_of_the_quorum(const SERVER& server, MYSQL* pCon)
break; break;
case Clustrix::Status::STATIC: case Clustrix::Status::STATIC:
MXS_NOTICE("Node %s:%d is not part of the quorum, switching to " MXS_NOTICE("%s: Node %s:%d is not part of the quorum, switching to "
"other node for monitoring.", zAddress, port); "other node for monitoring.",
zName, zAddress, port);
break; break;
case Clustrix::Status::UNKNOWN: case Clustrix::Status::UNKNOWN:
MXS_WARNING("Do not know how to interpret '%s'. Assuming node %s:%d " MXS_WARNING("%s: Do not know how to interpret '%s'. Assuming node %s:%d "
"is not part of the quorum.", row[0], zAddress, port); "is not part of the quorum.",
zName, row[0], zAddress, port);
} }
} }
else else
{ {
MXS_WARNING("No status returned for '%s' on %s:%d.", zQuery, zAddress, port); MXS_WARNING("%s: No status returned for '%s' on %s:%d.", zName, zQuery, zAddress, port);
} }
} }
@ -143,12 +145,12 @@ bool Clustrix::is_part_of_the_quorum(const SERVER& server, MYSQL* pCon)
} }
else else
{ {
MXS_WARNING("No result returned for '%s' on %s:%d.", zQuery, zAddress, port); MXS_WARNING("%s: No result returned for '%s' on %s:%d.", zName, zQuery, zAddress, port);
} }
} }
else else
{ {
MXS_ERROR("Could not execute '%s' on %s:%d: %s", zQuery, zAddress, port, mysql_error(pCon)); MXS_ERROR("%s: Could not execute '%s' on %s:%d: %s", zName, zQuery, zAddress, port, mysql_error(pCon));
} }
return rv; return rv;
@ -162,15 +164,15 @@ bool Clustrix::ping_or_connect_to_hub(const MXS_MONITORED_SERVER::ConnectionSett
if (mon_connection_is_ok(rv)) if (mon_connection_is_ok(rv))
{ {
if (Clustrix::is_part_of_the_quorum(server, *ppCon)) if (Clustrix::is_part_of_the_quorum(mon.m_name, server, *ppCon))
{ {
connected = true; connected = true;
} }
} }
else else
{ {
MXS_ERROR("Could either not ping or create connection to %s:%d: %s", MXS_ERROR("%s: Could either not ping or create connection to %s:%d: %s",
server.address, server.port, mysql_error(*ppCon)); mon.m_name, server.address, server.port, mysql_error(*ppCon));
} }
return connected; return connected;

View File

@ -42,26 +42,28 @@ std::string to_string(SubState sub_state);
/** /**
* Is a particular Clustrix node part of the quorum. * Is a particular Clustrix node part of the quorum.
* *
* @param zName The name of the Clustrix monitor instance.
* @param server The server object of a Clustrix node. * @param server The server object of a Clustrix node.
* @param pCon Valid MYSQL handle to the server. * @param pCon Valid MYSQL handle to the server.
* *
* @return True, if the node is part of the quorum, false otherwise. * @return True, if the node is part of the quorum, false otherwise.
*/ */
bool is_part_of_the_quorum(const SERVER& server, MYSQL* pCon); bool is_part_of_the_quorum(const char* zName, const SERVER& server, MYSQL* pCon);
/** /**
* Is a particular Clustrix node part of the quorum. * Is a particular Clustrix node part of the quorum.
* *
* @param zName The name of the Clustrix monitor instance.
* @param ms The monitored server object of a Clustrix node. * @param ms The monitored server object of a Clustrix node.
* *
* @return True, if the node is part of the quorum, false otherwise. * @return True, if the node is part of the quorum, false otherwise.
*/ */
inline bool is_part_of_the_quorum(MXS_MONITORED_SERVER& ms) inline bool is_part_of_the_quorum(const char* zName, MXS_MONITORED_SERVER& ms)
{ {
mxb_assert(ms.server); mxb_assert(ms.server);
mxb_assert(ms.con); mxb_assert(ms.con);
return is_part_of_the_quorum(*ms.server, ms.con); return is_part_of_the_quorum(zName, *ms.server, ms.con);
} }
/** /**

View File

@ -61,7 +61,7 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE()
{ {
{ {
MODULECMD_ARG_MONITOR | MODULECMD_ARG_NAME_MATCHES_DOMAIN, MODULECMD_ARG_MONITOR | MODULECMD_ARG_NAME_MATCHES_DOMAIN,
"Monitor name (from configuration file" "Monitor name (from configuration file)"
}, },
{ {
MODULECMD_ARG_SERVER, "Node to be softfailed." MODULECMD_ARG_SERVER, "Node to be softfailed."
@ -76,7 +76,7 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE()
{ {
{ {
MODULECMD_ARG_MONITOR | MODULECMD_ARG_NAME_MATCHES_DOMAIN, MODULECMD_ARG_MONITOR | MODULECMD_ARG_NAME_MATCHES_DOMAIN,
"Monitor name (from configuration file" "Monitor name (from configuration file)"
}, },
{ {
MODULECMD_ARG_SERVER, "Node to be unsoftfailed." MODULECMD_ARG_SERVER, "Node to be unsoftfailed."

View File

@ -135,11 +135,11 @@ void ClustrixMonitor::tick()
switch (m_http.status()) switch (m_http.status())
{ {
case http::Async::PENDING: case http::Async::PENDING:
MXS_WARNING("Health check round had not completed when next tick arrived."); MXS_WARNING("%s: Health check round had not completed when next tick arrived.", m_name);
break; break;
case http::Async::ERROR: case http::Async::ERROR:
MXS_WARNING("Health check round ended with general error."); MXS_WARNING("%s: Health check round ended with general error.", m_name);
make_health_check(); make_health_check();
break; break;
@ -206,8 +206,8 @@ void ClustrixMonitor::choose_hub()
if (pHub_con) if (pHub_con)
{ {
MXS_NOTICE("Monitoring Clustrix cluster state using node %s:%d.", MXS_NOTICE("%s: Monitoring Clustrix cluster state using node %s:%d.",
pHub_server->address, pHub_server->port); m_name, pHub_server->address, pHub_server->port);
m_pHub_con = pHub_con; m_pHub_con = pHub_con;
m_pHub_server = pHub_server; m_pHub_server = pHub_server;
@ -217,8 +217,8 @@ void ClustrixMonitor::choose_hub()
} }
else else
{ {
MXS_ERROR("Could not connect to any server or no server that could " MXS_ERROR("%s: Could not connect to any server or no server that could "
"be connected to was part of the quorum."); "be connected to was part of the quorum.", m_name);
} }
} }
@ -313,8 +313,8 @@ void ClustrixMonitor::refresh_nodes()
} }
else else
{ {
MXS_ERROR("Could not create server %s at %s:%d.", MXS_ERROR("%s: Could not create server %s at %s:%d.",
name.c_str(), ip.c_str(), mysql_port); m_name, name.c_str(), ip.c_str(), mysql_port);
} }
memberships.erase(mit); memberships.erase(mit);
@ -322,14 +322,15 @@ void ClustrixMonitor::refresh_nodes()
else else
{ {
// Node found in system.node_info but not in system.membership // Node found in system.node_info but not in system.membership
MXS_ERROR("Node %d at %s:%d,%d found in system.node_info " MXS_ERROR("%s: Node %d at %s:%d,%d found in system.node_info "
"but not in system.membership.", "but not in system.membership.",
id, ip.c_str(), mysql_port, health_port); m_name, id, ip.c_str(), mysql_port, health_port);
} }
} }
else else
{ {
MXS_WARNING("Either nodeid and/or iface_ip is missing, ignoring node."); MXS_WARNING("%s: Either nodeid and/or iface_ip is missing, ignoring node.",
m_name);
} }
} }
@ -359,13 +360,14 @@ void ClustrixMonitor::refresh_nodes()
} }
else else
{ {
MXS_WARNING("No result returned for '%s' on %s.", ZQUERY, m_pHub_server->address); MXS_WARNING("%s: No result returned for '%s' on %s.",
m_name, ZQUERY, m_pHub_server->address);
} }
} }
else else
{ {
MXS_ERROR("Could not execute '%s' on %s: %s", MXS_ERROR("%s: Could not execute '%s' on %s: %s",
ZQUERY, m_pHub_server->address, mysql_error(m_pHub_con)); m_name, ZQUERY, m_pHub_server->address, mysql_error(m_pHub_con));
} }
} }
} }
@ -460,7 +462,8 @@ bool ClustrixMonitor::check_cluster_membership(std::map<int, ClustrixMembership>
} }
else else
{ {
MXS_WARNING("No node id returned in row for '%s'.", ZQUERY); MXS_WARNING("%s: No node id returned in row for '%s'.",
m_name, ZQUERY);
} }
} }
@ -481,13 +484,13 @@ bool ClustrixMonitor::check_cluster_membership(std::map<int, ClustrixMembership>
} }
else else
{ {
MXS_WARNING("No result returned for '%s'.", ZQUERY); MXS_WARNING("%s: No result returned for '%s'.", m_name, ZQUERY);
} }
} }
else else
{ {
MXS_ERROR("Could not execute '%s' on %s: %s", MXS_ERROR("%s: Could not execute '%s' on %s: %s",
ZQUERY, m_pHub_server->address, mysql_error(m_pHub_con)); m_name, ZQUERY, m_pHub_server->address, mysql_error(m_pHub_con));
} }
return rv; return rv;
@ -540,11 +543,11 @@ void ClustrixMonitor::make_health_check()
break; break;
case http::Async::ERROR: case http::Async::ERROR:
MXS_ERROR("Could not initiate health check."); MXS_ERROR("%s: Could not initiate health check.", m_name);
break; break;
case http::Async::READY: case http::Async::READY:
MXS_NOTICE("Health check available immediately."); MXS_INFO("%s: Health check available immediately.", m_name);
break; break;
} }
} }
@ -602,7 +605,7 @@ bool ClustrixMonitor::check_http(Call::action_t action)
break; break;
case http::Async::ERROR: case http::Async::ERROR:
MXS_ERROR("Health check waiting ended with general error."); MXS_ERROR("%s: Health check waiting ended with general error.", m_name);
} }
} }
@ -655,7 +658,7 @@ bool ClustrixMonitor::perform_operation(Operation operation,
if (mysql_query(m_pHub_con, zQuery) == 0) if (mysql_query(m_pHub_con, zQuery) == 0)
{ {
MXS_NOTICE("Clustrix monitor %s performed %s on node %d (%s).", MXS_NOTICE("%s: %s performed on node %d (%s).",
m_name, zOperation, id, pServer->address); m_name, zOperation, id, pServer->address);
if (operation == Operation::SOFTFAIL) if (operation == Operation::SOFTFAIL)