Added new metrics

* MyHGM_myconnpoll_destroy
* MyHGM_myconnpoll_get
* MyHGM_myconnpoll_get_ok
* MyHGM_myconnpoll_push
* MyHGM_myconnpoll_reset
* Queries_frontends_bytes_recv
* Queries_frontends_bytes_sent
bsd_install_update
René Cannaò 8 years ago
parent a8e8859b79
commit e8de8ee2c8

@ -198,6 +198,7 @@ class MySQL_HostGroups_Manager {
unsigned long myconnpoll_get_ok;
unsigned long myconnpoll_get_ping;
unsigned long myconnpoll_push;
unsigned long myconnpoll_reset;
unsigned long myconnpoll_destroy;
unsigned long long autocommit_cnt;
unsigned long long commit_cnt;
@ -253,6 +254,9 @@ class MySQL_HostGroups_Manager {
void update_group_replication_set_read_only(char *_hostname, int _port, int _writer_hostgroup, char *error);
void update_group_replication_set_writer(char *_hostname, int _port, int _writer_hostgroup);
void converge_group_replication_config(int _writer_hostgroup);
SQLite3_result *SQL3_Get_ConnPool_Stats();
void increase_reset_counter();
};
#endif /* __CLASS_MYSQL_HOSTGROUPS_MANAGER_H */

@ -218,6 +218,8 @@ class MySQL_Thread
unsigned long long queries_slow;
unsigned long long queries_backends_bytes_sent;
unsigned long long queries_backends_bytes_recv;
unsigned long long queries_frontends_bytes_sent;
unsigned long long queries_frontends_bytes_recv;
unsigned long long query_processor_time;
unsigned long long backend_query_time;
unsigned long long mysql_backend_buffers_bytes;
@ -461,6 +463,8 @@ class MySQL_Threads_Handler
unsigned long long get_slow_queries();
unsigned long long get_queries_backends_bytes_recv();
unsigned long long get_queries_backends_bytes_sent();
unsigned long long get_queries_frontends_bytes_recv();
unsigned long long get_queries_frontends_bytes_sent();
unsigned int get_active_transations();
#ifdef IDLE_THREADS
unsigned int get_non_idle_client_connections();

@ -84,6 +84,7 @@ static void * HGCU_thread_run() {
int i;
for (i=0;i<(int)l;i++) {
myconn->reset();
MyHGM->increase_reset_counter();
myconn=(MySQL_Connection *)conn_array->index(i);
if (myconn->mysql->net.vio && myconn->mysql->net.fd && myconn->mysql->net.buff) {
MySQL_Connection_userinfo *userinfo = myconn->userinfo;
@ -355,6 +356,7 @@ MySQL_HostGroups_Manager::MySQL_HostGroups_Manager() {
status.myconnpoll_get_ping=0;
status.myconnpoll_push=0;
status.myconnpoll_destroy=0;
status.myconnpoll_reset=0;
status.autocommit_cnt=0;
status.commit_cnt=0;
status.rollback_cnt=0;
@ -1218,6 +1220,11 @@ MyHGC * MySQL_HostGroups_Manager::MyHGC_lookup(unsigned int _hid) {
return myhgc;
}
void MySQL_HostGroups_Manager::increase_reset_counter() {
wrlock();
status.myconnpoll_reset++;
wrunlock();
}
void MySQL_HostGroups_Manager::push_MyConn_to_pool(MySQL_Connection *c, bool _lock) {
assert(c->parent);
MySrvC *mysrvc=NULL;
@ -2117,6 +2124,53 @@ void MySQL_HostGroups_Manager::set_server_current_latency_us(char *hostname, int
wrunlock();
}
SQLite3_result * MySQL_HostGroups_Manager::SQL3_Get_ConnPool_Stats() {
const int colnum=2;
char buf[256];
char **pta=(char **)malloc(sizeof(char *)*colnum);
proxy_debug(PROXY_DEBUG_MYSQL_CONNECTION, 4, "Dumping MySQL Global Status\n");
SQLite3_result *result=new SQLite3_result(colnum);
result->add_column_definition(SQLITE_TEXT,"Variable_Name");
result->add_column_definition(SQLITE_TEXT,"Variable_Value");
wrlock();
// NOTE: as there is no string copy, we do NOT free pta[0] and pta[1]
{
pta[0]=(char *)"MyHGM_myconnpoll_get";
sprintf(buf,"%lu",status.myconnpoll_get);
pta[1]=buf;
result->add_row(pta);
}
{
pta[0]=(char *)"MyHGM_myconnpoll_get_ok";
sprintf(buf,"%lu",status.myconnpoll_get_ok);
pta[1]=buf;
result->add_row(pta);
}
{
pta[0]=(char *)"MyHGM_myconnpoll_push";
sprintf(buf,"%lu",status.myconnpoll_push);
pta[1]=buf;
result->add_row(pta);
}
{
pta[0]=(char *)"MyHGM_myconnpoll_destroy";
sprintf(buf,"%lu",status.myconnpoll_destroy);
pta[1]=buf;
result->add_row(pta);
}
{
pta[0]=(char *)"MyHGM_myconnpoll_reset";
sprintf(buf,"%lu",status.myconnpoll_reset);
pta[1]=buf;
result->add_row(pta);
}
wrunlock();
free(pta);
return result;
}
unsigned long long MySQL_HostGroups_Manager::Get_Memory_Stats() {
unsigned long long intsize=0;
wrlock();

@ -3073,7 +3073,11 @@ bool MySQL_Thread::process_data_on_data_stream(MySQL_Data_Stream *myds, unsigned
if (mypolls.fds[n].revents) {
if (mypolls.myds[n]->DSS < STATE_MARIADB_BEGIN || mypolls.myds[n]->DSS > STATE_MARIADB_END) {
// only if we aren't using MariaDB Client Library
myds->read_from_net();
int rb = 0;
rb = myds->read_from_net();
if (rb > 0 && myds->myds_type == MYDS_FRONTEND) {
status_variables.queries_frontends_bytes_recv += rb;
}
myds->read_pkts();
} else {
if (mypolls.fds[n].revents) {
@ -3411,6 +3415,8 @@ MySQL_Thread::MySQL_Thread() {
status_variables.queries_slow=0;
status_variables.queries_backends_bytes_sent=0;
status_variables.queries_backends_bytes_recv=0;
status_variables.queries_frontends_bytes_sent=0;
status_variables.queries_frontends_bytes_recv=0;
status_variables.query_processor_time=0;
status_variables.backend_query_time=0;
status_variables.mysql_backend_buffers_bytes=0;
@ -3601,6 +3607,18 @@ SQLite3_result * MySQL_Threads_Handler::SQL3_GlobalStatus(bool _memory) {
pta[1]=buf;
result->add_row(pta);
}
{ // Queries bytes recv
pta[0]=(char *)"Queries_frontends_bytes_recv";
sprintf(buf,"%llu",get_queries_frontends_bytes_recv());
pta[1]=buf;
result->add_row(pta);
}
{ // Queries bytes recv
pta[0]=(char *)"Queries_frontends_bytes_sent";
sprintf(buf,"%llu",get_queries_frontends_bytes_sent());
pta[1]=buf;
result->add_row(pta);
}
{ // Query Processor Time
pta[0]=(char *)"Query_Processor_time_nsec";
sprintf(buf,"%llu",get_query_processor_time());
@ -4368,6 +4386,32 @@ unsigned long long MySQL_Threads_Handler::get_queries_backends_bytes_sent() {
return q;
}
unsigned long long MySQL_Threads_Handler::get_queries_frontends_bytes_recv() {
unsigned long long q=0;
unsigned int i;
for (i=0;i<num_threads;i++) {
if (mysql_threads) {
MySQL_Thread *thr=(MySQL_Thread *)mysql_threads[i].worker;
if (thr)
q+=__sync_fetch_and_add(&thr->status_variables.queries_frontends_bytes_recv,0);
}
}
return q;
}
unsigned long long MySQL_Threads_Handler::get_queries_frontends_bytes_sent() {
unsigned long long q=0;
unsigned int i;
for (i=0;i<num_threads;i++) {
if (mysql_threads) {
MySQL_Thread *thr=(MySQL_Thread *)mysql_threads[i].worker;
if (thr)
q+=__sync_fetch_and_add(&thr->status_variables.queries_frontends_bytes_sent,0);
}
}
return q;
}
unsigned int MySQL_Threads_Handler::get_active_transations() {
unsigned long long q=0;
unsigned int i;

@ -5023,6 +5023,24 @@ void ProxySQL_Admin::stats___mysql_global() {
}
delete resultset;
resultset=NULL;
resultset=MyHGM->SQL3_Get_ConnPool_Stats();
if (resultset) {
for (std::vector<SQLite3_row *>::iterator it = resultset->rows.begin() ; it != resultset->rows.end(); ++it) {
SQLite3_row *r=*it;
int arg_len=0;
for (int i=0; i<2; i++) {
arg_len+=strlen(r->fields[i]);
}
char *query=(char *)malloc(strlen(a)+arg_len+32);
sprintf(query,a,r->fields[0],r->fields[1]);
statsdb->execute(query);
free(query);
}
delete resultset;
resultset=NULL;
}
int highwater;
int current;
sqlite3_status(SQLITE_STATUS_MEMORY_USED, &current, &highwater, 0);

@ -342,6 +342,15 @@ int MySQL_Data_Stream::write_to_net() {
if (mypolls) mypolls->last_sent[poll_fds_idx]=sess->thread->curtime;
bytes_info.bytes_sent+=bytes_io;
}
if (bytes_io > 0) {
if (myds_type == MYDS_FRONTEND) {
if (sess) {
if (sess->thread) {
sess->thread->status_variables.queries_frontends_bytes_sent += bytes_io;
}
}
}
}
return bytes_io;
}

Loading…
Cancel
Save