MXS-1220: Add old router diagnostic interface

Added back the old diagnostic entry point to the router interface.
This commit is contained in:
Markus Mäkelä
2017-04-21 12:15:06 +03:00
committed by Markus Mäkelä
parent b1294f083c
commit fc887c7f5f
11 changed files with 769 additions and 18 deletions

View File

@ -302,7 +302,38 @@ SchemaRouterSession* SchemaRouter::newSession(MXS_SESSION* pSession)
return rval;
}
json_t* SchemaRouter::diagnostics() const
void SchemaRouter::diagnostics(DCB* dcb)
{
double sescmd_pct = m_stats.n_sescmd != 0 ?
100.0 * ((double)m_stats.n_sescmd / (double)m_stats.n_queries) :
0.0;
/** Session command statistics */
dcb_printf(dcb, "\n\33[1;4mSession Commands\33[0m\n");
dcb_printf(dcb, "Total number of queries: %d\n",
m_stats.n_queries);
dcb_printf(dcb, "Percentage of session commands: %.2f\n",
sescmd_pct);
dcb_printf(dcb, "Longest chain of stored session commands: %d\n",
m_stats.longest_sescmd);
dcb_printf(dcb, "Session command history limit exceeded: %d times\n",
m_stats.n_hist_exceeded);
/** Session time statistics */
if (m_stats.sessions > 0)
{
dcb_printf(dcb, "\n\33[1;4mSession Time Statistics\33[0m\n");
dcb_printf(dcb, "Longest session: %.2lf seconds\n", m_stats.ses_longest);
dcb_printf(dcb, "Shortest session: %.2lf seconds\n", m_stats.ses_shortest);
dcb_printf(dcb, "Average session length: %.2lf seconds\n", m_stats.ses_average);
}
dcb_printf(dcb, "Shard map cache hits: %d\n", m_stats.shmap_cache_hit);
dcb_printf(dcb, "Shard map cache misses: %d\n", m_stats.shmap_cache_miss);
dcb_printf(dcb, "\n");
}
json_t* SchemaRouter::diagnostics_json() const
{
double sescmd_pct = m_stats.n_sescmd != 0 ?
100.0 * ((double)m_stats.n_sescmd / (double)m_stats.n_queries) :