diff --git a/documentation20/webdocs/markdowndocs/Connections with other Tools-ch.md b/documentation20/webdocs/markdowndocs/Connections with other Tools-ch.md index 34be7d1e76..d62a525e28 100644 --- a/documentation20/webdocs/markdowndocs/Connections with other Tools-ch.md +++ b/documentation20/webdocs/markdowndocs/Connections with other Tools-ch.md @@ -31,7 +31,7 @@ TDengine的Grafana插件在安装包的/usr/local/taos/connector/grafana目录 ![img](../assets/add_datasource3.jpg) -* Host: TDengine 集群的中任意一台服务器的 IP 地址与 TDengine RESTful 接口的端口号(6020),默认 http://localhost:6020。 +* Host: TDengine 集群的中任意一台服务器的 IP 地址与 TDengine RESTful 接口的端口号(6041),默认 http://localhost:6041 * User:TDengine 用户名。 * Password:TDengine 用户密码。 diff --git a/documentation20/webdocs/markdowndocs/connector-ch.md b/documentation20/webdocs/markdowndocs/connector-ch.md index 95b4af5c7c..511bf5a9a7 100644 --- a/documentation20/webdocs/markdowndocs/connector-ch.md +++ b/documentation20/webdocs/markdowndocs/connector-ch.md @@ -846,7 +846,7 @@ curl http://192.168.0.1:6041/rest/login/root/taosdata - 在demo库里查询表d1001的所有记录: ``` -curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'select * from demo.d1001' 192.168.0.1:6041/rest/sql` +curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'select * from demo.d1001' 192.168.0.1:6041/rest/sql ``` 返回值: @@ -865,7 +865,7 @@ curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'select * from demo.d1001 - 创建库demo: ``` -curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'create database demo' 192.168.0.1:6041/rest/sql` +curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'create database demo' 192.168.0.1:6041/rest/sql ``` 返回值: diff --git a/minidevops/grafana/tdengine/partials/config.html b/minidevops/grafana/tdengine/partials/config.html index 801a753271..f12eb86354 100644 --- a/minidevops/grafana/tdengine/partials/config.html +++ b/minidevops/grafana/tdengine/partials/config.html @@ -3,7 +3,7 @@
Host - +
diff --git a/minidevops/run.sh b/minidevops/run.sh index 15e74d0e5a..77f1186633 100755 --- a/minidevops/run.sh +++ b/minidevops/run.sh @@ -13,13 +13,13 @@ docker network create --ip-range 172.15.1.255/24 --subnet 172.15.1.1/16 minidevo docker run -d --net minidevops --ip 172.15.1.11 -v $LP/grafana:/var/lib/grafana/plugins -p 3000:3000 grafana/grafana #docker run -d --net minidevops --ip 172.15.1.11 -v /Users/tom/Documents/minidevops/grafana:/var/lib/grafana/plugins -p 3000:3000 grafana/grafana -TDENGINE=`docker run -d --net minidevops --ip 172.15.1.6 -p 6030:6030 -p 6020:6020 -p 6031:6031 -p 6032:6032 -p 6033:6033 -p 6034:6034 -p 6035:6035 -p 6036:6036 -p 6037:6037 -p 6038:6038 -p 6039:6039 tdengine/tdengine:1.6.4.5` +TDENGINE=`docker run -d --net minidevops --ip 172.15.1.6 -p 6030:6030 -p 6020:6020 -p 6031:6031 -p 6032:6032 -p 6033:6033 -p 6034:6034 -p 6035:6035 -p 6036:6036 -p 6037:6037 -p 6038:6038 -p 6039:6039 -p 6040:6040 -p 6041:6041 -h '172.15.1.6' tdengine/tdengine:2.0.0.0` docker cp /etc/localtime $TDENGINE:/etc/localtime -BLMPROMETHEUS=`docker run -d --net minidevops --ip 172.15.1.7 -p 10203:10203 tdengine/blm_prometheus 172.15.1.6` +BLMPROMETHEUS=`docker run -d --net minidevops --ip 172.15.1.7 -v $(pwd)/taos:/etc/taos -p 10203:10203 tdengine/blm_prometheus:2.0.0.0 -tdengine-name 172.15.1.6 -tdengine-api-port 6041` -BLMPTELEGRAF=`docker run -d --net minidevops --ip 172.15.1.8 -p 10202:10202 tdengine/blm_telegraf 172.15.1.6` +BLMPTELEGRAF=`docker run -d --net minidevops --ip 172.15.1.8 -p 10202:10202 tdengine/blm_telegraf:2.0.0.0 -host 172.15.1.6` docker run -d --net minidevops --ip 172.15.1.9 -v $LP/prometheus:/etc/prometheus -p 9090:9090 prom/prometheus #docker run -d --net minidevops --ip 172.15.1.9 -v /Users/tom/Documents/minidevops/prometheus:/etc/prometheus -p 9090:9090 prom/prometheus @@ -29,7 +29,7 @@ docker run -d --net minidevops --ip 172.15.1.10 -v $LP/telegraf:/etc/telegraf -p sleep 10 -curl -X POST http://localhost:3000/api/datasources --header "Content-Type:application/json" -u admin:admin -d '{"Name": "TDengine","Type": "tdengine","TypeLogoUrl": "public/plugins/tdengine/img/taosdata_logo.png","Access": "proxy","Url": "http://172.15.1.6:6020","BasicAuth": false,"isDefault": true,"jsonData": {},"readOnly": false}' +curl -X POST http://localhost:3000/api/datasources --header "Content-Type:application/json" -u admin:admin -d '{"Name": "TDengine","Type": "tdengine","TypeLogoUrl": "public/plugins/tdengine/img/taosdata_logo.png","Access": "proxy","Url": "http://172.15.1.6:6041","BasicAuth": false,"isDefault": true,"jsonData": {},"readOnly": false}' curl -X POST http://localhost:3000/api/dashboards/db --header "Content-Type:application/json" -u admin:admin -d '{"dashboard":{"annotations":{"list":[{"builtIn":1,"datasource":"-- Grafana --","enable":true,"hide":true,"iconColor":"rgba(0, 211, 255, 1)","name":"Annotations & Alerts","type":"dashboard"}]},"editable":true,"gnetId":null,"graphTooltip":0,"id":1,"links":[],"panels":[{"datasource":null,"gridPos":{"h":8,"w":6,"x":0,"y":0},"id":6,"options":{"fieldOptions":{"calcs":["mean"],"defaults":{"color":{"mode":"thresholds"},"links":[{"title":"","url":""}],"mappings":[],"max":100,"min":0,"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null},{"color":"red","value":80}]},"unit":"percent"},"overrides":[],"values":false},"orientation":"auto","showThresholdLabels":false,"showThresholdMarkers":true},"pluginVersion":"6.6.0","targets":[{"refId":"A","sql":"select last_row(value) from telegraf.mem where field=\"used_percent\""}],"timeFrom":null,"timeShift":null,"title":"Memory used percent","type":"gauge"},{"aliasColors":{},"bars":false,"dashLength":10,"dashes":false,"datasource":null,"fill":1,"fillGradient":0,"gridPos":{"h":8,"w":12,"x":6,"y":0},"hiddenSeries":false,"id":8,"legend":{"avg":false,"current":false,"max":false,"min":false,"show":true,"total":false,"values":false},"lines":true,"linewidth":1,"nullPointMode":"null","options":{"dataLinks":[]},"percentage":false,"pointradius":2,"points":false,"renderer":"flot","seriesOverrides":[],"spaceLength":10,"stack":false,"steppedLine":false,"targets":[{"alias":"MEMUSED-PERCENT","refId":"A","sql":"select avg(value) from telegraf.mem where field=\"used_percent\" interval(1m)"}],"thresholds":[],"timeFrom":null,"timeRegions":[],"timeShift":null,"title":"MEM","tooltip":{"shared":true,"sort":0,"value_type":"individual"},"type":"graph","xaxis":{"buckets":null,"mode":"time","name":null,"show":true,"values":[]},"yaxes":[{"format":"short","label":null,"logBase":1,"max":null,"min":null,"show":true},{"format":"short","label":null,"logBase":1,"max":null,"min":null,"show":true}],"yaxis":{"align":false,"alignLevel":null}},{"datasource":null,"gridPos":{"h":3,"w":18,"x":0,"y":8},"id":10,"options":{"displayMode":"lcd","fieldOptions":{"calcs":["mean"],"defaults":{"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":null}]},"unit":"percent"},"overrides":[],"values":false},"orientation":"auto","showUnfilled":true},"pluginVersion":"6.6.0","targets":[{"alias":"CPU-SYS","refId":"A","sql":"select last_row(value) from telegraf.cpu where field=\"usage_system\""},{"alias":"CPU-IDLE","refId":"B","sql":"select last_row(value) from telegraf.cpu where field=\"usage_idle\""},{"alias":"CPU-USER","refId":"C","sql":"select last_row(value) from telegraf.cpu where field=\"usage_user\""}],"timeFrom":null,"timeShift":null,"title":"CPU-USED","type":"bargauge"},{"aliasColors":{},"bars":false,"dashLength":10,"dashes":false,"datasource":"TDengine","description":"General CPU monitor","fill":1,"fillGradient":0,"gridPos":{"h":9,"w":18,"x":0,"y":11},"hiddenSeries":false,"id":2,"legend":{"avg":false,"current":false,"max":false,"min":false,"show":true,"total":false,"values":false},"lines":true,"linewidth":1,"nullPointMode":"null","options":{"dataLinks":[]},"percentage":false,"pointradius":2,"points":false,"renderer":"flot","seriesOverrides":[],"spaceLength":10,"stack":false,"steppedLine":false,"targets":[{"alias":"CPU-USER","refId":"A","sql":"select avg(value) from telegraf.cpu where field=\"usage_user\" and cpu=\"cpu-total\" interval(1m)"},{"alias":"CPU-SYS","refId":"B","sql":"select avg(value) from telegraf.cpu where field=\"usage_system\" and cpu=\"cpu-total\" interval(1m)"},{"alias":"CPU-IDLE","refId":"C","sql":"select avg(value) from telegraf.cpu where field=\"usage_idle\" and cpu=\"cpu-total\" interval(1m)"}],"thresholds":[],"timeFrom":null,"timeRegions":[],"timeShift":null,"title":"CPU","tooltip":{"shared":true,"sort":0,"value_type":"individual"},"type":"graph","xaxis":{"buckets":null,"mode":"time","name":null,"show":true,"values":[]},"yaxes":[{"format":"short","label":null,"logBase":1,"max":null,"min":null,"show":true},{"format":"short","label":null,"logBase":1,"max":null,"min":null,"show":true}],"yaxis":{"align":false,"alignLevel":null}}],"refresh":"10s","schemaVersion":22,"style":"dark","tags":["demo"],"templating":{"list":[]},"time":{"from":"now-3h","to":"now"},"timepicker":{"refresh_intervals":["5s","10s","30s","1m","5m","15m","30m","1h","2h","1d"]},"timezone":"","title":"TDengineDashboardDemo","id":null,"uid":null,"version":0}}' diff --git a/minidevops/taos/taos.cfg b/minidevops/taos/taos.cfg new file mode 100644 index 0000000000..b20ce9d755 --- /dev/null +++ b/minidevops/taos/taos.cfg @@ -0,0 +1 @@ +debugFlag 135 diff --git a/src/client/src/tscStream.c b/src/client/src/tscStream.c index 20b5e86090..6235e0aeba 100644 --- a/src/client/src/tscStream.c +++ b/src/client/src/tscStream.c @@ -220,15 +220,16 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, 0, 0); if (numOfRows > 0) { // when reaching here the first execution of stream computing is successful. - pStream->numOfRes += numOfRows; for(int32_t i = 0; i < numOfRows; ++i) { TAOS_ROW row = taos_fetch_row(res); - tscDebug("%p stream:%p fetch result", pSql, pStream); - tscStreamFillTimeGap(pStream, *(TSKEY*)row[0]); - pStream->stime = *(TSKEY *)row[0]; - - // user callback function - (*pStream->fp)(pStream->param, res, row); + if (row != NULL) { + tscDebug("%p stream:%p fetch result", pSql, pStream); + tscStreamFillTimeGap(pStream, *(TSKEY*)row[0]); + pStream->stime = *(TSKEY *)row[0]; + // user callback function + (*pStream->fp)(pStream->param, res, row); + pStream->numOfRes++; + } } if (!pStream->isProject) { diff --git a/src/client/src/tscSub.c b/src/client/src/tscSub.c index 9569987de0..81d73236a4 100644 --- a/src/client/src/tscSub.c +++ b/src/client/src/tscSub.c @@ -203,6 +203,7 @@ static void tscProcessSubscriptionTimer(void *handle, void *tmrId) { static SArray* getTableList( SSqlObj* pSql ) { const char* p = strstr( pSql->sqlstr, " from " ); + assert(p != NULL); // we are sure this is a 'select' statement char* sql = alloca(strlen(p) + 32); sprintf(sql, "select tbid(tbname)%s", p); diff --git a/src/connector/grafana/tdengine/dist/partials/config.html b/src/connector/grafana/tdengine/dist/partials/config.html index 801a753271..f12eb86354 100644 --- a/src/connector/grafana/tdengine/dist/partials/config.html +++ b/src/connector/grafana/tdengine/dist/partials/config.html @@ -3,7 +3,7 @@
Host - +
diff --git a/src/connector/grafana/tdengine/src/partials/config.html b/src/connector/grafana/tdengine/src/partials/config.html index 801a753271..f12eb86354 100644 --- a/src/connector/grafana/tdengine/src/partials/config.html +++ b/src/connector/grafana/tdengine/src/partials/config.html @@ -3,7 +3,7 @@
Host - +
diff --git a/src/dnode/src/dnodeTelemetry.c b/src/dnode/src/dnodeTelemetry.c index 60277a275a..22287f71fd 100644 --- a/src/dnode/src/dnodeTelemetry.c +++ b/src/dnode/src/dnodeTelemetry.c @@ -33,7 +33,7 @@ static pthread_t tsTelemetryThread; #define TELEMETRY_SERVER "telemetry.taosdata.com" #define TELEMETRY_PORT 80 -#define REPORT_INTERVAL 86400 +#define REPORT_INTERVAL 86400 static void beginObject(SBufferWriter* bw) { tbufWriteChar(bw, '{'); @@ -220,28 +220,34 @@ static void sendTelemetryReport() { taosWriteSocket(fd, tbufGetData(&bw, false), contLen); tbufCloseWriter(&bw); - taosReadSocket(fd, buf, 10); // read something to avoid nginx error 499 + // read something to avoid nginx error 499 + if (taosReadSocket(fd, buf, 10) < 0) { + dTrace("failed to receive response, reason:%s", strerror(errno)); + } taosCloseSocket(fd); } static void* telemetryThread(void* param) { - int timeToWait = 0; + struct timespec end = {0}; + clock_gettime(CLOCK_REALTIME, &end); + end.tv_sec += 300; // wait 5 minutes to send first report + while (1) { - if (timeToWait <= 0) { - if (sdbIsMaster()) { - sendTelemetryReport(); + while (1) { + if (sem_timedwait(&tsExitSem, &end) == 0) { + return NULL; + } + struct timespec now = {0}; + clock_gettime(CLOCK_REALTIME, &now); + if (now.tv_sec > end.tv_sec || (now.tv_sec == end.tv_sec && now.tv_nsec >= end.tv_nsec)) { + break; } - timeToWait = REPORT_INTERVAL; } - int startAt = taosGetTimestampSec(); - struct timespec timeout = {.tv_sec = 0, .tv_nsec = 0}; - clock_gettime(CLOCK_REALTIME, &timeout); - timeout.tv_sec += timeToWait; - if (sem_timedwait(&tsExitSem, &timeout) == 0) { - break; + if (sdbIsMaster()) { + sendTelemetryReport(); } - timeToWait -= (taosGetTimestampSec() - startAt); + end.tv_sec += REPORT_INTERVAL; } return NULL; diff --git a/src/kit/taosdump/taosdump.c b/src/kit/taosdump/taosdump.c index 993352dc21..8a05c893e8 100644 --- a/src/kit/taosdump/taosdump.c +++ b/src/kit/taosdump/taosdump.c @@ -275,7 +275,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) { fprintf(stderr, "Invalid path %s\n", arg); return -1; } - strcpy(configDir, full_path.we_wordv[0]); + tstrncpy(configDir, full_path.we_wordv[0], TSDB_FILENAME_LEN); wordfree(&full_path); break; case 'e': @@ -597,7 +597,7 @@ int32_t taosSaveTableOfMetricToTempFile(TAOS *taosCon, char* metric, struct argu numOfThread++; } - memset(tableRecord.name, 0, sizeof(STableRecord)); + memset(&tableRecord, 0, sizeof(STableRecord)); tstrncpy(tableRecord.name, (char *)row[0], fields[0].bytes); tstrncpy(tableRecord.metric, metric, TSDB_TABLE_NAME_LEN); @@ -851,6 +851,7 @@ int taosGetTableDes(char *table, STableDef *tableDes, TAOS* taosCon, bool isSupe if (code != 0) { fprintf(stderr, "failed to run command %s\n", tempCommand); free(tempCommand); + free(tbuf); taos_free_result(tmpResult); return -1; } @@ -876,6 +877,7 @@ int taosGetTableDes(char *table, STableDef *tableDes, TAOS* taosCon, bool isSupe if (isSuperTable) { free(tempCommand); + free(tbuf); return count; } @@ -891,6 +893,7 @@ int taosGetTableDes(char *table, STableDef *tableDes, TAOS* taosCon, bool isSupe if (code != 0) { fprintf(stderr, "failed to run command %s\n", tempCommand); free(tempCommand); + free(tbuf); taos_free_result(tmpResult); return -1; } @@ -901,6 +904,7 @@ int taosGetTableDes(char *table, STableDef *tableDes, TAOS* taosCon, bool isSupe if (NULL == row) { fprintf(stderr, " fetch failed to run command %s\n", tempCommand); free(tempCommand); + free(tbuf); taos_free_result(tmpResult); return -1; } @@ -961,6 +965,7 @@ int taosGetTableDes(char *table, STableDef *tableDes, TAOS* taosCon, bool isSupe } free(tempCommand); + free(tbuf); return count; } @@ -1835,7 +1840,7 @@ static void taosParseDirectory(const char *directoryName, const char *prefix, ch } int fileNum = 0; - while (fscanf(fp, "%s", fileArray[fileNum++])) { + while (fscanf(fp, "%128s", fileArray[fileNum++])) { if (strcmp(fileArray[fileNum-1], tsDbSqlFile) == 0) { fileNum--; } @@ -1864,7 +1869,7 @@ static void taosCheckTablesSQLFile(const char *directoryName) exit(0); } - while (fscanf(fp, "%s", tsDbSqlFile)) { + while (fscanf(fp, "%128s", tsDbSqlFile)) { break; } @@ -1922,20 +1927,6 @@ static FILE* taosOpenDumpInFile(char *fptr) { char *fname = full_path.we_wordv[0]; - if (access(fname, F_OK) != 0) { - fprintf(stderr, "ERROR: file %s is not exist\n", fptr); - - wordfree(&full_path); - return NULL; - } - - if (access(fname, R_OK) != 0) { - fprintf(stderr, "ERROR: file %s is not readable\n", fptr); - - wordfree(&full_path); - return NULL; - } - FILE *f = fopen(fname, "r"); if (f == NULL) { fprintf(stderr, "ERROR: failed to open file %s\n", fname); diff --git a/tests/pytest/util/dnodes-default.py b/tests/pytest/util/dnodes-default.py index ec3865f4f2..085e083149 100644 --- a/tests/pytest/util/dnodes-default.py +++ b/tests/pytest/util/dnodes-default.py @@ -39,6 +39,7 @@ class TDSimClient: "udebugFlag": "135", "jnidebugFlag": "135", "qdebugFlag": "135", + "telemetryReporting": "0", } def init(self, path): self.__init__() diff --git a/tests/pytest/util/dnodes-no-random-fail.py b/tests/pytest/util/dnodes-no-random-fail.py index 485c1b4b3f..2627575e61 100644 --- a/tests/pytest/util/dnodes-no-random-fail.py +++ b/tests/pytest/util/dnodes-no-random-fail.py @@ -36,6 +36,7 @@ class TDSimClient: "udebugFlag": "135", "jnidebugFlag": "135", "qdebugFlag": "135", + "telemetryReporting": "0", } def init(self, path): diff --git a/tests/pytest/util/dnodes-random-fail.py b/tests/pytest/util/dnodes-random-fail.py index 7c4edde47f..4f4cdcc0d0 100644 --- a/tests/pytest/util/dnodes-random-fail.py +++ b/tests/pytest/util/dnodes-random-fail.py @@ -36,6 +36,7 @@ class TDSimClient: "udebugFlag": "135", "jnidebugFlag": "135", "qdebugFlag": "135", + "telemetryReporting": "0", } def init(self, path):