diff --git a/include/common/tglobal.h b/include/common/tglobal.h index 97f84f82d7d9055f85e9b7fb0422af0f0409b466..88ce0cd970ec3528f75221a4ab2768550e6fd358 100644 --- a/include/common/tglobal.h +++ b/include/common/tglobal.h @@ -32,7 +32,6 @@ extern char tsLocalEp[]; extern uint16_t tsServerPort; extern int32_t tsVersion; extern int32_t tsStatusInterval; -extern bool tsEnableTelemetryReporting; // common extern int32_t tsRpcTimer; @@ -82,6 +81,12 @@ extern uint16_t tsMonitorPort; extern int32_t tsMonitorMaxLogs; extern bool tsMonitorComp; +// telem +extern bool tsEnableTelem; +extern int32_t tsTelemInterval; +extern char tsTelemServer[]; +extern uint16_t tsTelemPort; + // query buffer management extern int32_t tsQueryBufferSize; // maximum allowed usage buffer size in MB for each data node during query processing extern int64_t tsQueryBufferSizeBytes; // maximum allowed usage buffer size in byte for each data node diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index 49f4afc12b88a30cb1083c8fa76094ff47564005..e9babc129852ca4ba26661f09285b14ccebea1ae 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -30,7 +30,6 @@ char tsLocalEp[TSDB_EP_LEN] = {0}; // Local End Point, hostname:port uint16_t tsServerPort = 6030; int32_t tsVersion = 30000000; int32_t tsStatusInterval = 1; // second -bool tsEnableTelemetryReporting = false; // common int32_t tsRpcTimer = 300; @@ -75,6 +74,12 @@ uint16_t tsMonitorPort = 6043; int32_t tsMonitorMaxLogs = 100; bool tsMonitorComp = false; +// telem +bool tsEnableTelem = false; +int32_t tsTelemInterval = 86400; +char tsTelemServer[TSDB_FQDN_LEN] = "telemetry.taosdata.com"; +uint16_t tsTelemPort = 80; + /* * denote if the server needs to compress response message at the application layer to client, including query rsp, * metricmeta rsp, and multi-meter query rsp message body. The client compress the submit message to server. @@ -354,7 +359,6 @@ static int32_t taosAddServerCfg(SConfig *pCfg) { if (cfgAddDir(pCfg, "dataDir", tsDataDir, 0) != 0) return -1; if (cfgAddFloat(pCfg, "minimalDataDirGB", 2.0f, 0.001f, 10000000, 0) != 0) return -1; if (cfgAddInt32(pCfg, "maxNumOfDistinctRes", tsMaxNumOfDistinctResults, 10 * 10000, 10000 * 10000, 0) != 0) return -1; - if (cfgAddBool(pCfg, "telemetryReporting", tsEnableTelemetryReporting, 0) != 0) return -1; if (cfgAddInt32(pCfg, "maxConnections", tsMaxConnections, 1, 100000, 0) != 0) return -1; if (cfgAddInt32(pCfg, "maxShellConns", tsMaxShellConns, 10, 50000000, 0) != 0) return -1; if (cfgAddInt32(pCfg, "statusInterval", tsStatusInterval, 1, 30, 0) != 0) return -1; @@ -430,12 +434,17 @@ static int32_t taosAddServerCfg(SConfig *pCfg) { if (cfgAddInt32(pCfg, "numOfSnodeUniqueThreads", tsNumOfSnodeUniqueThreads, 1, 1024, 0) != 0) return -1; if (cfgAddBool(pCfg, "monitor", tsEnableMonitor, 0) != 0) return -1; - if (cfgAddInt32(pCfg, "monitorInterval", tsMonitorInterval, 1, 360000, 0) != 0) return -1; + if (cfgAddInt32(pCfg, "monitorInterval", tsMonitorInterval, 1, 200000, 0) != 0) return -1; if (cfgAddString(pCfg, "monitorFqdn", tsMonitorFqdn, 0) != 0) return -1; if (cfgAddInt32(pCfg, "monitorPort", tsMonitorPort, 1, 65056, 0) != 0) return -1; if (cfgAddInt32(pCfg, "monitorMaxLogs", tsMonitorMaxLogs, 1, 1000000, 0) != 0) return -1; if (cfgAddBool(pCfg, "monitorComp", tsMonitorComp, 0) != 0) return -1; + if (cfgAddBool(pCfg, "telemetryReporting", tsEnableTelem, 0) != 0) return -1; + if (cfgAddInt32(pCfg, "telemetryInterval", tsTelemInterval, 1, 200000, 0) != 0) return -1; + if (cfgAddString(pCfg, "telemetryServer", tsTelemServer, 0) != 0) return -1; + if (cfgAddInt32(pCfg, "telemetryPort", tsTelemPort, 1, 65056, 0) != 0) return -1; + return 0; } @@ -528,7 +537,6 @@ static void taosSetSystemCfg(SConfig *pCfg) { static int32_t taosSetServerCfg(SConfig *pCfg) { tsDataSpace.reserved = cfgGetItem(pCfg, "minimalDataDirGB")->fval; tsMaxNumOfDistinctResults = cfgGetItem(pCfg, "maxNumOfDistinctRes")->i32; - tsEnableTelemetryReporting = cfgGetItem(pCfg, "telemetryReporting")->bval; tsMaxConnections = cfgGetItem(pCfg, "maxConnections")->i32; tsMaxShellConns = cfgGetItem(pCfg, "maxShellConns")->i32; tsStatusInterval = cfgGetItem(pCfg, "statusInterval")->i32; @@ -572,6 +580,11 @@ static int32_t taosSetServerCfg(SConfig *pCfg) { tsMonitorMaxLogs = cfgGetItem(pCfg, "monitorMaxLogs")->i32; tsMonitorComp = cfgGetItem(pCfg, "monitorComp")->bval; + tsEnableTelem = cfgGetItem(pCfg, "telemetryReporting")->bval; + tsTelemInterval = cfgGetItem(pCfg, "telemetryInterval")->i32; + tstrncpy(tsTelemServer, cfgGetItem(pCfg, "telemetryServer")->str, TSDB_FQDN_LEN); + tsTelemPort = (uint16_t)cfgGetItem(pCfg, "telemetryPort")->i32; + if (tsQueryBufferSize >= 0) { tsQueryBufferSizeBytes = tsQueryBufferSize * 1048576UL; } diff --git a/source/dnode/mnode/impl/inc/mndInt.h b/source/dnode/mnode/impl/inc/mndInt.h index 07e36c762254df32364f5b5a754077d7043e0022..b9ec1905e6875baaf379c83903795af777e0dcf6 100644 --- a/source/dnode/mnode/impl/inc/mndInt.h +++ b/source/dnode/mnode/impl/inc/mndInt.h @@ -67,7 +67,6 @@ typedef struct { } SProfileMgmt; typedef struct { - bool enable; SRWLatch lock; char email[TSDB_FQDN_LEN]; } STelemMgmt; diff --git a/source/dnode/mnode/impl/src/mndTelem.c b/source/dnode/mnode/impl/src/mndTelem.c index 83a5cf938fdbb4f051cd377aa4b4ec9e7e43cc5c..e445022548711a4c201572c8617672e59af48cd4 100644 --- a/source/dnode/mnode/impl/src/mndTelem.c +++ b/source/dnode/mnode/impl/src/mndTelem.c @@ -21,9 +21,6 @@ #include "thttp.h" #include "tjson.h" -#define TELEMETRY_SERVER "telemetry.taosdata.com" -#define TELEMETRY_PORT 80 - typedef struct { int64_t numOfDnode; int64_t numOfMnode; @@ -62,6 +59,12 @@ static void mndGetStat(SMnode* pMnode, SMnodeStat* pStat) { sdbRelease(pSdb, pVgroup); } + + pStat->numOfChildTable = 100; + pStat->numOfColumn = 200; + pStat->totalPoints = 300; + pStat->totalStorage = 400; + pStat->compStorage = 500; } static void mndBuildRuntimeInfo(SMnode* pMnode, SJson* pJson) { @@ -122,12 +125,14 @@ static char* mndBuildTelemetryReport(SMnode* pMnode) { static int32_t mndProcessTelemTimer(SNodeMsg* pReq) { SMnode* pMnode = pReq->pNode; STelemMgmt* pMgmt = &pMnode->telemMgmt; - if (!pMgmt->enable) return 0; + if (!tsEnableTelem) return 0; taosWLockLatch(&pMgmt->lock); char* pCont = mndBuildTelemetryReport(pMnode); if (pCont != NULL) { - taosSendHttpReport(TELEMETRY_SERVER, TELEMETRY_PORT, pCont, strlen(pCont), HTTP_FLAT); + if (taosSendHttpReport(tsTelemServer, tsTelemPort, pCont, strlen(pCont), HTTP_FLAT) != 0) { + mError("failed to send telemetry msg"); + } taosMemoryFree(pCont); } taosWUnLockLatch(&pMgmt->lock); @@ -138,7 +143,6 @@ int32_t mndInitTelem(SMnode* pMnode) { STelemMgmt* pMgmt = &pMnode->telemMgmt; taosInitRWLatch(&pMgmt->lock); - pMgmt->enable = tsEnableTelemetryReporting; taosGetEmail(pMgmt->email, sizeof(pMgmt->email)); mndSetMsgHandle(pMnode, TDMT_MND_TELEM_TIMER, mndProcessTelemTimer); diff --git a/source/dnode/mnode/impl/src/mnode.c b/source/dnode/mnode/impl/src/mnode.c index 13fe01e16ebd04bfed5d342d34b35c23a1c045d9..3b7d955c02dacde7901649cde2cc04f2e60d6355 100644 --- a/source/dnode/mnode/impl/src/mnode.c +++ b/source/dnode/mnode/impl/src/mnode.c @@ -45,7 +45,6 @@ #define MQ_TIMER_MS 3000 #define TRNAS_TIMER_MS 6000 -#define TELEM_TIMER_MS 86400000 static void *mndBuildTimerMsg(int32_t *pContLen) { SMTimerReq timerReq = {0}; @@ -97,7 +96,7 @@ static void mndPullupTelem(void *param, void *tmrId) { tmsgPutToQueue(&pMnode->msgCb, READ_QUEUE, &rpcMsg); } - taosTmrReset(mndPullupTelem, TELEM_TIMER_MS, pMnode, pMnode->timer, &pMnode->telemTimer); + taosTmrReset(mndPullupTelem, tsTelemInterval * 1000, pMnode, pMnode->timer, &pMnode->telemTimer); } static int32_t mndInitTimer(SMnode *pMnode) { @@ -117,7 +116,8 @@ static int32_t mndInitTimer(SMnode *pMnode) { return -1; } - if (taosTmrReset(mndPullupTelem, 60000, pMnode, pMnode->timer, &pMnode->telemTimer)) { + int32_t interval = tsTelemInterval < 10 ? tsTelemInterval : 10; + if (taosTmrReset(mndPullupTelem, interval * 1000, pMnode, pMnode->timer, &pMnode->telemTimer)) { terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; } diff --git a/tests/script/tmp/data.sim b/tests/script/tmp/data.sim index 92fc9dccc92903331ea304d45ea1f918a4318e61..4e714c01ee29fb0b29b679c1d123de429b52d785 100644 --- a/tests/script/tmp/data.sim +++ b/tests/script/tmp/data.sim @@ -1,9 +1,14 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c telemetryReporting -v 1 +system sh/cfg.sh -n dnode1 -c telemetryInterval -v 1 +system sh/cfg.sh -n dnode1 -c telemetryServer -v localhost +system sh/cfg.sh -n dnode1 -c telemetryPort -v 80 + +return system sh/exec.sh -n dnode1 -s start sql connect -return sql create database db sql create table db.tb (ts timestamp, i int) sql insert into db.tb values(now, 1)