Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ProxySQL_Uptime status. It is ProxySQL running time (unit: seconds) #947

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/MySQL_Thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ extern MySQL_Authentication *GloMyAuth;
extern MySQL_Threads_Handler *GloMTH;
extern MySQL_Monitor *GloMyMon;
extern MySQL_Logger *GloMyLogger;
extern time_t proxysql_starttime;

const CHARSET_INFO * proxysql_find_charset_nr(unsigned int nr) {
const CHARSET_INFO * c = compiled_charsets;
Expand Down Expand Up @@ -2979,6 +2980,7 @@ void MySQL_Thread::listener_handle_new_connection(MySQL_Data_Stream *myds, unsig

SQLite3_result * MySQL_Threads_Handler::SQL3_GlobalStatus() {
const int colnum=2;
time_t proxysql_refresh_globalstatus_time = time(NULL);
char buf[256];
char **pta=(char **)malloc(sizeof(char *)*colnum);
Get_Memory_Stats();
Expand All @@ -2987,6 +2989,12 @@ SQLite3_result * MySQL_Threads_Handler::SQL3_GlobalStatus() {
result->add_column_definition(SQLITE_TEXT,"Variable_Name");
result->add_column_definition(SQLITE_TEXT,"Variable_Value");
// NOTE: as there is no string copy, we do NOT free pta[0] and pta[1]
{
pta[0] = (char *)"ProxySQL_Uptime";
sprintf(buf,"%lld",(long long)(proxysql_refresh_globalstatus_time - proxysql_starttime));
pta[1] = buf;
result->add_row(pta);
}
{ // Active Transactions
pta[0]=(char *)"Active_Transactions";
sprintf(buf,"%u",get_active_transations());
Expand Down
1 change: 1 addition & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@


time_t laststart;
time_t proxysql_starttime = time(NULL);
pid_t pid;

static const char * proxysql_pid_file() {
Expand Down