提交 8c7e10f4 编写于 作者: S shenglian zhou

(query):Merge remote-tracking branch 'origin/develop' into...

(query):Merge remote-tracking branch 'origin/develop' into szhou/feature/string-case-transform-substr-trim
version: 1.0.{build}
image:
- Visual Studio 2015
- macos
environment:
matrix:
- ARCH: amd64
- ARCH: x86
matrix:
exclude:
- image: macos
ARCH: x86
for:
-
matrix:
only:
- image: Visual Studio 2015
clone_folder: c:\dev\TDengine
clone_depth: 1
init:
- call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" %ARCH%
before_build:
- cd c:\dev\TDengine
- md build
build_script:
- cd build
- cmake -G "NMake Makefiles" .. -DBUILD_JDBC=false
- nmake install
-
matrix:
only:
- image: macos
clone_depth: 1
build_script:
- mkdir debug
- cd debug
- cmake .. > /dev/null
- make > /dev/null
notifications:
- provider: Email
to:
- sangshuduo@gmail.com
on_build_success: true
on_build_failure: true
on_build_status_changed: true
...@@ -20,11 +20,11 @@ Docker version 20.10.3, build 48d30b5 ...@@ -20,11 +20,11 @@ Docker version 20.10.3, build 48d30b5
### 在 Docker 容器中运行 TDengine server ### 在 Docker 容器中运行 TDengine server
```bash ```bash
$ docker run -d -p 6030-6041:6030-6041 -p 6030-6041:6030-6041/udp tdengine/tdengine $ docker run -d -p 6030-6049:6030-6049 -p 6030-6049:6030-6049/udp tdengine/tdengine
526aa188da767ae94b244226a2b2eec2b5f17dd8eff592893d9ec0cd0f3a1ccd 526aa188da767ae94b244226a2b2eec2b5f17dd8eff592893d9ec0cd0f3a1ccd
``` ```
这条命令,启动一个运行了 TDengine server 的 docker 容器,并且将容器的 6030 到 6041 端口映射到宿主机的 6030 到 6041 端口上。如果宿主机已经运行了 TDengine server 并占用了相同端口,需要映射容器的端口到不同的未使用端口段。(详情参见 [TDengine 2.0 端口说明](https://www.taosdata.com/cn/documentation/faq#port))。为了支持 TDengine 客户端操作 TDengine server 服务, TCP 和 UDP 端口都需要打开。 这条命令,启动一个运行了 TDengine server 的 docker 容器,并且将容器的 6030 到 6049 端口映射到宿主机的 6030 到 6049 端口上。如果宿主机已经运行了 TDengine server 并占用了相同端口,需要映射容器的端口到不同的未使用端口段。(详情参见 [TDengine 2.0 端口说明](https://www.taosdata.com/cn/documentation/faq#port))。为了支持 TDengine 客户端操作 TDengine server 服务, TCP 和 UDP 端口都需要打开。
- **docker run**:通过 Docker 运行一个容器 - **docker run**:通过 Docker 运行一个容器
- **-d**:让容器在后台运行 - **-d**:让容器在后台运行
...@@ -32,14 +32,14 @@ $ docker run -d -p 6030-6041:6030-6041 -p 6030-6041:6030-6041/udp tdengine/tdeng ...@@ -32,14 +32,14 @@ $ docker run -d -p 6030-6041:6030-6041 -p 6030-6041:6030-6041/udp tdengine/tdeng
- **tdengine/tdengine**:拉取的 TDengine 官方发布的应用镜像 - **tdengine/tdengine**:拉取的 TDengine 官方发布的应用镜像
- **526aa188da767ae94b244226a2b2eec2b5f17dd8eff592893d9ec0cd0f3a1ccd**:这个返回的长字符是容器 ID,我们也可以通过容器 ID 来查看对应的容器 - **526aa188da767ae94b244226a2b2eec2b5f17dd8eff592893d9ec0cd0f3a1ccd**:这个返回的长字符是容器 ID,我们也可以通过容器 ID 来查看对应的容器
进一步,还可以使用 docker run 命令启动运行 TDengine server 的 docker 容器,并使用 --name 命令行参数将容器命名为 tdengine,使用 --hostname 指定 hostname 为 tdengine-server,通过 -v 挂载本地目录(-v),实现宿主机与容器内部的数据同步,防止容器删除后,数据丢失。 进一步,还可以使用 docker run 命令启动运行 TDengine server 的 docker 容器,并使用 `--name` 命令行参数将容器命名为 `tdengine`,使用 `--hostname` 指定 hostname 为 `tdengine-server`,通过 `-v` 挂载本地目录到容器,实现宿主机与容器内部的数据同步,防止容器删除后,数据丢失。
``` ```bash
$ docker run -d --name tdengine --hostname="tdengine-server" -v ~/work/taos/log:/var/log/taos -v ~/work/taos/data:/var/lib/taos -p 6030-6041:6030-6041 -p 6030-6041:6030-6041/udp tdengine/tdengine $ docker run -d --name tdengine --hostname="tdengine-server" -v ~/work/taos/log:/var/log/taos -v ~/work/taos/data:/var/lib/taos -p 6030-6049:6030-6049 -p 6030-6049:6030-6049/udp tdengine/tdengine
``` ```
- **--name tdengine**:设置容器名称,我们可以通过容器名称来访问对应的容器 - **--name tdengine**:设置容器名称,我们可以通过容器名称来访问对应的容器
- **--hostnamename=tdengine-server**:设置容器内 Linux 系统的 hostname,我们可以通过映射 hostname 和 IP 来解决容器 IP 可能变化的问题。 - **--hostname=tdengine-server**:设置容器内 Linux 系统的 hostname,我们可以通过映射 hostname 和 IP 来解决容器 IP 可能变化的问题。
- **-v**:设置宿主机文件目录映射到容器内目录,避免容器删除后数据丢失。 - **-v**:设置宿主机文件目录映射到容器内目录,避免容器删除后数据丢失。
### 使用 docker ps 命令确认容器是否已经正确运行 ### 使用 docker ps 命令确认容器是否已经正确运行
...@@ -110,46 +110,47 @@ $ curl -u root:taosdata -d 'show databases' 127.0.0.1:6041/rest/sql ...@@ -110,46 +110,47 @@ $ curl -u root:taosdata -d 'show databases' 127.0.0.1:6041/rest/sql
TDengine RESTful 接口详情请参考[官方文档](https://www.taosdata.com/cn/documentation/connector#restful) TDengine RESTful 接口详情请参考[官方文档](https://www.taosdata.com/cn/documentation/connector#restful)
### 使用 Docker 容器运行 TDengine server 和 taosAdapter ### 使用 Docker 容器运行 TDengine server 和 taosAdapter
在 TDegnine 2.4.0.0 之后版本的 Docker 容器,开始提供一个独立运行的组件 taosAdapter,代替之前版本 TDengine 中 taosd 进程中内置的 http server。taosAdapter 支持通过 RESTful 接口对 TDengine server 的数据写入和查询能力,并提供和 InfluxDB/OpenTSDB 兼容的数据摄取接口,允许 InfluxDB/OpenTSDB 应用程序无缝移植到 TDengine。在新版本 Docker 镜像中,默认运行 taosd,而 taosAdapter 没有运行;也可以使用 docker run 命令中指定 taosadapter 的方式来运行 taosadapter,而 taosd 不会运行;或者在 docker run 命令中指定运行 run_taosd_and_taosadapter.sh 来同时运行 taosd 和 taosAdapter 在 TDegnine 2.4.0.0 之后版本的 Docker 容器,开始提供一个独立运行的组件 taosAdapter,代替之前版本 TDengine 中 taosd 进程中内置的 http server。taosAdapter 支持通过 RESTful 接口对 TDengine server 的数据写入和查询能力,并提供和 InfluxDB/OpenTSDB 兼容的数据摄取接口,允许 InfluxDB/OpenTSDB 应用程序无缝移植到 TDengine。在新版本 Docker 镜像中,默认启用了 taosAdapter,也可以使用 docker run 命令中设置 TAOS_DISABLE_ADAPTER=true 来禁用 taosAdapter;也可以在 docker run 命令中单独使用taosAdapter,而不运行 taosd
注意:如果容器中运行 taosAdapter,需要根据需要增加映射其他端口,具体端口默认配置和修改方法请参考[taosAdapter文档](https://github.com/taosdata/taosadapter/blob/develop/README-CN.md) 注意:如果容器中运行 taosAdapter,需要根据需要映射其他端口,具体端口默认配置和修改方法请参考[taosAdapter文档](https://github.com/taosdata/taosadapter/blob/develop/README-CN.md)
使用 docker 运行 TDengine 2.4.0.4 版本镜像(仅 taosd): 使用 docker 运行 TDengine 2.4.0.4 版本镜像(taosd + taosAdapter):
``` ```bash
$ docker run -d --name tdengine-taosa -p 6030-6049:6030-6049 -p 6030-6049:6030-6049/udp tdengine/tdengine:2.4.0.4 $ docker run -d --name tdengine-all -p 6030-6049:6030-6049 -p 6030-6049:6030-6049/udp tdengine/tdengine:2.4.0.4
``` ```
使用 docker 运行 TDengine 2.4.0.4 版本镜像(仅 taosAdapter): 使用 docker 运行 TDengine 2.4.0.4 版本镜像(仅 taosAdapter,需要设置 firstEp 配置项 或 TAOS_FIRST_EP 环境变量):
``` ```bash
$ docker run -d --name tdengine-taosa -p 6041-6049:6041-6049 -p 6041-6049:6041-6049/udp tdengine/tdengine:2.4.0.4 taosadapter $ docker run -d --name tdengine-taosa -p 6041-6049:6041-6049 -p 6041-6049:6041-6049/udp -e TAOS_FIRST_EP=tdengine-all tdengine/tdengine:2.4.0.4 taosadapter
``` ```
使用 docker 运行 TDengine 2.4.0.4 版本镜像(同时运行 taosd 和 taosAdapter): 使用 docker 运行 TDengine 2.4.0.4 版本镜像(仅 taosd):
```bash
$ docker run -d --name tdengine-taosd -p 6030-6042:6030-6042 -p 6030-6042:6030-6042/udp -e TAOS_DISABLE_ADAPTER=true tdengine/tdengine:2.4.0.4
``` ```
$ docker run -d --name tdengine-taosa -p 6030-6049:6030-6049 -p 6030-6049:6030-6049/udp tdengine/tdengine:2.4.0.4 run_taosd_and_taosadapter.sh
```
使用 curl 命令验证 RESTful 接口可以正常工作: 使用 curl 命令验证 RESTful 接口可以正常工作:
```
```bash
$ curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'show databases;' 127.0.0.1:6041/rest/sql $ curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'show databases;' 127.0.0.1:6041/rest/sql
{"status":"succ","head":["name","created_time","ntables","vgroups","replica","quorum","days","keep","cache(MB)","blocks","minrows","maxrows","wallevel","fsync","comp","cachelast","precision","update","status"],"column_meta":[["name",8,32],["created_time",9,8],["ntables",4,4],["vgroups",4,4],["replica",3,2],["quorum",3,2],["days",3,2],["keep",8,24],["cache(MB)",4,4],["blocks",4,4],["minrows",4,4],["maxrows",4,4],["wallevel",2,1],["fsync",4,4],["comp",2,1],["cachelast",2,1],["precision",8,3],["update",2,1],["status",8,10]],"data":[["log","2021-12-28 09:18:55.765",10,1,1,1,10,"30",1,3,100,4096,1,3000,2,0,"us",0,"ready"]],"rows":1} {"status":"succ","head":["name","created_time","ntables","vgroups","replica","quorum","days","keep","cache(MB)","blocks","minrows","maxrows","wallevel","fsync","comp","cachelast","precision","update","status"],"column_meta":[["name",8,32],["created_time",9,8],["ntables",4,4],["vgroups",4,4],["replica",3,2],["quorum",3,2],["days",3,2],["keep",8,24],["cache(MB)",4,4],["blocks",4,4],["minrows",4,4],["maxrows",4,4],["wallevel",2,1],["fsync",4,4],["comp",2,1],["cachelast",2,1],["precision",8,3],["update",2,1],["status",8,10]],"data":[["log","2021-12-28 09:18:55.765",10,1,1,1,10,"30",1,3,100,4096,1,3000,2,0,"us",0,"ready"]],"rows":1}
``` ```
taosAdapter 支持多个数据收集代理软件(如 Telegraf、StatsD、collectd 等),这里仅模拟 StasD 写入数据,在宿主机执行命令如下: taosAdapter 支持多个数据收集代理软件(如 Telegraf、StatsD、collectd 等),这里仅模拟 StatsD 写入数据,在宿主机执行命令如下:
```
```bash
$ echo "foo:1|c" | nc -u -w0 127.0.0.1 6044 $ echo "foo:1|c" | nc -u -w0 127.0.0.1 6044
``` ```
然后可以使用 taos shell 查询 taosAdapter 自动创建的数据库 statsd 和 超级表 foo 中的内容: 然后可以使用 taos shell 查询 taosAdapter 自动创建的数据库 statsd 和 超级表 foo 中的内容:
```
```bash
taos> show databases; taos> show databases;
name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status | name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status |
==================================================================================================================================================================================================================================================================================== ====================================================================================================================================================================================================================================================================================
...@@ -177,12 +178,11 @@ taos> ...@@ -177,12 +178,11 @@ taos>
可以看到模拟数据已经被写入到 TDengine 中。 可以看到模拟数据已经被写入到 TDengine 中。
### 应用示例:在宿主机使用 taosBenchmark 写入数据到 Docker 容器中的 TDengine server ### 应用示例:在宿主机使用 taosBenchmark 写入数据到 Docker 容器中的 TDengine server
1,在宿主机命令行界面执行 taosBenchmark (曾命名为 taosdemo)写入数据到 Docker 容器中的 TDengine server 1,在宿主机命令行界面执行 taosBenchmark (曾命名为 taosdemo)写入数据到 Docker 容器中的 TDengine server
```bash ```
$ taosBenchmark $ taosBenchmark
taosBenchmark is simulating data generated by power equipments monitoring... taosBenchmark is simulating data generated by power equipments monitoring...
...@@ -195,8 +195,10 @@ resultFile: ./output.txt ...@@ -195,8 +195,10 @@ resultFile: ./output.txt
thread num of insert data: 10 thread num of insert data: 10
thread num of create table: 10 thread num of create table: 10
top insert interval: 0 top insert interval: 0
```
使用 curl 命令验证 RESTful 接口可以正常工作: 使用 curl 命令验证 RESTful 接口可以正常工作:
``` ```
$ curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'show databases;' 127.0.0.1:6041/rest/sql $ curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'show databases;' 127.0.0.1:6041/rest/sql
...@@ -204,11 +206,13 @@ $ curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'show databases;' 127.0 ...@@ -204,11 +206,13 @@ $ curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'show databases;' 127.0
``` ```
taosAdapter 支持多个数据收集代理软件(如 Telegraf、StatsD、collectd 等),这里仅模拟 StasD 写入数据,在宿主机执行命令如下: taosAdapter 支持多个数据收集代理软件(如 Telegraf、StatsD、collectd 等),这里仅模拟 StasD 写入数据,在宿主机执行命令如下:
``` ```
$ echo "foo:1|c" | nc -u -w0 127.0.0.1 6044 $ echo "foo:1|c" | nc -u -w0 127.0.0.1 6044
``` ```
然后可以使用 taos shell 查询 taosAdapter 自动创建的数据库 statsd 和 超级表 foo 中的内容: 然后可以使用 taos shell 查询 taosAdapter 自动创建的数据库 statsd 和 超级表 foo 中的内容:
``` ```
taos> show databases; taos> show databases;
name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status | name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status |
...@@ -255,8 +259,10 @@ resultFile: ./output.txt ...@@ -255,8 +259,10 @@ resultFile: ./output.txt
thread num of insert data: 10 thread num of insert data: 10
thread num of create table: 10 thread num of create table: 10
top insert interval: 0 top insert interval: 0
```
使用 curl 命令验证 RESTful 接口可以正常工作: 使用 curl 命令验证 RESTful 接口可以正常工作:
``` ```
$ curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'show databases;' 127.0.0.1:6041/rest/sql $ curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'show databases;' 127.0.0.1:6041/rest/sql
...@@ -269,6 +275,7 @@ $ echo "foo:1|c" | nc -u -w0 127.0.0.1 6044 ...@@ -269,6 +275,7 @@ $ echo "foo:1|c" | nc -u -w0 127.0.0.1 6044
``` ```
然后可以使用 taos shell 查询 taosAdapter 自动创建的数据库 statsd 和 超级表 foo 中的内容: 然后可以使用 taos shell 查询 taosAdapter 自动创建的数据库 statsd 和 超级表 foo 中的内容:
``` ```
taos> show databases; taos> show databases;
name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status | name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status |
......
...@@ -1805,9 +1805,9 @@ TDengine 中的表(列)名命名规则如下: ...@@ -1805,9 +1805,9 @@ TDengine 中的表(列)名命名规则如下:
1. 在where条件中时,支持函数match/nmatch/between and/like/and/or/is null/is no null,不支持in 1. 在where条件中时,支持函数match/nmatch/between and/like/and/or/is null/is no null,不支持in
```mysql ```mysql
select * from s1 where info'k1' match 'v*'; select * from s1 where info->'k1' match 'v*';
select * from s1 where info'k1' like 'v%' and info contains 'k2'; select * from s1 where info->'k1' like 'v%' and info contains 'k2';
select * from s1 where info is null; select * from s1 where info is null;
...@@ -1819,7 +1819,7 @@ TDengine 中的表(列)名命名规则如下: ...@@ -1819,7 +1819,7 @@ TDengine 中的表(列)名命名规则如下:
3. 支持distinct操作. 3. 支持distinct操作.
```mysql ```mysql
select distinct info'k1' from s1 select distinct info->'k1' from s1
``` ```
5. 标签操作 5. 标签操作
...@@ -1850,7 +1850,7 @@ TDengine 中的表(列)名命名规则如下: ...@@ -1850,7 +1850,7 @@ TDengine 中的表(列)名命名规则如下:
比如暂不支持 比如暂不支持
```mysql ```mysql
select jtag'key' from (select jtag from stable) select jtag->'key' from (select jtag from stable)
``` ```
不支持 不支持
......
...@@ -20,11 +20,11 @@ Docker version 20.10.3, build 48d30b5 ...@@ -20,11 +20,11 @@ Docker version 20.10.3, build 48d30b5
### running TDengine server inside Docker ### running TDengine server inside Docker
```bash ```bash
$ docker run -d -p 6030-6041:6030-6041 -p 6030-6041:6030-6041/udp tdengine/tdengine $ docker run -d -p 6030-6049:6030-6049 -p 6030-6049:6030-6049/udp tdengine/tdengine
526aa188da767ae94b244226a2b2eec2b5f17dd8eff592893d9ec0cd0f3a1ccd 526aa188da767ae94b244226a2b2eec2b5f17dd8eff592893d9ec0cd0f3a1ccd
``` ```
This command starts a docker container with TDengine server running and maps the container's ports from 6030 to 6041 to the host's ports from 6030 to 6041. If the host is already running TDengine server and occupying the same port(s), you need to map the container's port to a different unused port segment. (Please see [TDengine 2.0 Port Description](https://www.taosdata.com/en/documentation/faq#port) for details). In order to support TDengine clients accessing TDengine server services, both TCP and UDP ports need to be open. This command starts a docker container with TDengine server running and maps the container's ports from 6030 to 6049 to the host's ports from 6030 to 6049. If the host is already running TDengine server and occupying the same port(s), you need to map the container's port to a different unused port segment. (Please see [TDengine 2.0 Port Description](https://www.taosdata.com/en/documentation/faq#port) for details). In order to support TDengine clients accessing TDengine server services, both TCP and UDP ports need to be open.
- **docker run**: Run a container via Docker - **docker run**: Run a container via Docker
- **-d**: put the container run in the background - **-d**: put the container run in the background
...@@ -118,6 +118,8 @@ Note: If taosAdapter is running inside the container, you need to add mapping to ...@@ -118,6 +118,8 @@ Note: If taosAdapter is running inside the container, you need to add mapping to
Running TDengine version 2.4.0.4 image with docker. Running TDengine version 2.4.0.4 image with docker.
Start taosAdapter and taosd by default:
``` ```
$ docker run -d --name tdengine-taosa -p 6030-6049:6030-6049 -p 6030-6049:6030-6049/udp tdengine/tdengine:2.4.0.4 $ docker run -d --name tdengine-taosa -p 6030-6049:6030-6049 -p 6030-6049:6030-6049/udp tdengine/tdengine:2.4.0.4
``` ```
......
...@@ -11,12 +11,16 @@ RUN tar -zxf ${pkgFile} ...@@ -11,12 +11,16 @@ RUN tar -zxf ${pkgFile}
WORKDIR /root/${dirName}/ WORKDIR /root/${dirName}/
RUN /bin/bash install.sh -e no RUN /bin/bash install.sh -e no
RUN apt-get clean && apt-get update && apt-get install -y locales && locale-gen en_US.UTF-8 ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get clean && apt-get update && apt-get install -y locales tzdata netcat && locale-gen en_US.UTF-8
ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib" \ ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib" \
LC_CTYPE=en_US.UTF-8 \ LC_CTYPE=en_US.UTF-8 \
LANG=en_US.UTF-8 \ LANG=en_US.UTF-8 \
LC_ALL=en_US.UTF-8 LC_ALL=en_US.UTF-8
EXPOSE 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 EXPOSE 6030-6049
EXPOSE 6030-6039/udp
COPY ./bin/* /usr/bin/
ENTRYPOINT ["/usr/bin/entrypoint.sh"]
CMD ["taosd"] CMD ["taosd"]
VOLUME [ "/var/lib/taos", "/var/log/taos","/etc/taos/" ] VOLUME [ "/var/lib/taos", "/var/log/taos", "/corefile" ]
此差异已折叠。
#!/bin/sh
set -e
# for TZ awareness
if [ "$TZ" != "" ]; then
ln -sf /usr/share/zoneinfo/$TZ /etc/localtime
echo $TZ >/etc/timezone
fi
# option to disable taosadapter, default is no
DISABLE_ADAPTER=${TAOS_DISABLE_ADAPTER:-0}
unset TAOS_DISABLE_ADAPTER
# to get mnodeEpSet from data dir
DATA_DIR=${TAOS_DATA_DIR:-/var/lib/taos}
# append env to custom taos.cfg
CFG_DIR=/tmp/taos
CFG_FILE=$CFG_DIR/taos.cfg
mkdir -p $CFG_DIR >/dev/null 2>&1
[ -f /etc/taos/taos.cfg ] && cat /etc/taos/taos.cfg | grep -E -v "^#|^\s*$" >$CFG_FILE
env-to-cfg >>$CFG_FILE
FQDN=$(cat $CFG_FILE | grep -E -v "^#|^$" | grep fqdn | tail -n1 | sed -E 's/.*fqdn\s+//')
# ensure the fqdn is resolved as localhost
grep "$FQDN" /etc/hosts >/dev/null || echo "127.0.0.1 $FQDN" >>/etc/hosts
# parse first ep host and port
FIRST_EP_HOST=${TAOS_FIRST_EP%:*}
FIRST_EP_PORT=${TAOS_FIRST_EP#*:}
# in case of custom server port
SERVER_PORT=$(cat $CFG_FILE | grep -E -v "^#|^$" | grep serverPort | tail -n1 | sed -E 's/.*serverPort\s+//')
SERVER_PORT=${SERVER_PORT:-6030}
# for other binaries like interpreters
if echo $1 | grep -E "taosd$" - >/dev/null; then
true # will run taosd
else
cp -f $CFG_FILE /etc/taos/taos.cfg || true
$@
exit $?
fi
set +e
ulimit -c unlimited
# set core files pattern, maybe failed
sysctl -w kernel.core_pattern=/corefile/core-$FQDN-%e-%p >/dev/null >&1
set -e
if [ "$DISABLE_ADAPTER" = "0" ]; then
which taosadapter >/dev/null && taosadapter &
# wait for 6041 port ready
for _ in $(seq 1 20); do
nc -z localhost 6041 && break
sleep 0.5
done
fi
# if has mnode ep set or the host is first ep or not for cluster, just start.
if [ -f "$DATA_DIR/dnode/mnodeEpSet.json" ] ||
[ "$TAOS_FQDN" = "$FIRST_EP_HOST" ]; then
$@ -c $CFG_DIR
# others will first wait the first ep ready.
else
if [ "$TAOS_FIRST_EP" = "" ]; then
echo "run TDengine with single node."
$@ -c $CFG_DIR
exit $?
fi
while true; do
es=0
taos -h $FIRST_EP_HOST -P $FIRST_EP_PORT -n startup >/dev/null || es=$?
if [ "$es" -eq 0 ]; then
taos -h $FIRST_EP_HOST -P $FIRST_EP_PORT -s "create dnode \"$FQDN:$SERVER_PORT\";"
break
fi
sleep 1s
done
$@ -c $CFG_DIR
fi
#!/bin/sh
set -e
self=$0
snake_to_camel_case() {
echo $1 | awk -F _ '{printf "%s", $1; for(i=2; i<=NF; i++) printf "%s", toupper(substr($i,1,1)) substr($i,2); print"";}'
}
if echo $1 | grep -E "^$" - >/dev/null; then
export |grep -E 'TAOS_.*' -o| sed 's/TAOS_//' |tr A-Z a-z | awk -F"=" '{print "name=$(""'$self' " $1"); echo $name "$2}' |sh
else
snake_to_camel_case $1
fi
version: "3"
networks:
inter:
api:
services:
arbitrator:
image: tdengine/tdengine:$VERSION
command: tarbitrator
networks:
- inter
td-1:
image: tdengine/tdengine:$VERSION
networks:
- inter
environment:
TAOS_FQDN: "td-1"
TAOS_FIRST_EP: "td-1"
TAOS_NUM_OF_MNODES: "2"
TAOS_REPLICA: "2"
TAOS_ARBITRATOR: arbitrator:6042
volumes:
- taosdata-td1:/var/lib/taos/
- taoslog-td1:/var/log/taos/
td-2:
image: tdengine/tdengine:$VERSION
networks:
- inter
environment:
TAOS_FQDN: "td-2"
TAOS_FIRST_EP: "td-1"
TAOS_NUM_OF_MNODES: "2"
TAOS_REPLICA: "2"
TAOS_ARBITRATOR: arbitrator:6042
volumes:
- taosdata-td2:/var/lib/taos/
- taoslog-td2:/var/log/taos/
adapter:
image: tdengine/tdengine:$VERSION
command: taosadapter
networks:
- inter
environment:
TAOS_FIRST_EP: "td-1"
TOAS_SECOND_EP: "td-2"
deploy:
replicas: 4
update_config:
parallelism: 4
nginx:
image: nginx
depends_on:
- adapter
networks:
- inter
- api
ports:
- 6041:6041
- 6044:6044/udp
command: [
"sh",
"-c",
"while true;
do curl -s http://adapter:6041/-/ping >/dev/null && break;
done;
printf 'server{listen 6041;location /{proxy_pass http://adapter:6041;}}'
> /etc/nginx/conf.d/rest.conf;
printf 'stream{server{listen 6044 udp;proxy_pass adapter:6044;}}'
>> /etc/nginx/nginx.conf;cat /etc/nginx/nginx.conf;
nginx -g 'daemon off;'",
]
volumes:
taosdata-td1:
taoslog-td1:
taosdata-td2:
taoslog-td2:
...@@ -4,11 +4,13 @@ ...@@ -4,11 +4,13 @@
set -e set -e
#set -x #set -x
source ./sed_power.sh scriptDir=$(dirname $(readlink -f $0))
source ./sed_tq.sh
source ./sed_pro.sh source $scriptDir/sed_power.sh
source ./sed_kh.sh source $scriptDir/sed_tq.sh
source ./sed_jh.sh source $scriptDir/sed_pro.sh
source $scriptDir/sed_kh.sh
source $scriptDir/sed_jh.sh
# release.sh -v [cluster | edge] # release.sh -v [cluster | edge]
# -c [aarch32 | aarch64 | x64 | x86 | mips64 ...] # -c [aarch32 | aarch64 | x64 | x86 | mips64 ...]
......
...@@ -4670,7 +4670,7 @@ static int32_t validateSQLExprItemSQLFunc(SSqlCmd* pCmd, tSqlExpr* pExpr, ...@@ -4670,7 +4670,7 @@ static int32_t validateSQLExprItemSQLFunc(SSqlCmd* pCmd, tSqlExpr* pExpr,
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
static int32_t validateSQLExprItemArithmeticExpr(SSqlCmd* pCmd, tSqlExpr* pExpr, SQueryInfo* pQueryInfo, SColumnList* pList, static int32_t validateSQLExprItemOperatorExpr(SSqlCmd* pCmd, tSqlExpr* pExpr, SQueryInfo* pQueryInfo, SColumnList* pList,
int32_t* type, uint64_t* uid, int32_t* height) { int32_t* type, uint64_t* uid, int32_t* height) {
uint64_t uidLeft = 0; uint64_t uidLeft = 0;
uint64_t uidRight = 0; uint64_t uidRight = 0;
...@@ -4699,7 +4699,9 @@ static int32_t validateSQLExprItemArithmeticExpr(SSqlCmd* pCmd, tSqlExpr* pExpr, ...@@ -4699,7 +4699,9 @@ static int32_t validateSQLExprItemArithmeticExpr(SSqlCmd* pCmd, tSqlExpr* pExpr,
*height = (leftHeight > rightHeight) ? leftHeight + 1 : rightHeight+1; *height = (leftHeight > rightHeight) ? leftHeight + 1 : rightHeight+1;
{ {
assert(leftType != SQLEXPR_TYPE_UNASSIGNED && rightType != SQLEXPR_TYPE_UNASSIGNED); if (leftType == SQLEXPR_TYPE_UNASSIGNED || rightType == SQLEXPR_TYPE_UNASSIGNED) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), "invalid operand expression");
}
// return invalid operation when one child aggregate and the other child scalar or column // return invalid operation when one child aggregate and the other child scalar or column
if ((leftType == SQLEXPR_TYPE_AGG && rightType == SQLEXPR_TYPE_SCALAR) || (rightType == SQLEXPR_TYPE_AGG && leftType == SQLEXPR_TYPE_SCALAR)) { if ((leftType == SQLEXPR_TYPE_AGG && rightType == SQLEXPR_TYPE_SCALAR) || (rightType == SQLEXPR_TYPE_AGG && leftType == SQLEXPR_TYPE_SCALAR)) {
...@@ -4727,6 +4729,11 @@ static int32_t validateSQLExprItemArithmeticExpr(SSqlCmd* pCmd, tSqlExpr* pExpr, ...@@ -4727,6 +4729,11 @@ static int32_t validateSQLExprItemArithmeticExpr(SSqlCmd* pCmd, tSqlExpr* pExpr,
rightType == SQLEXPR_TYPE_AGG || rightType == SQLEXPR_TYPE_SCALAR) { rightType == SQLEXPR_TYPE_AGG || rightType == SQLEXPR_TYPE_SCALAR) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg4); return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg4);
} }
} else if (pExpr->tokenId == TK_ISNULL || pExpr->tokenId == TK_NOTNULL ||
pExpr->tokenId == TK_IS || pExpr->tokenId == TK_LIKE ||
pExpr->tokenId == TK_MATCH || pExpr->tokenId == TK_NMATCH ||
pExpr->tokenId == TK_CONTAINS || pExpr->tokenId == TK_IN) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), "unsupported filtering operations");
} }
} }
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
...@@ -4742,7 +4749,7 @@ static int32_t validateSQLExprItem(SSqlCmd* pCmd, tSqlExpr* pExpr, ...@@ -4742,7 +4749,7 @@ static int32_t validateSQLExprItem(SSqlCmd* pCmd, tSqlExpr* pExpr,
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
if (pExpr->type == SQL_NODE_EXPR) { if (pExpr->type == SQL_NODE_EXPR) {
int32_t ret = validateSQLExprItemArithmeticExpr(pCmd, pExpr, pQueryInfo, pList, type, uid, height); int32_t ret = validateSQLExprItemOperatorExpr(pCmd, pExpr, pQueryInfo, pList, type, uid, height);
if (ret != TSDB_CODE_SUCCESS) { if (ret != TSDB_CODE_SUCCESS) {
return ret; return ret;
} }
......
...@@ -1933,9 +1933,6 @@ int tscBuildConnectMsg(SSqlObj *pSql, SSqlInfo *pInfo) { ...@@ -1933,9 +1933,6 @@ int tscBuildConnectMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
tstrncpy(pConnect->db, db, sizeof(pConnect->db)); tstrncpy(pConnect->db, db, sizeof(pConnect->db));
pthread_mutex_unlock(&pObj->mutex); pthread_mutex_unlock(&pObj->mutex);
tstrncpy(pConnect->clientVersion, version, sizeof(pConnect->clientVersion));
tstrncpy(pConnect->msgVersion, "", sizeof(pConnect->msgVersion));
pConnect->pid = htonl(taosGetPId()); pConnect->pid = htonl(taosGetPId());
taosGetCurrentAPPName(pConnect->appName, NULL); taosGetCurrentAPPName(pConnect->appName, NULL);
...@@ -2035,7 +2032,6 @@ int tscBuildHeartBeatMsg(SSqlObj *pSql, SSqlInfo *pInfo) { ...@@ -2035,7 +2032,6 @@ int tscBuildHeartBeatMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
// TODO the expired hb and client can not be identified by server till now. // TODO the expired hb and client can not be identified by server till now.
SHeartBeatMsg *pHeartbeat = (SHeartBeatMsg *)pCmd->payload; SHeartBeatMsg *pHeartbeat = (SHeartBeatMsg *)pCmd->payload;
tstrncpy(pHeartbeat->clientVer, version, tListLen(pHeartbeat->clientVer));
pHeartbeat->numOfQueries = numOfQueries; pHeartbeat->numOfQueries = numOfQueries;
pHeartbeat->numOfStreams = numOfStreams; pHeartbeat->numOfStreams = numOfStreams;
......
...@@ -212,16 +212,8 @@ TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass, ...@@ -212,16 +212,8 @@ TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass,
tscDebug("%p DB connection is opening, rpcObj: %p, dnodeConn:%p", pObj, pObj->pRpcObj, pObj->pRpcObj->pDnodeConn); tscDebug("%p DB connection is opening, rpcObj: %p, dnodeConn:%p", pObj, pObj->pRpcObj, pObj->pRpcObj->pDnodeConn);
taos_free_result(pSql); taos_free_result(pSql);
// version compare only requires the first 3 segments of the version string return pObj;
int code = taosCheckVersion(version, taos_get_server_info(pObj), 3);
if (code != 0) {
terrno = code;
taos_close(pObj);
return NULL;
} else {
return pObj;
}
} }
return NULL; return NULL;
......
## CSharp Connector
* This C# connector supports: Linux 64/Windows x64/Windows x86.
* This C# connector can be downloaded and included as a normal package from [Nuget.org](https://www.nuget.org/packages/TDengine.Connector/).
### Installation preparations
* Install TDengine client.
* .NET interface file TDengineDriver.cs and reference samples both
are located under Windows client's installation path:install_directory/examples/C#.
* Install [.NET SDK](https://dotnet.microsoft.com/download)
### Installation verification
Run {client_installation_directory}/examples/C#/C#Checker/C#Checker.cs
```cmd
cd {client_install_directory}/examples/C\#/C#Checker
//run c#checker.cs
dotnet run -- -h <FQDN>
```
### Example Source Code
You can find examples under follow directories:
* {client_installation_directory}/examples/C#
* [github C# example source code](https://github.com/taosdata/TDengine/tree/develop/tests/examples/C%23)
**Tips:**
"TDengineTest" is an example that includes some basic sample code like
connect, query and so on.
### Use C# connector
#### **prepare**
**tips:** Need to install .NET SDK first.
* Create a dotnet project(using console project as an example).
``` cmd
mkdir test
cd test
dotnet new console
```
* Add "TDengine.Connector" as a package through Nuget into project.
``` cmd
dotnet add package TDengine.Connector
```
#### **Connection**
``` C#
using TDengineDriver;
using System.Runtime.InteropServices;
// ... do something ...
string host = "127.0.0.1" ;
string configDir = "C:/TDengine/cfg"; // For linux should it be /etc/taos.
string user = "root";
string password = "taosdata";
string db = ''; // Also can set it to the db name you want to connect.
string port = 0
/* Set client options (optional step):charset, locale, timezone.
* Default: charset, locale, timezone same to system.
* Current supports options:TSDB_OPTION_LOCALE, TSDB_OPTION_CHARSET, TSDB_OPTION_TIMEZONE, TSDB_OPTION_CONFIGDIR.
*/
TDengine.Options((int)TDengineInitOption.TSDB_OPTION_CONFIGDIR,configDir);
// Get an TDengine connection
InPtr conn = TDengine.Connect(host, user, taosdata, db, port);
// Check if get connection success
if (conn == IntPtr.Zero)
{
Console.WriteLine("Connect to TDengine failed");
}
else
{
Console.WriteLine("Connect to TDengine success");
}
// Close TDengine Connection
if (conn != IntPtr.Zero)
{
TDengine.Close(this.conn);
}
// Suggest to clean environment, before exit your application.
TDengine.Cleanup();
```
#### **Execute SQL**
```C#
// Suppose conn is a valid tdengine connection from previous Connection sample
public static void ExecuteSQL(IntPtr conn, string sql)
{
IntPtr res = TDengine.Query(conn, sql);
// Check if query success
if((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0))
{
Console.Write(sql + " failure, ");
// Get error message while Res is a not null pointer.
if (res != IntPtr.Zero)
{
Console.Write("reason:" + TDengine.Error(res));
}
}
else
{
Console.Write(sql + " success, {0} rows affected", TDengine.AffectRows(res));
//... do something with res ...
// Important: need to free result to avoid memory leak.
TDengine.FreeResult(res);
}
}
// Calling method to execute sql;
ExecuteSQL(conn,$"create database if not exists {db};");
ExecuteSQL(conn,$"use {db};");
string createSql = "CREATE TABLE meters(ts TIMESTAMP, current FLOAT,"+
" voltage INT, phase FLOAT)TAGS(location BINARY(30), groupId INT);"
ExecuteSQL(conn,createSql);
ExecuteSQL(conn," INSERT INTO d1001 USING meters TAGS('Beijing.Chaoyang', 2) VALUES('a');");
ExecuteSQL(conn,$"drop database if exists {db};");
```
#### **Get Query Result**
```C#
// Following code is a sample that traverses retrieve data from TDengine.
public void ExecuteQuery(IntPtr conn,string sql)
{
// "conn" is a valid TDengine connection which can
// be got from previous "Connection" sample.
IntPrt res = TDengine.Query(conn, sql);
if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0))
{
Console.Write(sql.ToString() + " failure, ");
if (res != IntPtr.Zero)
{
Console.Write("reason: " + TDengine.Error(res));
}
// Execute query sql failed
// ... do something ...
}
// Retrieve data successfully then iterate through "res".
// Fields count, num of fields, that is equal to retrieved column count.
int fieldCount = TDengine.FieldCount(res);
Console.WriteLine("field count: " + fieldCount);
// Get query result field information in list form.
List<TDengineMeta> metas = TDengine.FetchFields(res);
for(int j = 0; j < metas.Count; j++)
{
TDengineMeta meta = (TDengineMeta)metas[j];
Console.WriteLine($"index:{j},type:{meta.type},typename:{meta.TypeName()},name:{meta.name},size:{meta.size}");
}
// Iterate over the data from the retrieved results.
IntPtr rowdata;
StringBuilder builder = new StringBuilder();
while ((rowdata = TDengine.FetchRows(res)) != IntPtr.Zero)
{
queryRows++;
IntPtr colLengthPtr = TDengine.FetchLengths(res);
int[] colLengthArr = new int[fieldCount];
Marshal.Copy(colLengthPtr, colLengthArr, 0, fieldCount);
for (int fields = 0; fields < fieldCount; ++fields)
{
TDengineMeta meta = metas[fields];
int offset = IntPtr.Size * fields;
IntPtr data = Marshal.ReadIntPtr(rowdata, offset);
builder.Append("---");
if (data == IntPtr.Zero)
{
builder.Append("NULL");
continue;
}
switch ((TDengineDataType)meta.type)
{
case TDengineDataType.TSDB_DATA_TYPE_BOOL:
bool v1 = Marshal.ReadByte(data) == 0 ? false : true;
builder.Append(v1.ToString());
break;
case TDengineDataType.TSDB_DATA_TYPE_TINYINT:
sbyte v2 = (sbyte)Marshal.ReadByte(data);
builder.Append(v2.ToString());
break;
case TDengineDataType.TSDB_DATA_TYPE_SMALLINT:
short v3 = Marshal.ReadInt16(data);
builder.Append(v3.ToString());
break;
case TDengineDataType.TSDB_DATA_TYPE_INT:
int v4 = Marshal.ReadInt32(data);
builder.Append(v4.ToString());
break;
case TDengineDataType.TSDB_DATA_TYPE_BIGINT:
long v5 = Marshal.ReadInt64(data);
builder.Append(v5.ToString());
break;
case TDengineDataType.TSDB_DATA_TYPE_FLOAT:
float v6 = (float)Marshal.PtrToStructure(data, typeof(float));
builder.Append(v6.ToString());
break;
case TDengineDataType.TSDB_DATA_TYPE_DOUBLE:
double v7 = (double)Marshal.PtrToStructure(data, typeof(double));
builder.Append(v7.ToString());
break;
case TDengineDataType.TSDB_DATA_TYPE_BINARY:
string v8 = Marshal.PtrToStringUTF8(data, colLengthArr[fields]);
builder.Append(v8);
break;
case TDengineDataType.TSDB_DATA_TYPE_TIMESTAMP:
long v9 = Marshal.ReadInt64(data);
builder.Append(v9.ToString());
break;
case TDengineDataType.TSDB_DATA_TYPE_NCHAR:
string v10 = Marshal.PtrToStringUTF8(data, colLengthArr[fields]);
builder.Append(v10);
break;
case TDengineDataType.TSDB_DATA_TYPE_UTINYINT:
byte v12 = Marshal.ReadByte(data);
builder.Append(v12.ToString());
break;
case TDengineDataType.TSDB_DATA_TYPE_USMALLINT:
ushort v13 = (ushort)Marshal.ReadInt16(data);
builder.Append(v13.ToString());
break;
case TDengineDataType.TSDB_DATA_TYPE_UINT:
uint v14 = (uint)Marshal.ReadInt32(data);
builder.Append(v14.ToString());
break;
case TDengineDataType.TSDB_DATA_TYPE_UBIGINT:
ulong v15 = (ulong)Marshal.ReadInt64(data);
builder.Append(v15.ToString());
break;
default:
builder.Append("unknown value");
break;
}
}
builder.Append("---");
}
// Do something with the result data, like print.
Console.WriteLine(builder.ToString());
// Important free "res".
TDengine.FreeResult(res);
}
```
#### **Stmt Bind Sample**
* Bind different types of data.
```C#
// Prepare tags values used to binding by stmt.
// An instance of TAOS_BIND can just bind a cell of table.
TAOS_BIND[] binds = new TAOS_BIND[1];
binds[0] = TaosBind.BindNchar("-123acvnchar");
// Use TaosBind.BindNil() to bind null values.
long[] tsArr = new long[5] { 1637064040000, 1637064041000,
1637064042000, 1637064043000, 1637064044000 };
bool?[] boolArr = new bool?[5] { true, false, null, true, true };
int?[] intArr = new int?[5] { -200, -100, null, 0, 300 };
long?[] longArr = new long?[5] { long.MinValue + 1, -2000, null,
1000, long.MaxValue };
string[] binaryArr = new string[5] { "/TDengine/src/client/src/tscPrepare.c",
String.Empty, null, "doBindBatchParam",
"string.Jion:1234567890123456789012345" };
// TAOS_MULTI_BIND can bind a column of data.
TAOS_MULTI_BIND[] mBinds = new TAOS_MULTI_BIND[5];
mBinds[0] = TaosMultiBind.MultiBindTimestamp(tsArr);
mBinds[1] = TaosMultiBind.MultiBindBool(boolArr);
mBinds[4] = TaosMultiBind.MultiBindInt(intArr);
mBinds[5] = TaosMultiBind.MultiBindBigint(longArr);
mBinds[12] = TaosMultiBind.MultiBindBinary(binaryArr);
// After using instance of TAOS_MULTI_BIND and TAOS_BIND,
// need to free the allocated unmanaged memory.
TaosMultiBind.FreeBind(mBind);
TaosMultiBind.FreeMBind(mBinds);
```
* Insert
```C#
/* Pre-request: create stable or normal table.
* Target table for this sample:stmtdemo
* Structure:create stable stmtdemo (ts timestamp,b bool,v4 int,
* v8 bigint,bin binary(100))tags(blob nchar(100));
*/
// This conn should be a valid connection that is returned by TDengine.Connect().
IntPtr conn;
IntPtr stmt = IntPtr.Zero;
// Insert statement
string sql = "insert into ? using stmtdemo tags(?,?,?,?,?) values(?)";
// "use db" before stmtPrepare().
stmt = TDengine.StmtInit(conn);
TDengine.StmtPrepare(stmt, sql);
// Use method StmtSetTbname() to config tablename,
// but needs to create the table before.
// Using StmtSetTbnameTags() to config table name and
// tags' value.(create sub table based on stable automatically)
TDengine.StmtSetTbname_tags(stmt,"t1",binds);
// Binding multiple lines of data.
TDengine.StmtBindParamBatch(stmt,mBinds);
// Add current bind parameters into batch.
TDengine.StmtAddBatch(stmt);
// Execute the batch instruction which has been prepared well by bind_param() method.
TDengine.StmtExecute(stmt);
// Cause we use unmanaged memory, remember to free occupied memory, after execution.
TaosMultiBind.FreeBind(mBind);
TaosMultiBind.FreeMBind(mBinds);
// Get error information if current stmt operation failed.
// This method is appropriate for all the stmt methods to get error message.
TDengine.StmtError(stmt);
```
* Query
``` C#
stmt = StmtInit(conn);
string querySql = "SELECT * FROM T1 WHERE V4 > ? AND V8 < ?";
StmtPrepare(stmt, querySql);
// Prepare Query parameters.
TAOS_BIND qparams[2];
qparams[0] = TaosBind.bindInt(-2);
qparams[1] = TaosBind.bindLong(4);
// Bind parameters.
TDengine.StmtBindParam(stmt, qparams);
// Execute
TDengine.StmtExecute(stmt);
// Get querying result, for SELECT only.
// User application should be freed with API FreeResult() at the end.
IntPtr result = TDengine.StmtUseResult(stmt);
// This "result" cam be traversed as normal sql query result.
// ... Do something with "result" ...
TDengine.FreeResult(result);
// Cause we use unmanaged memory, we need to free occupied memory after execution.
TaosMultiBind.FreeBind(qparams);
// Close stmt and release resource.
TDengine.StmtClose(stmt);
```
* Assert (samples about how to assert every step of stmt is successed or failed)
```C#
// Special StmtInit().
IntPtr stmt = TDengine.StmtInit(conn);
if ( stmt == IntPtr.Zero)
{
Console.WriteLine("Init stmt failed:{0}",TDengine.StmtErrorStr(stmt));
// ... do something ...
}
else
{
Console.WriteLine("Init stmt success");
// Continue
}
// For all stmt methods that return int type,we can get error message by StmtErrorStr().
if (TDengine.StmtPrepare(this.stmt, sql) == 0)
{
Console.WriteLine("stmt prepare success");
// Continue
}
else
{
Console.WriteLine("stmt prepare failed:{0} " , TDengine.StmtErrorStr(stmt));
// ... do something ...
}
// Estimate wether StmtUseResult() is successful or failed.
// If failed, get the error message by TDengine.Error(res)
IntPtr res = TDengine.StmtUseResult(stmt);
if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0))
{
Console.Write( " StmtUseResult failure, ");
if (res != IntPtr.Zero) {
Console.Write("reason: " + TDengine.Error(res));
}
}
else
{
Console.WriteLine(sql.ToString() + " success");
}
```
* More samples reference from [examples](https://github.com/taosdata/TDengine/tree/develop/tests/examples/C%23/).
**Note:**
* TDengine V2.0.3.0 supports both 32-bit and 64-bit Windows systems,
so when .NET project generates a .exe file, please select correspond
with "X86" or "x64" for the "Platform" under "Solution"/"Project".
* This .NET interface has been verified in Visual Studio 2015/2017,
other VS versions have not been verified yet.
* Since this. NET connector interface requires the taos.dll file, so before
executing the application, copy the taos.dll file in the
Windows {client_install_directory}/driver directory to the folder where the
.NET project finally generated the .exe executable file. After running the exe
file, you can access the TDengine database and do operations such as insert
and query(This step can be skip if the client has been installed on you machine).
...@@ -335,8 +335,8 @@ typedef struct { ...@@ -335,8 +335,8 @@ typedef struct {
typedef struct { typedef struct {
int8_t extend; int8_t extend;
char clientVersion[TSDB_VERSION_LEN]; char clientVersion[TSDB_VERSION_LEN]; // useless
char msgVersion[TSDB_VERSION_LEN]; char msgVersion[TSDB_VERSION_LEN]; // useless
char db[TSDB_TABLE_FNAME_LEN]; char db[TSDB_TABLE_FNAME_LEN];
char appName[TSDB_APPNAME_LEN]; char appName[TSDB_APPNAME_LEN];
int32_t pid; int32_t pid;
...@@ -920,7 +920,7 @@ typedef struct { ...@@ -920,7 +920,7 @@ typedef struct {
typedef struct { typedef struct {
int8_t extend; int8_t extend;
char clientVer[TSDB_VERSION_LEN]; char clientVer[TSDB_VERSION_LEN]; // useless
uint32_t connId; uint32_t connId;
int32_t pid; int32_t pid;
int32_t numOfQueries; int32_t numOfQueries;
......
Subproject commit 70a0dc32194b4e00a515773007238ae255758b32 Subproject commit a6531c1528b5b50fb234e2519106feae91cc8d38
...@@ -243,10 +243,6 @@ static int32_t mnodeProcessHeartBeatMsg(SMnodeMsg *pMsg) { ...@@ -243,10 +243,6 @@ static int32_t mnodeProcessHeartBeatMsg(SMnodeMsg *pMsg) {
} }
SHeartBeatMsg *pHBMsg = pMsg->rpcMsg.pCont; SHeartBeatMsg *pHBMsg = pMsg->rpcMsg.pCont;
if (taosCheckVersion(pHBMsg->clientVer, version, 3) != TSDB_CODE_SUCCESS) {
rpcFreeCont(pRsp);
return TSDB_CODE_TSC_INVALID_VERSION; // todo change the error code
}
SRpcConnInfo connInfo = {0}; SRpcConnInfo connInfo = {0};
rpcGetConnInfo(pMsg->rpcMsg.handle, &connInfo); rpcGetConnInfo(pMsg->rpcMsg.handle, &connInfo);
...@@ -307,11 +303,6 @@ static int32_t mnodeProcessConnectMsg(SMnodeMsg *pMsg) { ...@@ -307,11 +303,6 @@ static int32_t mnodeProcessConnectMsg(SMnodeMsg *pMsg) {
goto connect_over; goto connect_over;
} }
code = taosCheckVersion(pConnectMsg->clientVersion, version, 3);
if (code != TSDB_CODE_SUCCESS) {
goto connect_over;
}
SUserObj *pUser = pMsg->pUser; SUserObj *pUser = pMsg->pUser;
SAcctObj *pAcct = pUser->pAcct; SAcctObj *pAcct = pUser->pAcct;
......
...@@ -8471,10 +8471,6 @@ static int32_t deserializeColFilterInfo(SColumnFilterInfo* pColFilters, int16_t ...@@ -8471,10 +8471,6 @@ static int32_t deserializeColFilterInfo(SColumnFilterInfo* pColFilters, int16_t
int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SQueryParam* param) { int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SQueryParam* param) {
int32_t code = TSDB_CODE_SUCCESS; int32_t code = TSDB_CODE_SUCCESS;
if (taosCheckVersion(pQueryMsg->version, version, 3) != 0) {
return TSDB_CODE_QRY_INVALID_MSG;
}
pQueryMsg->numOfTables = htonl(pQueryMsg->numOfTables); pQueryMsg->numOfTables = htonl(pQueryMsg->numOfTables);
pQueryMsg->window.skey = htobe64(pQueryMsg->window.skey); pQueryMsg->window.skey = htobe64(pQueryMsg->window.skey);
pQueryMsg->window.ekey = htobe64(pQueryMsg->window.ekey); pQueryMsg->window.ekey = htobe64(pQueryMsg->window.ekey);
......
...@@ -41,9 +41,6 @@ char * paGetToken(char *src, char **token, int32_t *tokenLen); ...@@ -41,9 +41,6 @@ char * paGetToken(char *src, char **token, int32_t *tokenLen);
int32_t taosByteArrayToHexStr(char bytes[], int32_t len, char hexstr[]); int32_t taosByteArrayToHexStr(char bytes[], int32_t len, char hexstr[]);
int32_t taosHexStrToByteArray(char hexstr[], char bytes[]); int32_t taosHexStrToByteArray(char hexstr[], char bytes[]);
bool taosGetVersionNumber(char *versionStr, int *versionNubmer);
int taosCheckVersion(char *input_client_version, char *input_server_version, int compared_segments);
char * taosIpStr(uint32_t ipInt); char * taosIpStr(uint32_t ipInt);
uint32_t ip2uint(const char *const ip_addr); uint32_t ip2uint(const char *const ip_addr);
void jsonKeyMd5(void *pMsg, int msgLen, void *pKey); void jsonKeyMd5(void *pMsg, int msgLen, void *pKey);
......
...@@ -444,66 +444,6 @@ int32_t taosHexStrToByteArray(char hexstr[], char bytes[]) { ...@@ -444,66 +444,6 @@ int32_t taosHexStrToByteArray(char hexstr[], char bytes[]) {
return 0; return 0;
} }
// TODO move to comm module
bool taosGetVersionNumber(char *versionStr, int *versionNubmer) {
if (versionStr == NULL || versionNubmer == NULL) {
return false;
}
int versionNumberPos[5] = {0};
int len = (int)strlen(versionStr);
int dot = 0;
for (int pos = 0; pos < len && dot < 4; ++pos) {
if (versionStr[pos] == '.') {
versionStr[pos] = 0;
versionNumberPos[++dot] = pos + 1;
}
}
if (dot != 3) {
return false;
}
for (int pos = 0; pos < 4; ++pos) {
versionNubmer[pos] = atoi(versionStr + versionNumberPos[pos]);
}
versionStr[versionNumberPos[1] - 1] = '.';
versionStr[versionNumberPos[2] - 1] = '.';
versionStr[versionNumberPos[3] - 1] = '.';
return true;
}
int taosCheckVersion(char *input_client_version, char *input_server_version, int comparedSegments) {
char client_version[TSDB_VERSION_LEN] = {0};
char server_version[TSDB_VERSION_LEN] = {0};
int clientVersionNumber[4] = {0};
int serverVersionNumber[4] = {0};
tstrncpy(client_version, input_client_version, sizeof(client_version));
tstrncpy(server_version, input_server_version, sizeof(server_version));
if (!taosGetVersionNumber(client_version, clientVersionNumber)) {
uError("invalid client version:%s", client_version);
return TSDB_CODE_TSC_INVALID_VERSION;
}
if (!taosGetVersionNumber(server_version, serverVersionNumber)) {
uError("invalid server version:%s", server_version);
return TSDB_CODE_TSC_INVALID_VERSION;
}
for(int32_t i = 0; i < comparedSegments; ++i) {
if (clientVersionNumber[i] != serverVersionNumber[i]) {
uError("the %d-th number of server version:%s not matched with client version:%s", i, server_version,
client_version);
return TSDB_CODE_TSC_INVALID_VERSION;
}
}
return 0;
}
char *taosIpStr(uint32_t ipInt) { char *taosIpStr(uint32_t ipInt) {
static char ipStrArray[3][30]; static char ipStrArray[3][30];
static int ipStrIndex = 0; static int ipStrIndex = 0;
......
...@@ -1129,6 +1129,56 @@ class TDTestCase: ...@@ -1129,6 +1129,56 @@ class TDTestCase:
tdSql.error('select 1 != 2 and 1 < 2 or \'abc123\' or 2 between \'abc123\' and 5 and false or "abc123" from tb;') tdSql.error('select 1 != 2 and 1 < 2 or \'abc123\' or 2 between \'abc123\' and 5 and false or "abc123" from tb;')
tdSql.error('select \'1234\' or 1 < 2 or \'aace\' and "cde" between 4 and "def" and "ckas" or 10.1 from tb;') tdSql.error('select \'1234\' or 1 < 2 or \'aace\' and "cde" between 4 and "def" and "ckas" or 10.1 from tb;')
#operator: is NULL
tdSql.error('select 1 is NULL from tb;')
tdSql.error('select 1.0 is NULL from tb;')
tdSql.error('select true is NULL from tb;')
tdSql.error('select \'a\' is NULL from tb;')
tdSql.error('select "abc" is NULL from tb;')
tdSql.error('select 1 is NULL and 1.0 is NULL or "abc" is NULL from tb;')
#operator: is not NULL
tdSql.error('select 1 is not NULL from tb;')
tdSql.error('select 1.0 is not NULL from tb;')
tdSql.error('select true is not NULL from tb;')
tdSql.error('select \'a\' is not NULL from tb;')
tdSql.error('select "abc" is not NULL from tb;')
tdSql.error('select 1 is not NULL and 1.0 is not NULL or "abc" is not NULL from tb;')
#operator: like
tdSql.error('select 1 like 1 from tb;')
tdSql.error('select 1.0 like 1.0 from tb;')
tdSql.error('select true like true from tb;')
tdSql.error('select \'abc\' like \'a_\' from tb;')
tdSql.error('select "abc" like "ab__%" from tb;')
tdSql.error('select 1 like 1 and 1.0 like 1.0 or "abc" like "a%" from tb;')
#operator: match
tdSql.error('select 1 match 1 from tb;')
tdSql.error('select 1.0 match 1.0 from tb;')
tdSql.error('select true match true from tb;')
tdSql.error('select \'abc\' match \'a_\' from tb;')
tdSql.error('select "abc" match "ab__%" from tb;')
tdSql.error('select 1 match 1 and 1.0 match 1.0 or "abc" match "a%" from tb;')
#operator: nmatch
tdSql.error('select 1 nmatch 1 from tb;')
tdSql.error('select 1.0 nmatch 1.0 from tb;')
tdSql.error('select true nmatch true from tb;')
tdSql.error('select \'abc\' nmatch \'a_\' from tb;')
tdSql.error('select "abc" nmatch "ab__%" from tb;')
tdSql.error('select 1 nmatch 1 and 1.0 nmatch 1.0 or "abc" nmatch "a%" from tb;')
#operator: in
tdSql.error('select 1 in 1 from tb;')
tdSql.error('select 1 in (1, 2, 3) from tb;')
tdSql.error('select 1.0 in 1.0 from tb;')
tdSql.error('select 1.0 in (1.0, 2.0, 3.0) from tb;')
tdSql.error('select true in (true, false, true) from tb;')
tdSql.error('select \'abc\' in (\'acd\', \'bce\') from tb;')
tdSql.error('select "abc" in ("acd", "bce") from tb;')
tdSql.error('select 1 in (1,2,3) and 1.0 in (1.0,2.0,3.0) or "abc" in ("abc","cde") from tb;')
tdSql.execute('drop database db') tdSql.execute('drop database db')
def stop(self): def stop(self):
......
...@@ -297,6 +297,91 @@ class TDTestCase: ...@@ -297,6 +297,91 @@ class TDTestCase:
tdSql.error('select percentile(value, 50) or diff(value) = ceil(value) and apercentile(value, 50) from tb') tdSql.error('select percentile(value, 50) or diff(value) = ceil(value) and apercentile(value, 50) from tb')
tdSql.error('select floor(3.5) or round(3.5) and ceil(3.5) > true and round(3.5) or 3 from tb') tdSql.error('select floor(3.5) or round(3.5) and ceil(3.5) > true and round(3.5) or 3 from tb')
#operator: is NULL
tdSql.error('select count(*) is NULL from tb;')
tdSql.error('select avg(value) is NULL from tb;')
tdSql.error('select twa(value) is NULL from tb;')
tdSql.error('select sum(value) is NULL from tb;')
tdSql.error('select stddev(value) is NULL from tb;')
tdSql.error('select min(value) is NULL from tb;')
tdSql.error('select max(value) is NULL from tb;')
tdSql.error('select first(*) is NULL from tb;')
tdSql.error('select last(*) is NULL from tb;')
tdSql.error('select top(value, 3) is NULL or bottom(value,3) is NULL from tb;')
tdSql.error('select percentile(value, 50) is NULL or apercentile(value, 50) is NULL from tb')
tdSql.error('select diff(value) is NULL or ceil(value) is NULL from tb')
tdSql.error('select floor(3.5) is NULL or round(3.5) is NULL or ceil(3.5) is NULL from tb')
#operator: is not NULL
tdSql.error('select count(*) is not NULL from tb;')
tdSql.error('select avg(value) is not NULL from tb;')
tdSql.error('select twa(value) is not NULL from tb;')
tdSql.error('select sum(value) is not NULL from tb;')
tdSql.error('select stddev(value) is not NULL from tb;')
tdSql.error('select min(value) is not NULL from tb;')
tdSql.error('select max(value) is not NULL from tb;')
tdSql.error('select first(*) is not NULL from tb;')
tdSql.error('select last(*) is not NULL from tb;')
tdSql.error('select top(value, 3) is not NULL or bottom(value,3) is not NULL from tb;')
tdSql.error('select percentile(value, 50) is not NULL or apercentile(value, 50) is not NULL from tb')
tdSql.error('select diff(value) is not NULL or ceil(value) is not NULL from tb')
tdSql.error('select floor(3.5) is not NULL or round(3.5) is not NULL or ceil(3.5) is not NULL from tb')
#operator: like
tdSql.error('select count(*) like "abc" from tb;')
tdSql.error('select avg(value) like "abc" from tb;')
tdSql.error('select twa(value) like "abc" from tb;')
tdSql.error('select sum(value) like "abc" from tb;')
tdSql.error('select stddev(value) like "abc" from tb;')
tdSql.error('select min(value) like "abc" from tb;')
tdSql.error('select max(value) like "abc" from tb;')
tdSql.error('select first(*) like "abc" from tb;')
tdSql.error('select last(*) like "abc" from tb;')
tdSql.error('select top(value, 3) like "abc" or bottom(value,3) like "abc" from tb;')
tdSql.error('select percentile(value, 50) like "abc" or apercentile(value, 50) like "abc" from tb')
tdSql.error('select diff(value) like "abc" or ceil(value) like "abc" from tb')
tdSql.error('select floor(3.5) like "abc" or round(3.5) like "abc" or ceil(3.5) like "abc" from tb')
#operator: match
tdSql.error('select count(*) match "abc" from tb;')
tdSql.error('select avg(value) match "abc" from tb;')
tdSql.error('select twa(value) match "abc" from tb;')
tdSql.error('select sum(value) match "abc" from tb;')
tdSql.error('select stddev(value) match "abc" from tb;')
tdSql.error('select min(value) match "abc" from tb;')
tdSql.error('select max(value) match "abc" from tb;')
tdSql.error('select first(*) match "abc" from tb;')
tdSql.error('select last(*) match "abc" from tb;')
tdSql.error('select top(value, 3) match "abc" or bottom(value,3) match "abc" from tb;')
tdSql.error('select percentile(value, 50) match "abc" or apercentile(value, 50) match "abc" from tb')
tdSql.error('select diff(value) match "abc" or ceil(value) match "abc" from tb')
tdSql.error('select floor(3.5) match "abc" or round(3.5) match "abc" or ceil(3.5) match "abc" from tb')
#operator: nmatch
tdSql.error('select count(*) nmatch "abc" from tb;')
tdSql.error('select avg(value) nmatch "abc" from tb;')
tdSql.error('select twa(value) nmatch "abc" from tb;')
tdSql.error('select sum(value) nmatch "abc" from tb;')
tdSql.error('select stddev(value) nmatch "abc" from tb;')
tdSql.error('select min(value) nmatch "abc" from tb;')
tdSql.error('select max(value) nmatch "abc" from tb;')
tdSql.error('select first(*) nmatch "abc" from tb;')
tdSql.error('select last(*) nmatch "abc" from tb;')
tdSql.error('select top(value, 3) nmatch "abc" or bottom(value,3) nmatch "abc" from tb;')
tdSql.error('select percentile(value, 50) nmatch "abc" or apercentile(value, 50) nmatch "abc" from tb')
tdSql.error('select diff(value) nmatch "abc" or ceil(value) nmatch "abc" from tb')
tdSql.error('select floor(3.5) nmatch "abc" or round(3.5) nmatch "abc" or ceil(3.5) nmatch "abc" from tb')
#operator: in
tdSql.error('select count(*) in 1 from tb;')
tdSql.error('select avg(value) in (1, 2, 3) from tb;')
tdSql.error('select twa(value) in 1.0 from tb;')
tdSql.error('select sum(value) in (1.0, 2.0, 3.0) from tb;')
tdSql.error('select min(value) in (true, false, true) from tb;')
tdSql.error('select tbname in (\'acd\', \'bce\') from tb;')
tdSql.error('select t in ("acd", "bce") from tb;')
tdSql.error('select top(value, 3) in (1,2,3) and ceil(value) in (1.0,2.0,3.0) or last(*) in ("abc","cde") from tb;')
tdSql.execute('drop database db') tdSql.execute('drop database db')
def stop(self): def stop(self):
......
...@@ -37,12 +37,44 @@ class TDTestCase: ...@@ -37,12 +37,44 @@ class TDTestCase:
tdSql.checkData(0, 0, 8) tdSql.checkData(0, 0, 8)
tdSql.query("select count(*) from db.stb1") tdSql.query("select count(*) from db.stb1")
tdSql.checkData(0, 0, 160) tdSql.checkData(0, 0, 160)
tdSql.query("select distinct(c5) from db.stb1")
tdSql.checkData(0, 0, None)
tdSql.query("select distinct(c6) from db.stb1")
tdSql.checkData(0, 0, None)
tdSql.query("select distinct(c7) from db.stb1")
tdSql.checkData(0, 0, None)
tdSql.query("select distinct(c8) from db.stb1")
tdSql.checkData(0, 0, None)
tdSql.query("select distinct(c9) from db.stb1")
tdSql.checkData(0, 0, None)
tdSql.query("select distinct(c10) from db.stb1")
tdSql.checkData(0, 0, None)
tdSql.query("select distinct(c11) from db.stb1")
tdSql.checkData(0, 0, None)
tdSql.query("select distinct(c12) from db.stb1")
tdSql.checkData(0, 0, None)
tdSql.execute("reset query cache") tdSql.execute("reset query cache")
tdSql.query("select count(tbname) from db.`stb1-2`") tdSql.query("select count(tbname) from db.`stb1-2`")
tdSql.checkData(0, 0, 8) tdSql.checkData(0, 0, 8)
tdSql.query("select count(*) from db.`stb1-2`") tdSql.query("select count(*) from db.`stb1-2`")
tdSql.checkData(0, 0, 160) tdSql.checkData(0, 0, 160)
tdSql.query("select distinct(c5) from db.`stb1-2`")
tdSql.checkData(0, 0, None)
tdSql.query("select distinct(c6) from db.`stb1-2`")
tdSql.checkData(0, 0, None)
tdSql.query("select distinct(c7) from db.`stb1-2`")
tdSql.checkData(0, 0, None)
tdSql.query("select distinct(c8) from db.`stb1-2`")
tdSql.checkData(0, 0, None)
tdSql.query("select distinct(c9) from db.`stb1-2`")
tdSql.checkData(0, 0, None)
tdSql.query("select distinct(c10) from db.`stb1-2`")
tdSql.checkData(0, 0, None)
tdSql.query("select distinct(c11) from db.`stb1-2`")
tdSql.checkData(0, 0, None)
tdSql.query("select distinct(c12) from db.`stb1-2`")
tdSql.checkData(0, 0, None)
cmd = "taosBenchmark -f ./5-taos-tools/taosbenchmark/json/stmt_auto_create_table.json" cmd = "taosBenchmark -f ./5-taos-tools/taosbenchmark/json/stmt_auto_create_table.json"
tdLog.info("%s" % cmd) tdLog.info("%s" % cmd)
......
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
"sample_file": "./sample.csv", "sample_file": "./sample.csv",
"use_sample_ts": "no", "use_sample_ts": "no",
"tags_file": "", "tags_file": "",
"partial_col_num": 5,
"columns": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 29, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 23, "count":1}], "columns": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 29, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 23, "count":1}],
"tags": [{"type": "TIMESTAMP"},{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 19, "count":1}] "tags": [{"type": "TIMESTAMP"},{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 19, "count":1}]
},{ },{
...@@ -80,6 +81,7 @@ ...@@ -80,6 +81,7 @@
"sample_file": "./sample.csv", "sample_file": "./sample.csv",
"use_sample_ts": "no", "use_sample_ts": "no",
"tags_file": "", "tags_file": "",
"partial_col_num": 5,
"columns": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 29, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 23, "count":1}], "columns": [{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 29, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 23, "count":1}],
"tags": [{"type": "TIMESTAMP"},{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 19, "count":1}] "tags": [{"type": "TIMESTAMP"},{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 19, "count":1}]
}] }]
......
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
"sample_file": "./sample.csv", "sample_file": "./sample.csv",
"use_sample_ts": "no", "use_sample_ts": "no",
"tags_file": "", "tags_file": "",
"partial_col_num": 999,
"columns": [{"type": "TIMESTAMP"},{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 29, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 23, "count":1}], "columns": [{"type": "TIMESTAMP"},{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 29, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 23, "count":1}],
"tags": [{"type": "TIMESTAMP"},{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 19, "count":1}] "tags": [{"type": "TIMESTAMP"},{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 19, "count":1}]
}] }]
......
...@@ -55,7 +55,8 @@ ...@@ -55,7 +55,8 @@
"sample_file": "./sample.csv", "sample_file": "./sample.csv",
"use_sample_ts": "no", "use_sample_ts": "no",
"tags_file": "", "tags_file": "",
"columns": [{"type": "TIMESTAMP"},{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 29, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 23, "count":1}], "partial_col_num": 3,
"columns": [{"type": "TIMESTAMP"},{"type": "INT", "len": 0}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 29, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 23, "count":1}],
"tags": [{"type": "TIMESTAMP"},{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 19, "count":1}] "tags": [{"type": "TIMESTAMP"},{"type": "INT"}, {"type": "BIGINT"}, {"type": "FLOAT"}, {"type": "DOUBLE"}, {"type": "SMALLINT"}, {"type": "TINYINT"}, {"type": "BOOL"}, {"type": "NCHAR","len": 17, "count":1}, {"type": "UINT"}, {"type": "UBIGINT"}, {"type": "UTINYINT"}, {"type": "USMALLINT"}, {"type": "BINARY", "len": 19, "count":1}]
}] }]
}] }]
......
...@@ -56,6 +56,30 @@ class TDTestCase: ...@@ -56,6 +56,30 @@ class TDTestCase:
tdSql.checkData(0, 0, 8) tdSql.checkData(0, 0, 8)
tdSql.query("select count(*) from db.stb") tdSql.query("select count(*) from db.stb")
tdSql.checkData(0, 0, 40) tdSql.checkData(0, 0, 40)
tdSql.query("select distinct(c1) from db.stb")
tdSql.checkData(0, 0, None)
tdSql.query("select distinct(c3) from db.stb")
tdSql.checkData(0, 0, None)
tdSql.query("select distinct(c4) from db.stb")
tdSql.checkData(0, 0, None)
tdSql.query("select distinct(c5) from db.stb")
tdSql.checkData(0, 0, None)
tdSql.query("select distinct(c6) from db.stb")
tdSql.checkData(0, 0, None)
tdSql.query("select distinct(c7) from db.stb")
tdSql.checkData(0, 0, None)
tdSql.query("select distinct(c8) from db.stb")
tdSql.checkData(0, 0, None)
tdSql.query("select distinct(c9) from db.stb")
tdSql.checkData(0, 0, None)
tdSql.query("select distinct(c10) from db.stb")
tdSql.checkData(0, 0, None)
tdSql.query("select distinct(c11) from db.stb")
tdSql.checkData(0, 0, None)
tdSql.query("select distinct(c12) from db.stb")
tdSql.checkData(0, 0, None)
tdSql.query("select distinct(c13) from db.stb")
tdSql.checkData(0, 0, None)
def stop(self): def stop(self):
tdSql.close() tdSql.close()
......
...@@ -28,7 +28,7 @@ else ...@@ -28,7 +28,7 @@ else
ngx.say("select db--- pass.") ngx.say("select db--- pass.")
end end
res = driver.query(conn,"create table m1 (ts timestamp, speed int,owner binary(20))") res = driver.query(conn,"create table m1 (ts timestamp, speed int, owner binary(20), mark nchar(30))")
if res.code ~=0 then if res.code ~=0 then
ngx.say("create table---failed: "..res.error) ngx.say("create table---failed: "..res.error)
...@@ -36,7 +36,7 @@ else ...@@ -36,7 +36,7 @@ else
ngx.say("create table--- pass.") ngx.say("create table--- pass.")
end end
res = driver.query(conn,"insert into m1 values ('2019-09-01 00:00:00.001', 0, 'robotspace'), ('2019-09-01 00:00:00.002',1,'Hilink'),('2019-09-01 00:00:00.003',2,'Harmony')") res = driver.query(conn,"insert into m1 values ('2019-09-01 00:00:00.001', 0, 'robotspace', '世界人民大团结万岁'), ('2019-09-01 00:00:00.002',1,'Hilink','⾾⾿⿀⿁⿂⿃⿄⿅⿆⿇⿈⿉⿊⿋⿌⿍⿎⿏⿐⿑⿒⿓⿔⿕'),('2019-09-01 00:00:00.003',2,'Harmony', '₠₡₢₣₤₥₦₧₨₩₪₫€₭₮₯₰₱₲₳₴₵')")
if res.code ~=0 then if res.code ~=0 then
ngx.say("insert records failed: "..res.error) ngx.say("insert records failed: "..res.error)
return return
...@@ -56,13 +56,12 @@ if res.code ~=0 then ...@@ -56,13 +56,12 @@ if res.code ~=0 then
else else
ngx.say(cjson.encode(res)) ngx.say(cjson.encode(res))
if (#(res.item) == 3) then if (#(res.item) == 3) then
ngx.say("select--- pass") ngx.say("select--- pass")
else else
ngx.say("select--- failed: expect 3 affected records, actually received "..#(res.item)) ngx.say("select--- failed: expect 3 affected records, actually received "..#(res.item))
end end
end end
--[[ --[[
local flag = false local flag = false
function query_callback(res) function query_callback(res)
......
...@@ -35,7 +35,7 @@ static int l_connect(lua_State *L){ ...@@ -35,7 +35,7 @@ static int l_connect(lua_State *L){
} }
lua_getfield(L, 1, "port"); lua_getfield(L, 1, "port");
if (lua_isnumber(L,-1)){ if (lua_isnumber(L, -1)){
port = lua_tonumber(L, -1); port = lua_tonumber(L, -1);
//printf("port = %d\n", port); //printf("port = %d\n", port);
} }
...@@ -113,7 +113,6 @@ static int l_query(lua_State *L){ ...@@ -113,7 +113,6 @@ static int l_query(lua_State *L){
int rows = 0; int rows = 0;
int num_fields = taos_field_count(result); int num_fields = taos_field_count(result);
const TAOS_FIELD *fields = taos_fetch_fields(result); const TAOS_FIELD *fields = taos_fetch_fields(result);
//char temp[256];
const int affectRows = taos_affected_rows(result); const int affectRows = taos_affected_rows(result);
// printf(" affect rows:%d\r\n", affectRows); // printf(" affect rows:%d\r\n", affectRows);
...@@ -122,7 +121,7 @@ static int l_query(lua_State *L){ ...@@ -122,7 +121,7 @@ static int l_query(lua_State *L){
lua_pushinteger(L, affectRows); lua_pushinteger(L, affectRows);
lua_setfield(L, table_index, "affected"); lua_setfield(L, table_index, "affected");
lua_newtable(L); lua_newtable(L);
while ((row = taos_fetch_row(result))) { while ((row = taos_fetch_row(result))) {
//printf("row index:%d\n",rows); //printf("row index:%d\n",rows);
rows++; rows++;
...@@ -136,17 +135,21 @@ static int l_query(lua_State *L){ ...@@ -136,17 +135,21 @@ static int l_query(lua_State *L){
} }
lua_pushstring(L,fields[i].name); lua_pushstring(L,fields[i].name);
int32_t* length = taos_fetch_lengths(result);
switch (fields[i].type) { switch (fields[i].type) {
case TSDB_DATA_TYPE_UTINYINT:
case TSDB_DATA_TYPE_TINYINT: case TSDB_DATA_TYPE_TINYINT:
lua_pushinteger(L,*((char *)row[i])); lua_pushinteger(L,*((char *)row[i]));
break; break;
case TSDB_DATA_TYPE_USMALLINT:
case TSDB_DATA_TYPE_SMALLINT: case TSDB_DATA_TYPE_SMALLINT:
lua_pushinteger(L,*((short *)row[i])); lua_pushinteger(L,*((short *)row[i]));
break; break;
case TSDB_DATA_TYPE_UINT:
case TSDB_DATA_TYPE_INT: case TSDB_DATA_TYPE_INT:
lua_pushinteger(L,*((int *)row[i])); lua_pushinteger(L,*((int *)row[i]));
break; break;
case TSDB_DATA_TYPE_UBIGINT:
case TSDB_DATA_TYPE_BIGINT: case TSDB_DATA_TYPE_BIGINT:
lua_pushinteger(L,*((int64_t *)row[i])); lua_pushinteger(L,*((int64_t *)row[i]));
break; break;
...@@ -156,9 +159,11 @@ static int l_query(lua_State *L){ ...@@ -156,9 +159,11 @@ static int l_query(lua_State *L){
case TSDB_DATA_TYPE_DOUBLE: case TSDB_DATA_TYPE_DOUBLE:
lua_pushnumber(L,*((double *)row[i])); lua_pushnumber(L,*((double *)row[i]));
break; break;
case TSDB_DATA_TYPE_JSON:
case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_BINARY:
case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_NCHAR:
lua_pushstring(L,(char *)row[i]); //printf("type:%d, max len:%d, current len:%d\n",fields[i].type, fields[i].bytes, length[i]);
lua_pushlstring(L,(char *)row[i], length[i]);
break; break;
case TSDB_DATA_TYPE_TIMESTAMP: case TSDB_DATA_TYPE_TIMESTAMP:
lua_pushinteger(L,*((int64_t *)row[i])); lua_pushinteger(L,*((int64_t *)row[i]));
...@@ -166,6 +171,7 @@ static int l_query(lua_State *L){ ...@@ -166,6 +171,7 @@ static int l_query(lua_State *L){
case TSDB_DATA_TYPE_BOOL: case TSDB_DATA_TYPE_BOOL:
lua_pushinteger(L,*((char *)row[i])); lua_pushinteger(L,*((char *)row[i]));
break; break;
case TSDB_DATA_TYPE_NULL:
default: default:
lua_pushnil(L); lua_pushnil(L);
break; break;
......
...@@ -28,14 +28,14 @@ static int l_connect(lua_State *L){ ...@@ -28,14 +28,14 @@ static int l_connect(lua_State *L){
luaL_checktype(L, 1, LUA_TTABLE); luaL_checktype(L, 1, LUA_TTABLE);
lua_getfield(L,1,"host"); lua_getfield(L, 1,"host");
if (lua_isstring(L,-1)){ if (lua_isstring(L,-1)){
host = lua_tostring(L, -1); host = lua_tostring(L, -1);
// printf("host = %s\n", host); // printf("host = %s\n", host);
} }
lua_getfield(L, 1, "port"); lua_getfield(L, 1, "port");
if (lua_isinteger(L,-1)){ if (lua_isinteger(L, -1)){
port = lua_tointeger(L, -1); port = lua_tointeger(L, -1);
//printf("port = %d\n", port); //printf("port = %d\n", port);
} }
...@@ -113,7 +113,6 @@ static int l_query(lua_State *L){ ...@@ -113,7 +113,6 @@ static int l_query(lua_State *L){
int rows = 0; int rows = 0;
int num_fields = taos_field_count(result); int num_fields = taos_field_count(result);
const TAOS_FIELD *fields = taos_fetch_fields(result); const TAOS_FIELD *fields = taos_fetch_fields(result);
//char temp[256];
const int affectRows = taos_affected_rows(result); const int affectRows = taos_affected_rows(result);
// printf(" affect rows:%d\r\n", affectRows); // printf(" affect rows:%d\r\n", affectRows);
...@@ -122,7 +121,7 @@ static int l_query(lua_State *L){ ...@@ -122,7 +121,7 @@ static int l_query(lua_State *L){
lua_pushinteger(L, affectRows); lua_pushinteger(L, affectRows);
lua_setfield(L, table_index, "affected"); lua_setfield(L, table_index, "affected");
lua_newtable(L); lua_newtable(L);
while ((row = taos_fetch_row(result))) { while ((row = taos_fetch_row(result))) {
//printf("row index:%d\n",rows); //printf("row index:%d\n",rows);
rows++; rows++;
...@@ -136,17 +135,21 @@ static int l_query(lua_State *L){ ...@@ -136,17 +135,21 @@ static int l_query(lua_State *L){
} }
lua_pushstring(L,fields[i].name); lua_pushstring(L,fields[i].name);
int32_t* length = taos_fetch_lengths(result);
switch (fields[i].type) { switch (fields[i].type) {
case TSDB_DATA_TYPE_UTINYINT:
case TSDB_DATA_TYPE_TINYINT: case TSDB_DATA_TYPE_TINYINT:
lua_pushinteger(L,*((char *)row[i])); lua_pushinteger(L,*((char *)row[i]));
break; break;
case TSDB_DATA_TYPE_USMALLINT:
case TSDB_DATA_TYPE_SMALLINT: case TSDB_DATA_TYPE_SMALLINT:
lua_pushinteger(L,*((short *)row[i])); lua_pushinteger(L,*((short *)row[i]));
break; break;
case TSDB_DATA_TYPE_UINT:
case TSDB_DATA_TYPE_INT: case TSDB_DATA_TYPE_INT:
lua_pushinteger(L,*((int *)row[i])); lua_pushinteger(L,*((int *)row[i]));
break; break;
case TSDB_DATA_TYPE_UBIGINT:
case TSDB_DATA_TYPE_BIGINT: case TSDB_DATA_TYPE_BIGINT:
lua_pushinteger(L,*((int64_t *)row[i])); lua_pushinteger(L,*((int64_t *)row[i]));
break; break;
...@@ -156,9 +159,11 @@ static int l_query(lua_State *L){ ...@@ -156,9 +159,11 @@ static int l_query(lua_State *L){
case TSDB_DATA_TYPE_DOUBLE: case TSDB_DATA_TYPE_DOUBLE:
lua_pushnumber(L,*((double *)row[i])); lua_pushnumber(L,*((double *)row[i]));
break; break;
case TSDB_DATA_TYPE_JSON:
case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_BINARY:
case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_NCHAR:
lua_pushstring(L,(char *)row[i]); //printf("type:%d, max len:%d, current len:%d\n",fields[i].type, fields[i].bytes, length[i]);
lua_pushlstring(L,(char *)row[i], length[i]);
break; break;
case TSDB_DATA_TYPE_TIMESTAMP: case TSDB_DATA_TYPE_TIMESTAMP:
lua_pushinteger(L,*((int64_t *)row[i])); lua_pushinteger(L,*((int64_t *)row[i]));
...@@ -166,6 +171,7 @@ static int l_query(lua_State *L){ ...@@ -166,6 +171,7 @@ static int l_query(lua_State *L){
case TSDB_DATA_TYPE_BOOL: case TSDB_DATA_TYPE_BOOL:
lua_pushinteger(L,*((char *)row[i])); lua_pushinteger(L,*((char *)row[i]));
break; break;
case TSDB_DATA_TYPE_NULL:
default: default:
lua_pushnil(L); lua_pushnil(L);
break; break;
......
...@@ -37,7 +37,7 @@ else ...@@ -37,7 +37,7 @@ else
print("select db--- pass.") print("select db--- pass.")
end end
res = driver.query(conn,"create table m1 (ts timestamp, speed int,owner binary(20))") res = driver.query(conn,"create table m1 (ts timestamp, speed int, owner binary(20), mark nchar(30))")
if res.code ~=0 then if res.code ~=0 then
print("create table---failed: "..res.error) print("create table---failed: "..res.error)
return return
...@@ -45,7 +45,7 @@ else ...@@ -45,7 +45,7 @@ else
print("create table--- pass.") print("create table--- pass.")
end end
res = driver.query(conn,"insert into m1 values ('2019-09-01 00:00:00.001',0,'robotspace'), ('2019-09-01 00:00:00.002',1,'Hilink'),('2019-09-01 00:00:00.003',2,'Harmony')") res = driver.query(conn,"insert into m1 values ('2019-09-01 00:00:00.001', 0, 'robotspace', '世界人民大团结万岁'), ('2019-09-01 00:00:00.002', 1, 'Hilink', '⾾⾿⿀⿁⿂⿃⿄⿅⿆⿇⿈⿉⿊⿋⿌⿍⿎⿏⿐⿑⿒⿓⿔⿕'),('2019-09-01 00:00:00.003', 2, 'Harmony', '₠₡₢₣₤₥₦₧₨₩₪₫€₭₮₯₰₱₲₳₴₵')")
if res.code ~=0 then if res.code ~=0 then
print("insert records failed: "..res.error) print("insert records failed: "..res.error)
return return
...@@ -64,7 +64,11 @@ if res.code ~=0 then ...@@ -64,7 +64,11 @@ if res.code ~=0 then
return return
else else
if (#(res.item) == 3) then if (#(res.item) == 3) then
print("select--- pass") print("select--- pass")
print(res.item[1].mark)
print(res.item[2].mark)
print(res.item[3].mark)
else else
print("select--- failed: expect 3 affected records, actually received "..#(res.item)) print("select--- failed: expect 3 affected records, actually received "..#(res.item))
end end
......
# How to build image
## eg:
cd ./collectd_docker
docker build -t "taosadapter_collectd:v1" .
# How to run single container
## eg:
cd ./collectd_docker
./run_collectd.sh -h
#Usage:
#1st arg: agent_count
#2nd arg: container_hostname prefix
#3rd arg: TaosadapterIp
#4th arg: TaosadapterPort
#5th arg: CollectdInterval
#eg: ./run_collectd.sh 1 collectd_agent1 172.26.10.86 6047 1
#eg: ./run_collectd.sh 2 collectd_agent* 172.26.10.86 6047 1
#rm all: ./run_collectd.sh rm collectd_agent*
# How to run all container
## You need to edit run_all.sh to set taosadapter ip/port by manual, but count of each agent could be defined in bash_args
./run_all.sh -h
#Usage:
#1st arg: collectd_count
#2nd arg: icinga2_count
#3rd arg: statsd_count
#4th arg: tcollector_count
#5th arg: telegraf_count
#6th arg: node_exporter port range
#eg: ./run_all.sh 10 10 1 10 50 10000:10020
FROM ubuntu:20.04
ENV REFRESHED_AT 2021-12-04
WORKDIR /root
ARG DEBIAN_FRONTEND=noninteractive
RUN set -ex; \
apt update -y --fix-missing && \
apt-get install -y --no-install-recommends collectd && \
rm -rf /var/lib/apt/lists/*
COPY collectd.conf /etc/collectd/collectd.conf
COPY entrypoint.sh /entrypoint.sh
ENV CollectdHostname localhost
ENV TaosadapterIp 127.0.0.1
ENV TaosadapterPort 6047
ENV CollectdInterval 10
ENTRYPOINT ["/entrypoint.sh"]
#!/bin/bash
sed -i 's/CollectdHostname/'$HOSTNAME'/g;s/TaosadapterIp/'$TaosadapterIp'/g;s/TaosadapterPort/'$TaosadapterPort'/g;s/CollectdInterval/'$CollectdInterval'/g;' /etc/collectd/collectd.conf
/etc/init.d/collectd start
tail -f /dev/null
#!/bin/bash
case "$1" in
-h|--help)
echo "Usage:"
echo "1st arg: agent_count"
echo "2nd arg: container_hostname prefix"
echo "3rd arg: TaosadapterIp"
echo "4th arg: TaosadapterPort"
echo "5th arg: CollectdInterval"
echo "eg: ./run_collectd.sh 1 collectd_agent1 172.26.10.86 6047 1"
echo "eg: ./run_collectd.sh 2 collectd_agent* 172.26.10.86 6047 1"
echo "rm all: ./run_collectd.sh rm collectd_agent*"
exit 0
;;
esac
if [ $1 == "rm" ]; then
docker ps | grep $2 | awk '{print $1}' | xargs docker stop | xargs docker rm
exit
fi
if [ ! -n "$1" ]; then
echo "please input 1st arg"
exit
fi
if [ ! -n "$2" ]; then
echo "please input 2nd arg"
exit
fi
if [ ! -n "$3" ]; then
echo "please input 3rd arg"
exit
fi
if [ ! -n "$4" ]; then
echo "please input 4th arg"
exit
fi
if [ ! -n "$5" ]; then
echo "please input 5th arg"
exit
fi
if [ $1 -eq 1 ];then
docker ps | grep $2
if [ $? -eq 0 ];then
docker stop $2 && docker rm $2
fi
docker run -itd --name $2 -h $2 -e TaosadapterIp=$3 -e TaosadapterPort=$4 -e CollectdInterval=$5 taosadapter_collectd:v1 /bin/bash
else
perfix=`echo $2 | cut -d '*' -f 1`
for i in `seq 1 $1`;
do
docker ps | grep $perfix$i
if [ $? -eq 0 ];then
docker stop $perfix$i && docker rm $perfix$i
fi
docker run -itd --name $perfix$i -h $perfix$i -e TaosadapterIp=$3 -e TaosadapterPort=$4 -e CollectdInterval=$5 taosadapter_collectd:v1 /bin/bash
done
fi
#docker run -itd --name collectd_agent1 -h collectd_agent1 -e CollectdHostname=collectd_agent1 -e TaosadapterIp=172.26.10.86 -e TaosadapterPort=6047 -e CollectdInterval=1 taosadapter_collectd:v1 /bin/bash
FROM ubuntu:20.04
ENV REFRESHED_AT 2021-12-05
ARG DEBIAN_FRONTEND=noninteractive
WORKDIR /root
RUN set -ex; \
apt update -y --fix-missing && \
apt install -y gnupg
COPY icinga-focal.list /etc/apt/sources.list.d/icinga-focal.list
COPY icinga.key /root/icinga.key
RUN set -ex; \
apt-key add icinga.key && \
apt update -y --fix-missing && \
apt-get install -y --no-install-recommends icinga2 monitoring-plugins systemctl && \
icinga2 feature enable opentsdb && \
rm -rf /var/lib/apt/lists/*
COPY opentsdb.conf /etc/icinga2/features-available/opentsdb.conf
COPY entrypoint.sh /entrypoint.sh
COPY templates.conf /etc/icinga2/conf.d/templates.conf
ENV Icinga2Interval 10s
ENV TaosadapterIp 127.0.0.1
ENV TaosadapterPort 6048
ENTRYPOINT ["/entrypoint.sh"]
#!/bin/bash
sed -i 's/TaosadapterIp/'$TaosadapterIp'/g;s/TaosadapterPort/'$TaosadapterPort'/g;' /etc/icinga2/features-available/opentsdb.conf
sed -i 's/Icinga2Interval/'$Icinga2Interval'/g;' /etc/icinga2/conf.d/templates.conf
systemctl restart icinga2
tail -f /dev/null
deb http://packages.icinga.com/ubuntu icinga-focal main
deb-src http://packages.icinga.com/ubuntu icinga-focal main
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v2.0.19 (GNU/Linux)
mQGiBFKHzk4RBACSHMIFTtfw4ZsNKAA03Gf5t7ovsKWnS7kcMYleAidypqhOmkGg
0petiYsMPYT+MOepCJFGNzwQwJhZrdLUxxMSWay4Xj0ArgpD9vbvU+gj8Tb02l+x
SqNGP8jXMV5UnK4gZsrYGLUPvx47uNNYRIRJAGOPYTvohhnFJiG402dzlwCg4u5I
1RdFplkp9JM6vNM9VBIAmcED/2jr7UQGsPs8YOiPkskGHLh/zXgO8SvcNAxCLgbp
BjGcF4Iso/A2TAI/2KGJW6kBW/Paf722ltU6s/6mutdXJppgNAz5nfpEt4uZKZyu
oSWf77179B2B/Wl1BsX/Oc3chscAgQb2pD/qPF/VYRJU+hvdQkq1zfi6cVsxyREV
k+IwA/46nXh51CQxE29ayuy1BoIOxezvuXFUXZ8rP6aCh4KaiN9AJoy7pBieCzsq
d7rPEeGIzBjI+yhEu8p92W6KWzL0xduWfYg9I7a2GTk8CaLX2OCLuwnKd7RVDyyZ
yzRjWs0T5U7SRAWspLStYxMdKert9lLyQiRHtLwmlgBPqa0gh7Q+SWNpbmdhIE9w
ZW4gU291cmNlIE1vbml0b3JpbmcgKEJ1aWxkIHNlcnZlcikgPGluZm9AaWNpbmdh
Lm9yZz6IYAQTEQIAIAUCUofOTgIbAwYLCQgHAwIEFQIIAwQWAgMBAh4BAheAAAoJ
EMbjGcM0QQaCgSQAnRjXdbsyqziqhmxfAKffNJYuMPwdAKCS/IRCVyQzApFBtIBQ
1xuoym/4C7kCDQRSh85OEAgAvPwjlURCi8z6+7i60no4n16dNcSzd6AT8Kizpv2r
9BmNBff/GNYGnHyob/DMtmO2esEuVG8w62rO9m1wzzXzjbtmtU7NZ1Tg+C+reU2I
GNVu3SYtEVK/UTJHAhLcgry9yD99610tYPN2Fx33Efse94mXOreBfCvDsmFGSc7j
GVNCWXpMR3jTYyGj1igYd5ztOzG63D8gPyOucTTl+RWN/G9EoGBv6sWqk5eCd1Fs
JlWyQX4BJn3YsCZx3uj1DWL0dAl2zqcn6m1M4oj1ozW47MqM/efKOcV6VvCs9SL8
F/NFvZcH4LKzeupCQ5jEONqcTlVlnLlIqId95Z4DI4AV9wADBQf/S6sKA4oH49tD
Yb5xAfUyEp5ben05TzUJbXs0Z7hfRQzy9+vQbWGamWLgg3QRUVPx1e4IT+W5vEm5
dggNTMEwlLMI7izCPDcD32B5oxNVxlfj428KGllYWCFj+edY+xKTvw/PHnn+drKs
LE65Gwx4BPHm9EqWHIBX6aPzbgbJZZ06f6jWVBi/N7e/5n8lkxXqS23DBKemapyu
S1i56sH7mQSMaRZP/iiOroAJemPNxv1IQkykxw2woWMmTLKLMCD/i+4DxejE50tK
dxaOLTc4HDCsattw/RVJO6fwE414IXHMv330z4HKWJevMQ+CmQGfswvCwgeBP9n8
PItLjBQAXIhJBBgRAgAJBQJSh85OAhsMAAoJEMbjGcM0QQaCzpAAmwUNoRyySf9p
5G3/2UD1PMueIwOtAKDVVDXEq5LJPVg4iafNu0SRMwgP0Q==
=icbY
-----END PGP PUBLIC KEY BLOCK-----
/**
* The OpenTsdbWriter type writes check result metrics and
* performance data to a OpenTSDB tcp socket.
*/
object OpenTsdbWriter "opentsdb" {
host = "TaosadapterIp"
port = TaosadapterPort
//enable_generic_metrics = false
// Custom Tagging, refer to Icinga object type documentation for
// OpenTsdbWriter
//host_template = {
// metric = "icinga.host"
// tags = {
// zone = "$host.zone$"
// }
//}
//service_template = {
// metric = "icinga.service.$service.check_command$"
// tags = {
// zone = "$service.zone$"
// }
//}
}
#!/bin/bash
case "$1" in
-h|--help)
echo "Usage:"
echo "1st arg: agent_count"
echo "2nd arg: container_hostname prefix"
echo "3rd arg: TaosadapterIp"
echo "4th arg: TaosadapterPort"
echo "5th arg: Icinga2Interval"
echo "eg: ./run_icinga2.sh 1 icinga2_agent1 172.26.10.86 6048 1"
echo "eg: ./run_icinga2.sh 2 icinga2_agent* 172.26.10.86 6048 1"
exit 0
;;
esac
if [ $1 == "rm" ]; then
docker ps | grep $2 | awk '{print $1}' | xargs docker stop | xargs docker rm
exit
fi
if [ ! -n "$1" ]; then
echo "please input 1st arg"
exit
fi
if [ ! -n "$2" ]; then
echo "please input 2nd arg"
exit
fi
if [ ! -n "$3" ]; then
echo "please input 3rd arg"
exit
fi
if [ ! -n "$4" ]; then
echo "please input 4th arg"
exit
fi
if [ ! -n "$5" ]; then
echo "please input 5th arg"
exit
fi
if [ $1 -eq 1 ];then
docker ps | grep $2
if [ $? -eq 0 ];then
docker stop $2 && docker rm $2
fi
docker run -itd --name $2 -h $2 -e TaosadapterIp=$3 -e TaosadapterPort=$4 -e Icinga2Interval=$5 taosadapter_icinga2:v1 /bin/bash
else
perfix=`echo $2 | cut -d '*' -f 1`
for i in `seq 1 $1`;
do
docker ps | grep $perfix$i
if [ $? -eq 0 ];then
docker stop $perfix$i && docker rm $perfix$i
fi
docker run -itd --name $perfix$i -h $perfix$i -e TaosadapterIp=$3 -e TaosadapterPort=$4 -e Icinga2Interval=$5 taosadapter_icinga2:v1 /bin/bash
done
fi
#docker run -itd --name icinga2_agent1 -h icinga2_agent1 -e TaosadapterIp=172.26.10.86 -e TaosadapterPort=6048 -e Icinga2Interval=1s taosadapter_icinga2:v1 /bin/bash
/*
* Generic template examples.
*/
/**
* Provides default settings for hosts. By convention
* all hosts should import this template.
*
* The CheckCommand object `hostalive` is provided by
* the plugin check command templates.
* Check the documentation for details.
*/
template Host "generic-host" {
max_check_attempts = 3
check_interval = Icinga2Interval
retry_interval = 30s
check_command = "hostalive"
}
/**
* Provides default settings for services. By convention
* all services should import this template.
*/
template Service "generic-service" {
max_check_attempts = 5
check_interval = Icinga2Interval
retry_interval = 30s
}
/**
* Provides default settings for users. By convention
* all users should inherit from this template.
*/
template User "generic-user" {
}
/**
* Provides default settings for host notifications.
* By convention all host notifications should import
* this template.
*/
template Notification "mail-host-notification" {
command = "mail-host-notification"
states = [ Up, Down ]
types = [ Problem, Acknowledgement, Recovery, Custom,
FlappingStart, FlappingEnd,
DowntimeStart, DowntimeEnd, DowntimeRemoved ]
vars += {
// notification_icingaweb2url = "https://www.example.com/icingaweb2"
// notification_from = "Icinga 2 Host Monitoring <icinga@example.com>"
notification_logtosyslog = false
}
period = "24x7"
}
/**
* Provides default settings for service notifications.
* By convention all service notifications should import
* this template.
*/
template Notification "mail-service-notification" {
command = "mail-service-notification"
states = [ OK, Warning, Critical, Unknown ]
types = [ Problem, Acknowledgement, Recovery, Custom,
FlappingStart, FlappingEnd,
DowntimeStart, DowntimeEnd, DowntimeRemoved ]
vars += {
// notification_icingaweb2url = "https://www.example.com/icingaweb2"
// notification_from = "Icinga 2 Service Monitoring <icinga@example.com>"
notification_logtosyslog = false
}
period = "24x7"
}
FROM ubuntu:20.04
ENV REFRESHED_AT 2021-12-05
WORKDIR /root
ARG DEBIAN_FRONTEND=noninteractive
RUN set -ex; \
apt update -y --fix-missing && \
apt-get install -y --no-install-recommends wget && \
wget http://39.105.163.10:9000/node_exporter-1.3.0.linux-amd64.tar.gz && \
tar -xvf node_exporter-1.3.0.linux-amd64.tar.gz && \
mv node_exporter-1.3.0.linux-amd64/node_exporter /usr/bin/node_exporter && \
rm -rf node_exporter-1.3.0.linux-amd64 node_exporter-1.3.0.linux-amd64.tar.gz &&\
apt remove -y wget && \
rm -rf /var/lib/apt/lists/*
COPY entrypoint.sh /entrypoint.sh
ENV NodeExporterHostname localhost
ENV NodeExporterInterval 10
ENTRYPOINT ["/entrypoint.sh"]
import sys
## eg: python3 gen_taosadapter_url.py 172.26.10.87 10000:10050
#TaosadapterIp = "172.26.10.87"
TaosadapterIp = sys.argv[1]
#TaosadapterPort = "10000:10050"
TaosadapterPort = sys.argv[2]
start_port = int(TaosadapterPort.split(":")[0])
end_port = int(TaosadapterPort.split(":")[1])
urls_list = []
for port in range(start_port, end_port+1):
urls_list.append(f"http://{TaosadapterIp}:{port}")
print(urls_list)
#!/bin/bash
case "$1" in
-h|--help)
echo "Usage:"
echo "1st arg: port range"
echo "2nd arg: container_hostname prefix"
echo "eg: ./run_node_exporter.sh 10000 node_exporter_agent1"
echo "eg: ./run_node_exporter.sh 10000:10010 node_exporter_agent*"
exit 0
;;
esac
if [ $1 == "rm" ]; then
docker ps | grep $2 | awk '{print $1}' | xargs docker stop | xargs docker rm
exit
fi
if [ ! -n "$1" ]; then
echo "please input 1st arg"
exit
fi
if [ ! -n "$2" ]; then
echo "please input 2nd arg"
exit
fi
if [ ! `echo $1 | grep :` ];then
docker ps | grep $2
if [ $? -eq 0 ];then
docker stop $2 && docker rm $2
fi
docker run -itd --name $2 -h $2 -p $1:9100 taosadapter_node_exporter:v1 /bin/bash
else
perfix=`echo $2 | cut -d '*' -f 1`
start_port=`echo $1 | cut -d ':' -f 1`
end_port=`echo $1 | cut -d ':' -f 2`
for i in `seq $start_port $end_port`;
do
docker ps | grep $perfix$i
if [ $? -eq 0 ];then
docker stop $perfix$i && docker rm $perfix$i
fi
docker run -itd --name $perfix$i -h $perfix$i -p $i:9100 taosadapter_node_exporter:v1 /bin/bash
done
fi
#docker run -itd --name node_exporter_agent1 -h node_exporter_agent1 -p 10000:9100 taosadapter_node_exporter:v1 /bin/bash
#!/bin/bash
./collectd_docker/run_collectd.sh rm collectd_agent*
./icinga2_docker/run_icinga2.sh rm icinga2_agent*
./statsd_docker/run_statsd.sh rm statsd_agent*
./tcollector_docker/run_tcollector.sh rm tcollector_agent*
./telegraf_docker/run_telegraf.sh rm telegraf_agent*
./node_exporter_docker/run_node_exporter.sh rm node_exporter_agent*
#!/bin/bash
case "$1" in
-h|--help)
echo "Usage:"
echo "1st arg: collectd_count"
echo "2nd arg: icinga2_count"
echo "3rd arg: statsd_count"
echo "4th arg: tcollector_count"
echo "5th arg: telegraf_count"
echo "6th arg: node_exporter port range"
echo "eg: ./run_all.sh 10 10 1 10 50 10000:10010"
exit 0
;;
esac
collectd_count=$1
icinga2_count=$2
statsd_count=$3
tcollector_count=$4
telegraf_count=$5
node_exporter_count=$6
taosadapter1_ip=172.26.10.86
taosadapter2_ip=172.26.10.85
taosadapter3_ip=172.26.10.84
./collectd_docker/run_collectd.sh $1 taosadapter1_collectd_agent* $taosadapter1_ip 6047 1
./icinga2_docker/run_icinga2.sh $2 taosadapter1_icinga2_agent* $taosadapter1_ip 6048 1
./statsd_docker/run_statsd.sh $3 taosadapter1_statsd_agent $taosadapter1_ip 6044
./tcollector_docker/run_tcollector.sh $4 taosadapter1_tcollector_agent* $taosadapter1_ip 6049
./telegraf_docker/run_telegraf.sh $5 taosadapter1_telegraf_agent* $taosadapter1_ip 6041 10s taosadapter1_telegraf
./collectd_docker/run_collectd.sh $1 taosadapter2_collectd_agent* $taosadapter2_ip 6047 1
./icinga2_docker/run_icinga2.sh $2 taosadapter2_icinga2_agent* $taosadapter2_ip 6048 1
./statsd_docker/run_statsd.sh $3 taosadapter2_statsd_agent $taosadapter2_ip 6044
./tcollector_docker/run_tcollector.sh $4 taosadapter2_tcollector_agent* $taosadapter2_ip 6049
./telegraf_docker/run_telegraf.sh $5 taosadapter2_telegraf_agent* $taosadapter2_ip 6041 10s taosadapter2_telegraf
./collectd_docker/run_collectd.sh $1 taosadapter3_collectd_agent* $taosadapter3_ip 6047 1
./icinga2_docker/run_icinga2.sh $2 taosadapter3_icinga2_agent* $taosadapter3_ip 6048 1
./statsd_docker/run_statsd.sh $3 taosadapter3_statsd_agent $taosadapter3_ip 6044
./tcollector_docker/run_tcollector.sh $4 taosadapter3_tcollector_agent* $taosadapter3_ip 6049
./telegraf_docker/run_telegraf.sh $5 taosadapter3_telegraf_agent* $taosadapter3_ip 6041 10s taosadapter3_telegraf
./node_exporter_docker/run_node_exporter.sh $6 node_exporter_agent*
FROM ubuntu:20.04
ENV REFRESHED_AT 2021-12-06
WORKDIR /root
ARG DEBIAN_FRONTEND=noninteractive
RUN set -ex; \
apt update -y --fix-missing && \
apt-get install -y --no-install-recommends nodejs devscripts debhelper wget netcat-traditional npm && \
wget http://39.105.163.10:9000/statsd.tar.gz && \
tar -xvf statsd.tar.gz && \
cd statsd && \
npm install && \
npm audit fix && \
rm -rf statsd.tar.gz && \
apt remove -y wget && \
rm -rf /var/lib/apt/lists/*
COPY config.js /root/statsd/config.js
COPY entrypoint.sh /entrypoint.sh
ENV TaosadapterIp 127.0.0.1
ENV TaosadapterPort 6044
ENTRYPOINT ["/entrypoint.sh"]
/*
Graphite Required Variable:
(Leave this unset to avoid sending stats to Graphite.
Set debug flag and leave this unset to run in 'dry' debug mode -
useful for testing statsd clients without a Graphite server.)
graphiteHost: hostname or IP of Graphite server
Optional Variables:
graphitePort: port for the graphite text collector [default: 2003]
graphitePicklePort: port for the graphite pickle collector [default: 2004]
graphiteProtocol: either 'text' or 'pickle' [default: 'text']
backends: an array of backends to load. Each backend must exist
by name in the directory backends/. If not specified,
the default graphite backend will be loaded.
* example for console and graphite:
[ "./backends/console", "./backends/graphite" ]
servers: an array of server configurations.
If not specified, the server, address,
address_ipv6, and port top-level configuration
options are used to configure a single server for
backwards-compatibility
Each server configuration supports the following keys:
server: the server to load. The server must exist by name in the directory
servers/. If not specified, the default udp server will be loaded.
* example for tcp server:
"./servers/tcp"
address: address to listen on [default: 0.0.0.0]
address_ipv6: defines if the address is an IPv4 or IPv6 address [true or false, default: false]
port: port to listen for messages on [default: 8125]
socket: (only for tcp servers) path to unix domain socket which will be used to receive
metrics [default: undefinded]
socket_mod: (only for tcp servers) file mode which should be applied to unix domain socket, relevant
only if socket option is used [default: undefined]
debug: debug flag [default: false]
mgmt_address: address to run the management TCP interface on
[default: 0.0.0.0]
mgmt_port: port to run the management TCP interface on [default: 8126]
title: Allows for overriding the process title. [default: statsd]
if set to false, will not override the process title and let the OS set it.
The length of the title has to be less than or equal to the binary name + cli arguments
NOTE: This does not work on Mac's with node versions prior to v0.10
healthStatus: default health status to be returned and statsd process starts ['up' or 'down', default: 'up']
dumpMessages: log all incoming messages
flushInterval: interval (in ms) to flush metrics to each backend
percentThreshold: for time information, calculate the Nth percentile(s)
(can be a single value or list of floating-point values)
negative values mean to use "top" Nth percentile(s) values
[%, default: 90]
flush_counts: send stats_counts metrics [default: true]
keyFlush: log the most frequently sent keys [object, default: undefined]
interval: how often to log frequent keys [ms, default: 0]
percent: percentage of frequent keys to log [%, default: 100]
log: location of log file for frequent keys [default: STDOUT]
deleteIdleStats: don't send values to graphite for inactive counters, sets, gauges, or timers
as opposed to sending 0. For gauges, this unsets the gauge (instead of sending
the previous value). Can be individually overridden. [default: false]
deleteGauges: don't send values to graphite for inactive gauges, as opposed to sending the previous value [default: false]
gaugesMaxTTL: number of flush cycles to wait before the gauge is marked as inactive, to use in combination with deleteGauges [default: 1]
deleteTimers: don't send values to graphite for inactive timers, as opposed to sending 0 [default: false]
deleteSets: don't send values to graphite for inactive sets, as opposed to sending 0 [default: false]
deleteCounters: don't send values to graphite for inactive counters, as opposed to sending 0 [default: false]
prefixStats: prefix to use for the statsd statistics data for this running instance of statsd [default: statsd]
applies to both legacy and new namespacing
keyNameSanitize: sanitize all stat names on ingress [default: true]
If disabled, it is up to the backends to sanitize keynames
as appropriate per their storage requirements.
calculatedTimerMetrics: List of timer metrics that will be sent. Default will send all metrics.
To filter on percents and top percents: append '_percent' to the metric name.
Example: calculatedTimerMetrics: ['count', 'median', 'upper_percent', 'histogram']
console:
prettyprint: whether to prettyprint the console backend
output [true or false, default: true]
log: log settings [object, default: undefined]
backend: where to log: stdout or syslog [string, default: stdout]
application: name of the application for syslog [string, default: statsd]
level: log level for [node-]syslog [string, default: LOG_INFO]
graphite:
legacyNamespace: use the legacy namespace [default: true]
globalPrefix: global prefix to use for sending stats to graphite [default: "stats"]
prefixCounter: graphite prefix for counter metrics [default: "counters"]
prefixTimer: graphite prefix for timer metrics [default: "timers"]
prefixGauge: graphite prefix for gauge metrics [default: "gauges"]
prefixSet: graphite prefix for set metrics [default: "sets"]
globalSuffix: global suffix to use for sending stats to graphite [default: ""]
This is particularly useful for sending per host stats by
settings this value to: require('os').hostname().split('.')[0]
repeater: an array of hashes of the for host: and port:
that details other statsd servers to which the received
packets should be "repeated" (duplicated to).
e.g. [ { host: '10.10.10.10', port: 8125 },
{ host: 'observer', port: 88125 } ]
repeaterProtocol: whether to use udp4, udp6, or tcp for repeaters.
["udp4," "udp6", or "tcp" default: "udp4"]
histogram: for timers, an array of mappings of strings (to match metrics) and
corresponding ordered non-inclusive upper limits of bins.
For all matching metrics, histograms are maintained over
time by writing the frequencies for all bins.
'inf' means infinity. A lower limit of 0 is assumed.
default: [], meaning no histograms for any timer.
First match wins. examples:
* histogram to only track render durations, with unequal
class intervals and catchall for outliers:
[ { metric: 'render', bins: [ 0.01, 0.1, 1, 10, 'inf'] } ]
* histogram for all timers except 'foo' related,
equal class interval and catchall for outliers:
[ { metric: 'foo', bins: [] },
{ metric: '', bins: [ 50, 100, 150, 200, 'inf'] } ]
automaticConfigReload: whether to watch the config file and reload it when it
changes. The default is true. Set this to false to disable.
*/
{
graphitePort: 2003
, graphiteHost: "127.0.0.1"
, port: 8125
, backends: [ "./backends/console", "./backends/graphite", "./backends/repeater" ]
, repeater: [ { host: '127.0.0.1', port: 8125 }, { host:'TaosadapterIp', port: TaosadapterPort } ]
}
#!/bin/bash
sed -i 's/TaosadapterIp/'$TaosadapterIp'/g;s/TaosadapterPort/'$TaosadapterPort'/g;' /root/statsd/config.js
nohup node /root/statsd/stats.js /root/statsd/config.js &
sleep 10
for i in `seq 1 100`;
do
echo "${HOSTNAME}.count${i}:55|c" | nc -w 1 -u 127.0.0.1 8125
done
tail -f /dev/null
#!/bin/bash
case "$1" in
-h|--help)
echo "Usage:"
echo "1st arg: agent_count"
echo "2nd arg: container_hostname prefix"
echo "3rd arg: TaosadapterIp"
echo "4th arg: TaosadapterPort"
echo "eg: ./run_statsd.sh 1 statsd_agent1 172.26.10.86 6044"
echo "eg: ./run_statsd.sh 2 statsd_agent* 172.26.10.86 6044"
exit 0
;;
esac
if [ $1 == "rm" ]; then
docker ps | grep $2 | awk '{print $1}' | xargs docker stop | xargs docker rm
exit
fi
if [ ! -n "$1" ]; then
echo "please input 1st arg"
exit
fi
if [ ! -n "$2" ]; then
echo "please input 2nd arg"
exit
fi
if [ ! -n "$3" ]; then
echo "please input 3rd arg"
exit
fi
if [ ! -n "$4" ]; then
echo "please input 4th arg"
exit
fi
if [ $1 -eq 1 ];then
docker ps | grep $2
if [ $? -eq 0 ];then
docker stop $2 && docker rm $2
fi
docker run -itd --name $2 -h $2 -e TaosadapterIp=$3 -e TaosadapterPort=$4 taosadapter_statsd:v1 /bin/bash
else
perfix=`echo $2 | cut -d '*' -f 1`
for i in `seq 1 $1`;
do
docker ps | grep $perfix$i
if [ $? -eq 0 ];then
docker stop $perfix$i && docker rm $perfix$i
fi
docker run -itd --name $perfix$i -h $perfix$i -e TaosadapterIp=$3 -e TaosadapterPort=$4 taosadapter_statsd:v1 /bin/bash
done
fi
#docker run -itd --name statsd_agent1 -h statsd_agent1 -e TaosadapterIp=172.26.10.86 -e TaosadapterPort=6044 taosadapter_statsd:v1 /bin/bash
FROM ubuntu:20.04
ENV REFRESHED_AT 2021-12-06
WORKDIR /root
ARG DEBIAN_FRONTEND=noninteractive
RUN set -ex; \
apt update -y --fix-missing && \
apt-get install -y --no-install-recommends git python && \
git clone git://github.com/OpenTSDB/tcollector.git && \
apt remove -y git && \
rm -rf /var/lib/apt/lists/*
COPY config.py /root/tcollector/collectors/etc/config.py
COPY entrypoint.sh /entrypoint.sh
ENV TaosadapterIp 127.0.0.1
ENV TaosadapterPort 6049
ENTRYPOINT ["/entrypoint.sh"]
#!/usr/bin/env python
# This file is part of tcollector.
# Copyright (C) 2010 The tcollector Authors.
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your
# option) any later version. This program is distributed in the hope that it
# will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
# General Public License for more details. You should have received a copy
# of the GNU Lesser General Public License along with this program. If not,
# see <http://www.gnu.org/licenses/>.
# This 'onload' function will be called by tcollector when it starts up.
# You can put any code here that you want to load inside the tcollector.
# This also gives you a chance to override the options from the command
# line or to add custom sanity checks on their values.
# You can also use this to change the global tags that will be added to
# every single data point. For instance if you have multiple different
# pools or clusters of machines, you might wanna lookup the name of the
# pool or cluster the current host belongs to and add it to the tags.
# Throwing an exception here will cause the tcollector to die before it
# starts doing any work.
# Python files in this directory that don't have an "onload" function
# will be imported by tcollector too, but no function will be called.
# When this file executes, you can assume that its directory is in
# sys.path, so you can import other Python modules from this directory
# or its subdirectories.
import os
import sys
def onload(options, tags):
"""Function called by tcollector when it starts up.
Args:
options: The options as returned by the OptionParser.
tags: A dictionnary that maps tag names to tag values.
"""
pass
def get_defaults():
"""Configuration values to use as defaults in the code
This is called by the OptionParser.
"""
default_cdir = os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), 'collectors')
defaults = {
'verbose': False,
'no_tcollector_stats': False,
'evictinterval': 6000,
'dedupinterval': 300,
'deduponlyzero': False,
'allowed_inactivity_time': 600,
'dryrun': False,
'maxtags': 8,
'http_password': False,
'reconnectinterval': 0,
'http_username': False,
'port': TaosadapterPort,
'pidfile': '/var/run/tcollector.pid',
'http': False,
'http_api_path': "api/put",
'tags': [],
'remove_inactive_collectors': False,
'host': 'TaosadapterIp',
'logfile': '/var/log/tcollector.log',
'cdir': default_cdir,
'ssl': False,
'stdin': False,
'daemonize': False,
'hosts': False,
"monitoring_interface": None,
"monitoring_port": 13280,
"namespace_prefix": "",
}
return defaults
#!/bin/bash
sed -i 's/TaosadapterIp/'$TaosadapterIp'/g;s/TaosadapterPort/'$TaosadapterPort'/g;' /root/tcollector/collectors/etc/config.py
/root/tcollector/tcollector start
tail -f /dev/null
#!/bin/bash
case "$1" in
-h|--help)
echo "Usage:"
echo "1st arg: agent_count"
echo "2nd arg: container_hostname prefix"
echo "3rd arg: TaosadapterIp"
echo "4th arg: TaosadapterPort"
echo "eg: ./run_tcollector.sh 1 tcollector_agent1 172.26.10.86 6049"
echo "eg: ./run_tcollector.sh 2 tcollector_agent* 172.26.10.86 6049"
exit 0
;;
esac
if [ $1 == "rm" ]; then
docker ps | grep $2 | awk '{print $1}' | xargs docker stop | xargs docker rm
exit
fi
if [ ! -n "$1" ]; then
echo "please input 1st arg"
exit
fi
if [ ! -n "$2" ]; then
echo "please input 2nd arg"
exit
fi
if [ ! -n "$3" ]; then
echo "please input 3rd arg"
exit
fi
if [ ! -n "$4" ]; then
echo "please input 4th arg"
exit
fi
if [ $1 -eq 1 ];then
docker ps | grep $2
if [ $? -eq 0 ];then
docker stop $2 && docker rm $2
fi
docker run -itd --name $2 -h $2 -e TaosadapterIp=$3 -e TaosadapterPort=$4 taosadapter_tcollector:v1 /bin/bash
else
perfix=`echo $2 | cut -d '*' -f 1`
for i in `seq 1 $1`;
do
docker ps | grep $perfix$i
if [ $? -eq 0 ];then
docker stop $perfix${i} && docker rm $perfix${i}
fi
docker run -itd --name $perfix$i -h $perfix$i -e TaosadapterIp=$3 -e TaosadapterPort=$4 taosadapter_tcollector:v1 /bin/bash
done
fi
#docker run -itd --name tcollector_agent1 -h tcollector_agent1 -e TaosadapterIp=172.26.10.86 -e TaosadapterPort=6049 taosadapter_tcollector:v1 /bin/bash
FROM ubuntu:20.04
ENV REFRESHED_AT 2021-12-06
ARG DEBIAN_FRONTEND=noninteractive
WORKDIR /root
RUN set -ex; \
apt update -y --fix-missing && \
apt install -y gnupg curl systemctl
RUN set -ex; \
curl -fsSL https://repos.influxdata.com/influxdb.key | apt-key add - && \
. /etc/lsb-release && \
echo 'deb https://repos.influxdata.com/ubuntu focal stable' > /etc/apt/sources.list.d/influxdb.list && \
apt update -y --fix-missing && \
apt-get install -y --no-install-recommends telegraf && \
apt remove -y gnupg curl && \
rm -rf /var/lib/apt/lists/*
COPY entrypoint.sh /entrypoint.sh
COPY telegraf.conf /etc/telegraf/telegraf.conf
ENV TelegrafInterval 1s
ENV TaosadapterIp 127.0.0.1
ENV TaosadapterPort 6048
ENV Dbname telegraf
ENTRYPOINT ["/entrypoint.sh"]
#!/bin/bash
sed -i 's/TaosadapterIp/'$TaosadapterIp'/g;s/TaosadapterPort/'$TaosadapterPort'/g;s/TelegrafInterval/'$TelegrafInterval'/g;s/Dbname/'$Dbname'/g;' /etc/telegraf/telegraf.conf
systemctl restart telegraf
tail -f /dev/null
#!/bin/bash
case "$1" in
-h|--help)
echo "Usage:"
echo "1st arg: agent_count"
echo "2nd arg: container_hostname prefix"
echo "3rd arg: TaosadapterIp"
echo "4th arg: TaosadapterPort"
echo "5th arg: TelegrafInterval"
echo "6th arg: Dbname"
echo "eg: ./run_telegraf.sh 1 telegraf_agent1 172.26.10.86 6041 1s telegraf"
echo "eg: ./run_telegraf.sh 2 telegraf_agent* 172.26.10.86 6041 1s telegraf"
exit 0
;;
esac
if [ $1 == "rm" ]; then
docker ps | grep $2 | awk '{print $1}' | xargs docker stop | xargs docker rm
exit
fi
if [ ! -n "$1" ]; then
echo "please input 1st arg"
exit
fi
if [ ! -n "$2" ]; then
echo "please input 2nd arg"
exit
fi
if [ ! -n "$3" ]; then
echo "please input 3rd arg"
exit
fi
if [ ! -n "$4" ]; then
echo "please input 4th arg"
exit
fi
if [ ! -n "$5" ]; then
echo "please input 5th arg"
exit
fi
if [ ! -n "$6" ]; then
echo "please input 6th arg"
exit
fi
if [ $1 -eq 1 ];then
docker ps | grep $2
if [ $? -eq 0 ];then
docker stop $2 && docker rm $2
fi
docker run -itd --name $2 -h $2 -e TaosadapterIp=$3 -e TaosadapterPort=$4 -e TelegrafInterval=$5 taosadapter_telegraf:v1 /bin/bash
else
perfix=`echo $2 | cut -d '*' -f 1`
for i in `seq 1 $1`;
do
docker ps | grep $perfix$i
if [ $? -eq 0 ];then
docker stop $perfix$i && docker rm $perfix$i
fi
docker run -itd --name $perfix$i -h $perfix$i -e TaosadapterIp=$3 -e TaosadapterPort=$4 -e TelegrafInterval=$5 -e Dbname=$6 taosadapter_telegraf:v1 /bin/bash
done
fi
#docker run -itd --name telegraf_agent1 -h telegraf_agent1 -e TaosadapterIp=172.26.10.86 -e TaosadapterPort=6041 -e TelegrafInterval=1s -e Dbname=telegraf taosadapter_telegraf:v1 /bin/bash
"insert into db1.stb11 values (nahr,);"
"insert into db1.stb22 (now,1,1);"
"insert into db1.stb13 (now,1,1) (now, 1,1, 2);"
"insert into db1.tb1 (now, 1,2 ,3 ,4);"
"insert into db1.stb16 values (now, null);"
"insert into db1.stb15 values (1614530008000,a, b, %$, d, e, f, g);"
"stb14,arch=x64,datacenter=us-west-1b,hostname=host_5,os=Ubuntu16,rack=,region=us-west-1,service=10,service_environment=staging,service_version=1614530008000,team=NYC col_value=32.261068 1614530008000"
"stb14,arch=x64,datacenter=us-west-1b,hostname=host_5,os=Ubuntu16,rack=1,region=us-west-1,service=10,service_environment=staging,service_version=2,team=NYC col_value=32.261068"
"stb14,arch=x64,datacenter=us-west-1b,hostname=host_5,os=Ubuntu16,rack=2,region=us-west-1,service=10,service_environment=staging,service_version=1614530008000,team=NYC 32.261068 1614530008000"
stb15 1614530008000 32.261068286779754 arch=x64 datacenter=us-west-1b hostname=host_5 os=Ubuntu16 rack= region=us-west-1 service=10 service_environment=staging service_version= team=NYC
stb15 32.261068286779754 arch=x64 datacenter=us-west-1b hostname=host_5 os=Ubuntu16 rack=1 region=us-west-1 service=10 service_environment=staging service_version=1 team=NYC
stb15 1614530008000 arch=x64 datacenter=us-west-1b hostname=host_5 os=Ubuntu16 rack=1 region=us-west-1 service=10 service_environment=staging service_version=1 team=NYC
"{""metric"": ""stb16"", ""timestamp"":1614530008000, ""value"":32.261068286779754, ""tags"":{""arch"":""x64"",""datacenter"":""us-west-1b"",""hostname"":""host_5"",""os"":""Ubuntu16"",""rack"":,""region"":""us-west-1"",""service"":""10"",""service_environment"":""staging"",""service_version"":""1"",""team"":""NYC""}}"
"{""metric"": ""stb16"", ""timestamp"":, ""value"":32.261068286779754, ""tags"":{""arch"":""x64"",""datacenter"":""us-west-1b"",""hostname"":""host_5"",""os"":""Ubuntu16"",""rack"":1,""region"":""us-west-1"",""service"":""10"",""service_environment"":""staging"",""service_version"":""1"",""team"":""NYC""}}"
"{""metric"": ""stb16"", ""timestamp"":1614530008000, ""value"":, ""tags"":{""arch"":""x64"",""datacenter"":""us-west-1b"",""hostname"":""host_5"",""os"":""Ubuntu16"",""rack"":,""region"":""us-west-1"",""service"":""10"",""service_environment"":""staging"",""service_version"":""1"",""team"":""NYC""}}"
"insert into db2.stb21 values (nahr,);"
"insert into db2.stb32 (now,1,1);"
"insert into db2.stb23 (now,1,1) (now, 1,1, 2);"
"insert into db2.tb1 (now, 1,2 ,3 ,4);"
"insert into db2.stb26 values (now, null);"
"insert into db2.stb25 values (1614530008000,a, b, %$, d, e, f, g);"
"stb24,arch=x64,datacenter=us-west-1b,hostname=host_5,os=Ubuntu16,rack=,region=us-west-1,service=10,service_environment=staging,service_version=1614530008000,team=NYC col_value=32.261068 1614530008000"
"stb24,arch=x64,datacenter=us-west-1b,hostname=host_5,os=Ubuntu16,rack=1,region=us-west-1,service=10,service_environment=staging,service_version=2,team=NYC col_value=32.261068"
"stb24,arch=x64,datacenter=us-west-1b,hostname=host_5,os=Ubuntu16,rack=2,region=us-west-1,service=10,service_environment=staging,service_version=1614530008000,team=NYC 32.261068 1614530008000"
stb25 1614530008000 32.261068286779754 arch=x64 datacenter=us-west-1b hostname=host_5 os=Ubuntu16 rack= region=us-west-1 service=10 service_environment=staging service_version= team=NYC
stb25 32.261068286779754 arch=x64 datacenter=us-west-1b hostname=host_5 os=Ubuntu16 rack=1 region=us-west-1 service=10 service_environment=staging service_version=1 team=NYC
stb25 1614530008000 arch=x64 datacenter=us-west-1b hostname=host_5 os=Ubuntu16 rack=1 region=us-west-1 service=10 service_environment=staging service_version=1 team=NYC
"{""metric"": ""stb26"", ""timestamp"":1614530008000, ""value"":32.261068286779754, ""tags"":{""arch"":""x64"",""datacenter"":""us-west-1b"",""hostname"":""host_5"",""os"":""Ubuntu16"",""rack"":,""region"":""us-west-1"",""service"":""10"",""service_environment"":""staging"",""service_version"":""1"",""team"":""NYC""}}"
"{""metric"": ""stb26"", ""timestamp"":, ""value"":32.261068286779754, ""tags"":{""arch"":""x64"",""datacenter"":""us-west-1b"",""hostname"":""host_5"",""os"":""Ubuntu16"",""rack"":1,""region"":""us-west-1"",""service"":""10"",""service_environment"":""staging"",""service_version"":""1"",""team"":""NYC""}}"
"{""metric"": ""stb26"", ""timestamp"":1614530008000, ""value"":, ""tags"":{""arch"":""x64"",""datacenter"":""us-west-1b"",""hostname"":""host_5"",""os"":""Ubuntu16"",""rack"":,""region"":""us-west-1"",""service"":""10"",""service_environment"":""staging"",""service_version"":""1"",""team"":""NYC""}}"
"insert into db3.stb31 values (nahr,);"
"insert into db3.stb12 (now,1,1);"
"insert into db3.stb33 (now,1,1) (now, 1,1, 2);"
"insert into db3.tb1 (now, 1,2 ,3 ,4);"
"insert into db3.stb36 values (now, null);"
"insert into db3.stb35 values (1614530008000,a, b, %$, d, e, f, g);"
"stb34,arch=x64,datacenter=us-west-1b,hostname=host_5,os=Ubuntu16,rack=,region=us-west-1,service=10,service_environment=staging,service_version=1614530008000,team=NYC col_value=32.261068 1614530008000"
"stb34,arch=x64,datacenter=us-west-1b,hostname=host_5,os=Ubuntu16,rack=1,region=us-west-1,service=10,service_environment=staging,service_version=2,team=NYC col_value=32.261068"
"stb34,arch=x64,datacenter=us-west-1b,hostname=host_5,os=Ubuntu16,rack=2,region=us-west-1,service=10,service_environment=staging,service_version=1614530008000,team=NYC 32.261068 1614530008000"
stb35 1614530008000 32.261068286779754 arch=x64 datacenter=us-west-1b hostname=host_5 os=Ubuntu16 rack= region=us-west-1 service=10 service_environment=staging service_version= team=NYC
stb35 32.261068286779754 arch=x64 datacenter=us-west-1b hostname=host_5 os=Ubuntu16 rack=1 region=us-west-1 service=10 service_environment=staging service_version=1 team=NYC
stb35 1614530008000 arch=x64 datacenter=us-west-1b hostname=host_5 os=Ubuntu16 rack=1 region=us-west-1 service=10 service_environment=staging service_version=1 team=NYC
"{""metric"": ""stb36"", ""timestamp"":1614530008000, ""value"":32.261068286779754, ""tags"":{""arch"":""x64"",""datacenter"":""us-west-1b"",""hostname"":""host_5"",""os"":""Ubuntu16"",""rack"":,""region"":""us-west-1"",""service"":""10"",""service_environment"":""staging"",""service_version"":""1"",""team"":""NYC""}}"
"{""metric"": ""stb36"", ""timestamp"":, ""value"":32.261068286779754, ""tags"":{""arch"":""x64"",""datacenter"":""us-west-1b"",""hostname"":""host_5"",""os"":""Ubuntu16"",""rack"":1,""region"":""us-west-1"",""service"":""10"",""service_environment"":""staging"",""service_version"":""1"",""team"":""NYC""}}"
"{""metric"": ""stb36"", ""timestamp"":1614530008000, ""value"":, ""tags"":{""arch"":""x64"",""datacenter"":""us-west-1b"",""hostname"":""host_5"",""os"":""Ubuntu16"",""rack"":,""region"":""us-west-1"",""service"":""10"",""service_environment"":""staging"",""service_version"":""1"",""team"":""NYC""}}"
"insert into long_db1.stb11 values (nahr,);"
"insert into long_db1.stb22 (now,1,1);"
"insert into long_db1.stb13 (now,1,1) (now, 1,1, 2);"
"insert into long_db1.tb1 (now, 1,2 ,3 ,4);"
"insert into long_db1.stb16 values (now, null);"
"insert into long_db1.stb15 values (1614530008000,a, b, %$, d, e, f, g);"
"insert into long_db2.stb21 values (nahr,);"
"insert into long_db2.stb32 (now,1,1);"
"insert into long_db2.stb23 (now,1,1) (now, 1,1, 2);"
"insert into long_db2.tb1 (now, 1,2 ,3 ,4);"
"insert into long_db2.stb26 values (now, null);"
"insert into long_db2.stb25 values (1614530008000,a, b, %$, d, e, f, g);"
"insert into long_db3.stb31 values (nahr,);"
"insert into long_db3.stb12 (now,1,1);"
"insert into long_db3.stb33 (now,1,1) (now, 1,1, 2);"
"insert into long_db3.tb1 (now, 1,2 ,3 ,4);"
"insert into long_db3.stb36 values (now, null);"
"insert into long_db3.stb35 values (1614530008000,a, b, %$, d, e, f, g);"
\ No newline at end of file
select * from db0.stb1 limit 1000;
select * from db0.stb3 limit 10000;
select * from db0.stb5 limit 100000;
"select avg(c1), max(c2), count(c3), sum(c4) from db0.stb1 where ts>""2021-03-01 00:00:00"" and ts < ""2021-03-08 00:00:00"" interval (1h);"
"select avg(c1), max(c2), count(c3), sum(c4) from db0.stb1 where ts>""2021-03-01 00:00:00"" and ts < ""2021-03-08 00:00:00"" group by c7;"
show db0.stables;
select count(tbname) from db1.tb1;
select count(*) from db2.tb2;
select * from db3.tb3 limit 10;
select * from db2.stb25 limit 10000;
select * from db3.stb31 limit 100000;
select * from db1.stb16 limit 100000;
"select avg(c1), max(c2), count(c3), sum(c4) from db3.stb31 where ts>""2021-03-01 00:00:00"" and ts < ""2021-03-01 00:35:00"" group by c7;"
"select avg(c1), max(c2), count(c3), sum(c4) from db2.stb23 where ts>""2021-03-01 00:00:00"" and ts < ""2021-03-01 00:35:00"" interval (1s);"
"select avg(c1), max(c2), count(c3), sum(c4) from db1.stb13 where ts>""2021-03-01 00:00:00"" and ts < ""2021-03-01 00:35:00"" interval (10s);"
select count(tbname) from long_db1.tb1;
select count(*) from long_db2.tb2;
select * from long_db3.tb3 limit 10;
select * from long_db2.stb25 limit 10000;
select * from long_db3.stb31 limit 100000;
select * from long_db1.stb16 limit 100000;
"select avg(c1), max(c2), count(c3), sum(c4) from long_db3.stb31 where ts>""2021-03-01 00:00:00"" and ts < ""2021-03-01 00:35:00"" group by c7;"
"select avg(c1), max(c2), count(c3), sum(c4) from long_db2.stb23 where ts>""2021-03-01 00:00:00"" and ts < ""2021-03-01 00:35:00"" interval (1s);"
"select avg(c1), max(c2), count(c3), sum(c4) from long_db1.stb13 where ts>""2021-03-01 00:00:00"" and ts < ""2021-03-01 00:35:00"" interval (10s);"
show taosadapter1_collectd.stables;
select count(*) from taosadapter1_collectd.`cpu.6.cpu.interrupt`;
select last(*) from taosadapter2_collectd.`cpu.2.cpu.interrupt`;
select * from taosadapter3_collectd.`cpu.2.cpu.system` limit 100;
select count(*) from taosadapter1_telegraf.mem;
select last(*) from taosadapter2_telegraf.cpu;
select * from taosadapter3_telegraf.kernel;
select count(*) from taosadapter1_tcollector.`net.stat.tcp.retransmit`;
select last(*) from taosadapter2_tcollector.`proc.meminfo.shmem`;
select * from taosadapter3_tcollector.`sys.numa.allocation`;
select count(*) from taosadapter1_icinga2.`icinga.host.rta_min`;
select last(*) from taosadapter2_icinga2.`icinga.host.acknowledgement`;
select * from taosadapter3_icinga2.`icinga.host.rta_crit`;
select count(*) from taosadapter1_node_exporter.`node_time_seconds`;
select last(*) from taosadapter2_node_exporter.`go_memstats_next_gc_bytes`;
select * from taosadapter3_node_exporter.`node_sockstat_TCP_mem`;
select count(*) from taosadapter2_statsd.taosadapter2_statsd_agent_count50;
select c199 from db0.stb2;
select null from db1.stb11;
select * from db2.tb0;
select blank from db3.stb31 limit 100000;
select null from long_db1.stb11;
select * from long_db2.tb0;
select blank from long_db3.stb31 limit 100000;
select count(*) from taosadapter1_collectd.cpu.6.cpu.interrupt;
select last(*) from taosadapter2_collectd.cpu.2.cpu.interr;
select * from taosadapter3_coll*.`cpu.2.cpu.system` limit 100;
select count(*) from taosadapter1_telegraf.`mem`;
select last(*) from `taosadapter2_telegraf`.cpu;
select * from taos_telegraf.kernel;
select count(*) from `taosadapter1_tcollector`.`net.stat.tcp.retransmit`;
select last(*) from taosadapter2_`tcollector`.`proc.meminfo.shmem`;
select * from taosadapter3_tcollector.sys.numa.`allocation`;
select count(*) from taosadapter1_icinga2.:icinga.host.rta_min;
"select last(*) from taosadapter2_icinga2.""""""`icinga.host.acknowledgement`;"
select * from taosadapter3_icinga2.```icinga.host.rta_crit`;
select count(*) from taosadapter1_node_exporter..`node_time_seconds`;
select last(*) from ..taosadapter2_node_exporter.`go_memstats_next_gc_bytes`;
select * from taosa%%dapter3___node_exporter.`node_sockstat_TCP_mem`;
select count(*) from taosadapter2_statsd%.taosadapter2_statsd_agent_count50;
\ No newline at end of file
#!/bin/bash
jmeter -n -t createStaticData.jmx >> createStaticData.log
jmeter -n -t longInsertData.jmx >> longInsertData.log
jmeter -n -t error_insert.jmx >> error_insert.log
jmeter -n -t query.jmx >> query.log
while true
do
jmeter -n -t shortInsertData.jmx >> ./shortInsertData.log
done
#!/bin/bash
while true
do
jmeter -n -t shortInsertData.jmx >> ./shortInsertData.log
done
此差异已折叠。
...@@ -21,7 +21,7 @@ python3 ./test.py -f 2-query/TD-12344.py ...@@ -21,7 +21,7 @@ python3 ./test.py -f 2-query/TD-12344.py
python3 ./test.py -f 2-query/TD-12614.py python3 ./test.py -f 2-query/TD-12614.py
python3 ./test.py -f 2-query/function_elapsed.py python3 ./test.py -f 2-query/function_elapsed.py
python3 ./test.py -f 2-query/TD-12909.py python3 ./test.py -f 2-query/TD-12909.py
python3 ./test.py -f 2-query/TD-12427.py
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册