From dee35186a89f40e7467d11bfdb2081e3faca9111 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Sun, 19 Nov 2017 13:23:49 +0100 Subject: [PATCH] Web UI displays some real values It displays: - uptime - Detected OS - if idle threads is enabled - if Monitor is enabled --- include/proxysql_structs.h | 1 + lib/ProxySQL_GloVars.cpp | 1 + lib/ProxySQL_HTTP_Server.cpp | 64 ++++++++++++++++++++++++++++++++---- 3 files changed, 59 insertions(+), 7 deletions(-) diff --git a/include/proxysql_structs.h b/include/proxysql_structs.h index efdaf25de..fc359adf8 100644 --- a/include/proxysql_structs.h +++ b/include/proxysql_structs.h @@ -465,6 +465,7 @@ struct _global_variables_t { pthread_rwlock_t rwlock_usernames; bool has_debug; + bool idle_threads; volatile int shutdown; bool nostart; diff --git a/lib/ProxySQL_GloVars.cpp b/lib/ProxySQL_GloVars.cpp index 1aa345a73..112ee9d2a 100644 --- a/lib/ProxySQL_GloVars.cpp +++ b/lib/ProxySQL_GloVars.cpp @@ -174,6 +174,7 @@ void ProxySQL_GlobalVariables::process_opts_pre() { #ifdef IDLE_THREADS if (opt->isSet("--idle-threads")) { global.idle_threads=true; + glovars.idle_threads=true; } #endif /* IDLE_THREADS */ diff --git a/lib/ProxySQL_HTTP_Server.cpp b/lib/ProxySQL_HTTP_Server.cpp index 1b45f472d..5e7b4063d 100644 --- a/lib/ProxySQL_HTTP_Server.cpp +++ b/lib/ProxySQL_HTTP_Server.cpp @@ -38,6 +38,7 @@ //extern struct MHD_Daemon *Admin_HTTP_Server; extern ProxySQL_Statistics *GloProxyStats; +extern MySQL_Threads_Handler *GloMTH; extern char * Chart_bundle_js_c; extern char * font_awesome; @@ -82,19 +83,68 @@ static char *generate_home() { html.append("\n"); //html.append("\n"); html.append("\n"); - html.append("Uptime = 0d 0h00m44s
\n"); - html.append("OS version = CentOS 7.3
\n"); - html.append("Worker threads = 8
\n"); - html.append("Idle threads = enabled
\n"); - html.append("Monitor = enabled
\n"); + html.append("Uptime = "); + { + unsigned long long t1=monotonic_time(); + char buf1[30]; + unsigned long long uptime = (t1-GloVars.global.start_time)/1000/1000; + unsigned long long days = uptime / 86400; + unsigned long long hours = (uptime - days*86400)/3600; + unsigned long long mins = (uptime % 3600)/60; + unsigned long long secs = uptime % 60; + sprintf(buf1,"%llud %02lluh%02llum%02llus", days, hours, mins, secs); + html.append(buf1); + } + html.append("
\n"); + html.append("OS version = "); + { + struct utsname unameData; + int rc; + rc=uname(&unameData); + if (rc==0) { + html.append(unameData.sysname); html.append(" "); + html.append(unameData.nodename); html.append(" "); + html.append(unameData.release); html.append(" "); + html.append(unameData.machine); + } else { + html.append("UNKNOWN"); + } + } + html.append("
\n"); + html.append("Worker threads = "); + { + char buf[16]; + sprintf(buf,"%u",GloMTH->num_threads); + html.append(buf); + } + html.append("
\n"); + html.append("Idle threads = "); + if (glovars.idle_threads) { + html.append("enabled"); + } else { + html.append(" disabled "); + } + html.append("
\n"); + html.append("Monitor = "); + { + char *en = GloMTH->get_variable("monitor_enabled"); + if (en && strcmp(en,"true")==0) { + html.append("enabled"); + } else { + html.append(" disabled "); + } + if (en) { + free(en); + } + } + html.append("
\n"); html.append("\n"); html.append("\n"); html.append("ProxySQL version = 1.4.3
\n"); html.append("ProxySQL latest = 1.4.4
\n"); html.append("\n"); html.append("\n"); - //html.append("\n"); - html.append("ProxySQL version = 1.4.3
\n"); + html.append("ProxySQL version = "); html.append(PROXYSQL_VERSION); html.append("
\n"); html.append("ProxySQL latest = 1.4.4
\n"); html.append("\n"); html.append("\n");