我编写了以下脚本,允许我设置传感器的数量和它们的批量插入数量。每个批量插入都有一个不同的纪元时间。每个传感器插件都有一个不同的值 + 不同的标签(温度)值。
凯罗斯版本:
root@ip-172-16-0-147:~# echo "version" | nc -w 30 localhost 4242
KairosDB 1.2.0-0.3beta.20171211170411
Scylla(后端存储)版本:
[centos@ip-172-16-0-128 ~]$ scylla --version
2.0.2-0.20171201.07b039f
问题: 只有第一个批量插入 Kairos,其他批量被忽略,我不知道为什么。任何关于为什么或如何更正脚本的想法都值得赞赏。
剧本:
import socket
import time
import random
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("[Kairos_IP]", 4242))
start_time = time.time()
lowerRange = 1
upperRange = 5
sensor_amount = 10
sensors = []
for x in range(lowerRange, upperRange):
str=""
curr_epoch = time.time()
#curr_epoch = int(time.time() * 1000)
time.sleep(1)
for y in range(1,sensor_amount):
statement = "put SENSOR_%d %d %d temp=%d\n" %(y,curr_epoch,random.randint(1,500),random.randint(1,500))
sensors.append(statement)
str+=(sensors[y-1])
print statement
s.send(str)
print curr_epoch
print("--- %s seconds ---" % (time.time() - start_time))
输出示例:
put SENSOR_1 1515672684 240 temp=500
put SENSOR_2 1515672684 279 temp=403
put SENSOR_3 1515672684 380 temp=376
put SENSOR_4 1515672684 59 temp=38
put SENSOR_5 1515672684 405 temp=46
put SENSOR_6 1515672684 61 temp=255
put SENSOR_7 1515672684 19 temp=21
put SENSOR_8 1515672684 246 temp=80
put SENSOR_9 1515672684 289 temp=233
1515672684.72
put SENSOR_1 1515672685 58 temp=12
put SENSOR_2 1515672685 245 temp=199
put SENSOR_3 1515672685 492 temp=220
put SENSOR_4 1515672685 185 temp=432
put SENSOR_5 1515672685 235 temp=416
put SENSOR_6 1515672685 218 temp=297
put SENSOR_7 1515672685 378 temp=3
put SENSOR_8 1515672685 317 temp=397
put SENSOR_9 1515672685 103 temp=229
1515672685.72
put SENSOR_1 1515672686 482 temp=395
put SENSOR_2 1515672686 417 temp=7
put SENSOR_3 1515672686 285 temp=111
put SENSOR_4 1515672686 67 temp=322
put SENSOR_5 1515672686 402 temp=3
put SENSOR_6 1515672686 120 temp=410
put SENSOR_7 1515672686 232 temp=50
put SENSOR_8 1515672686 90 temp=263
put SENSOR_9 1515672686 315 temp=48
1515672686.72
put SENSOR_1 1515672687 181 temp=453
put SENSOR_2 1515672687 212 temp=414
put SENSOR_3 1515672687 116 temp=138
put SENSOR_4 1515672687 106 temp=118
put SENSOR_5 1515672687 92 temp=348
put SENSOR_6 1515672687 178 temp=361
put SENSOR_7 1515672687 148 temp=198
put SENSOR_8 1515672687 334 temp=79
put SENSOR_9 1515672687 191 temp=192
1515672687.72