1
0
mirror of https://github.com/Oxalide/vsphere-influxdb-go.git synced 2023-10-10 13:36:51 +02:00
vsphere-influxdb-go/vendor/github.com/influxdata/influxdb/etc/burn-in/random_points.rb

30 lines
614 B
Ruby
Raw Normal View History

2017-10-25 22:52:40 +02:00
require "influxdb"
ONE_WEEK_IN_SECONDS = 7*24*60*60
NUM_POINTS = 10_000
BATCHES = 100
master = InfluxDB::Client.new
master.delete_database("ctx") rescue nil
master.create_database("ctx")
influxdb = InfluxDB::Client.new "ctx"
influxdb.time_precision = "s"
names = ["foo", "bar", "baz", "quu", "qux"]
st = Time.now
BATCHES.times do |m|
points = []
puts "Writing #{NUM_POINTS} points, time ##{m}.."
NUM_POINTS.times do |n|
timestamp = Time.now.to_i - rand(ONE_WEEK_IN_SECONDS)
points << {value: names.sample, time: timestamp}
end
influxdb.write_point("ct1", points)
end
puts st
puts Time.now