Merge pull request #5317 from sysown/v3.0.6-implement_FLUSH_STATS

implement admin command 'PROXYSQL FLUSH STATS'
pull/5345/head
René Cannaò 3 months ago committed by GitHub
commit 77fe582801
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -892,5 +892,12 @@ class ProxySQL_Admin {
// FLUSH LOGS
void flush_logs();
#ifdef DEBUG
// FLUSH STATS
void flush_stats(); // Reset all statistics
void flush_mysql_stats(); // Reset MySQL statistics only
void flush_pgsql_stats(); // Reset PostgreSQL statistics only
#endif // DEBUG
};
#endif /* __CLASS_PROXYSQL_ADMIN_H */

@ -808,6 +808,32 @@ bool admin_handler_command_proxysql(char *query_no_space, unsigned int query_no_
return false;
}
#ifdef DEBUG
if (query_no_space_length == strlen("PROXYSQL FLUSH STATS") && !strncasecmp("PROXYSQL FLUSH STATS", query_no_space, query_no_space_length)) {
proxy_info("Received PROXYSQL FLUSH STATS command\n");
ProxySQL_Admin *SPA = (ProxySQL_Admin *)pa;
SPA->flush_stats();
SPA->send_ok_msg_to_client(sess, NULL, 0, query_no_space);
return false;
}
if (query_no_space_length == strlen("PROXYSQL FLUSH MYSQL STATS") && !strncasecmp("PROXYSQL FLUSH MYSQL STATS", query_no_space, query_no_space_length)) {
proxy_info("Received PROXYSQL FLUSH MYSQL STATS command\n");
ProxySQL_Admin *SPA = (ProxySQL_Admin *)pa;
SPA->flush_mysql_stats();
SPA->send_ok_msg_to_client(sess, NULL, 0, query_no_space);
return false;
}
if (query_no_space_length == strlen("PROXYSQL FLUSH PGSQL STATS") && !strncasecmp("PROXYSQL FLUSH PGSQL STATS", query_no_space, query_no_space_length)) {
proxy_info("Received PROXYSQL FLUSH PGSQL STATS command\n");
ProxySQL_Admin *SPA = (ProxySQL_Admin *)pa;
SPA->flush_pgsql_stats();
SPA->send_ok_msg_to_client(sess, NULL, 0, query_no_space);
return false;
}
#endif // DEBUG
if (strcasecmp("PROXYSQL RELOAD TLS",query_no_space) == 0) {
proxy_info("Received %s command\n", query_no_space);
ProxySQL_Admin *SPA=(ProxySQL_Admin *)pa;

@ -1116,6 +1116,47 @@ void ProxySQL_Admin::flush_logs() {
proxy_debug(PROXY_DEBUG_ADMIN, 1, "Running PROXYSQL FLUSH LOGS\n");
}
#ifdef DEBUG
void ProxySQL_Admin::flush_stats() {
flush_mysql_stats();
flush_pgsql_stats();
}
void ProxySQL_Admin::flush_mysql_stats() {
if (!GloMyQPro || !GloMTH || !MyHGM) {
proxy_info("MySQL statistics flush skipped: MySQL modules not initialized\n");
return;
}
// Reset MySQL query digest statistics
stats___mysql_query_digests_v2(true, false, false);
// Reset MySQL error statistics
stats___mysql_errors(true);
// Reset MySQL connection pool statistics
stats___mysql_connection_pool(true);
// Reset MySQL client host cache
stats___mysql_client_host_cache(true);
proxy_info("MySQL statistics flushed successfully\n");
}
void ProxySQL_Admin::flush_pgsql_stats() {
if (!GloPgQPro || !GloPTH || !PgHGM) {
proxy_info("PgSQL statistics flush skipped: PgSQL modules not initialized\n");
return;
}
// Reset PostgreSQL query digest statistics
stats___pgsql_query_digests_v2(true, false, false);
// Reset PostgreSQL error statistics
stats___pgsql_errors(true);
// Reset PostgreSQL connection pool statistics
stats___pgsql_connection_pool(true);
// Reset PostgreSQL client host cache
stats___pgsql_client_host_cache(true);
proxy_info("PgSQL statistics flushed successfully\n");
}
#endif // DEBUG
// Explicitly instantiate the required template class and member functions
// NOTE: send_ok_msg_to_client and send_error_msg_to_client instantiations moved to after definitions (near line 5730)
template int ProxySQL_Admin::FlushDigestTableToDisk<(SERVER_TYPE)0>(SQLite3DB*);

@ -27,6 +27,9 @@ std::vector<std::string> queries = {
"PROXYSQL FLUSH LOGS",
"PROXYSQL FLUSH QUERY CACHE",
"PROXYSQL FLUSH CONFIGDB",
"PROXYSQL FLUSH STATS",
"PROXYSQL FLUSH MYSQL STATS",
"PROXYSQL FLUSH PGSQL STATS",
"PROXYSQLTEST 21",
"PROXYSQLTEST 21 10",
"PROXYSQLTEST 41",

Loading…
Cancel
Save