Status variables per #366

- Queries_backends_bytes_recv
- Queries_backends_bytes_sent

Closes #366
pull/378/head
René Cannaò 11 years ago
parent 4bf5fda572
commit 6fc9bb3dad

@ -158,9 +158,14 @@ class MySQL_Thread
int shutdown;
PtrArray *mysql_sessions;
// status variables are per thread only
// in this way, there is no need for atomic operation and there is no cache miss
// when it is needed a total, all threads are checked
struct {
unsigned long long queries;
unsigned long long queries_slow;
unsigned long long queries_backends_bytes_sent;
unsigned long long queries_backends_bytes_recv;
} status_variables;
@ -323,6 +328,8 @@ class MySQL_Threads_Handler
bool kill_session(uint32_t _thread_session_id);
unsigned long long get_total_queries();
unsigned long long get_slow_queries();
unsigned long long get_queries_backends_bytes_recv();
unsigned long long get_queries_backends_bytes_sent();
};

@ -1677,6 +1677,8 @@ MySQL_Thread::MySQL_Thread() {
status_variables.queries=0;
status_variables.queries_slow=0;
status_variables.queries_backends_bytes_sent=0;
status_variables.queries_backends_bytes_recv=0;
}
@ -1787,6 +1789,18 @@ SQLite3_result * MySQL_Threads_Handler::SQL3_GlobalStatus() {
pta[1]=buf;
result->add_row(pta);
}
{ // Queries bytes recv
pta[0]=(char *)"Queries_backends_bytes_recv";
sprintf(buf,"%llu",get_queries_backends_bytes_recv());
pta[1]=buf;
result->add_row(pta);
}
{ // Queries bytes recv
pta[0]=(char *)"Queries_backends_bytes_sent";
sprintf(buf,"%llu",get_queries_backends_bytes_sent());
pta[1]=buf;
result->add_row(pta);
}
{ // Queries
pta[0]=(char *)"Questions";
sprintf(buf,"%llu",get_total_queries());
@ -2019,3 +2033,29 @@ unsigned long long MySQL_Threads_Handler::get_slow_queries() {
}
return q;
}
unsigned long long MySQL_Threads_Handler::get_queries_backends_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_backends_bytes_recv,0);
}
}
return q;
}
unsigned long long MySQL_Threads_Handler::get_queries_backends_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_backends_bytes_sent,0);
}
}
return q;
}

@ -466,6 +466,7 @@ handler_again:
real_query_start();
__sync_fetch_and_add(&parent->queries_sent,1);
__sync_fetch_and_add(&parent->bytes_sent,query.length);
myds->sess->thread->status_variables.queries_backends_bytes_sent+=query.length;
if (async_exit_status) {
next_event(ASYNC_QUERY_CONT);
} else {
@ -534,6 +535,7 @@ handler_again:
if (mysql_row) {
unsigned int br=MyRS->add_row(mysql_row);
__sync_fetch_and_add(&parent->bytes_recv,br);
myds->sess->thread->status_variables.queries_backends_bytes_recv+=br;
NEXT_IMMEDIATE(ASYNC_USE_RESULT_CONT);
} else {
MyRS->add_eof();

Loading…
Cancel
Save