MXS-1632: Filter out inactive servers
The statistics are only returned for active servers.
This commit is contained in:
@ -120,10 +120,13 @@ RWSplit::SrvStatMap RWSplit::all_server_stats() const
|
|||||||
for (const auto& a : m_server_stats.values())
|
for (const auto& a : m_server_stats.values())
|
||||||
{
|
{
|
||||||
for (const auto& b : a)
|
for (const auto& b : a)
|
||||||
|
{
|
||||||
|
if (b.first->is_active)
|
||||||
{
|
{
|
||||||
stats[b.first] += b.second;
|
stats[b.first] += b.second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return stats;
|
return stats;
|
||||||
}
|
}
|
||||||
@ -383,6 +386,7 @@ void RWSplit::diagnostics(DCB* dcb)
|
|||||||
dcb_printf(dcb, " Server Total Read Write\n");
|
dcb_printf(dcb, " Server Total Read Write\n");
|
||||||
for (const auto& s : srv_stats)
|
for (const auto& s : srv_stats)
|
||||||
{
|
{
|
||||||
|
mxb_assert(s.second.total == s.second.read + s.second.write);
|
||||||
dcb_printf(dcb,
|
dcb_printf(dcb,
|
||||||
" %s %10lu %10lu %10lu\n",
|
" %s %10lu %10lu %10lu\n",
|
||||||
s.first->name,
|
s.first->name,
|
||||||
@ -414,14 +418,11 @@ json_t* RWSplit::diagnostics_json() const
|
|||||||
json_object_set_new(rval, "weightby", json_string(weightby));
|
json_object_set_new(rval, "weightby", json_string(weightby));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto srv_stats = all_server_stats();
|
|
||||||
|
|
||||||
if (!srv_stats.empty())
|
|
||||||
{
|
|
||||||
json_t* arr = json_array();
|
json_t* arr = json_array();
|
||||||
|
|
||||||
for (const auto& a : srv_stats)
|
for (const auto& a : all_server_stats())
|
||||||
{
|
{
|
||||||
|
mxb_assert(a.second.total == a.second.read + a.second.write);
|
||||||
json_t* obj = json_object();
|
json_t* obj = json_object();
|
||||||
json_object_set_new(obj, "id", json_string(a.first->name));
|
json_object_set_new(obj, "id", json_string(a.first->name));
|
||||||
json_object_set_new(obj, "total", json_integer(a.second.total));
|
json_object_set_new(obj, "total", json_integer(a.second.total));
|
||||||
@ -431,7 +432,6 @@ json_t* RWSplit::diagnostics_json() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
json_object_set_new(rval, "server_query_statistics", arr);
|
json_object_set_new(rval, "server_query_statistics", arr);
|
||||||
}
|
|
||||||
|
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user