Created
June 30, 2014 14:17
-
-
Save tomquas/d13ffcff91d03e987b1c to your computer and use it in GitHub Desktop.
fill influxdb w/ semi-random data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'socket' | |
require 'json' | |
total = ARGV.first.to_i || 1_000 | |
packets_per_run = 1_000 | |
def send_bulk(socket, packets) | |
packets.times do | |
socket.send [{name:"udp", columns:["v"], points:[[rand]]}].to_json, 0 | |
end | |
sleep 1.0/8.0 # w/o this pause, we lose udp packets... | |
end | |
db = UDPSocket.new | |
db.connect '127.0.0.1', 4444 | |
(total / packets_per_run).to_i.times { send_bulk(db, packets_per_run) } | |
send_bulk(db, total % packets_per_run) | |
db.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment