Skip to content

Instantly share code, notes, and snippets.

@andy-dufour
Created July 11, 2016 13:56
Show Gist options
  • Save andy-dufour/fd65794120033a041fd4952aa5f8eadc to your computer and use it in GitHub Desktop.
Save andy-dufour/fd65794120033a041fd4952aa5f8eadc to your computer and use it in GitHub Desktop.
e2fsck -f /dev/mapper/opscode-drbd
resize2fs /dev/mapper/opscode-drbd 5G

Place the contents of report-filler.rb into ~/report-filler.rb

ruby report-filler.rb &
require 'securerandom'
require 'pg'
require 'json'
#config = JSON.parse(::File.read('config.json'))
postgres_user = 'opscode_reporting'
# CHANGE POSTGRES_PW!!!
postgres_pw = 'affa8e1f58a10456ab80f2c29d9ce2650afb7c7a468fc15ee988810028f51b6d115ae7974cc9f98308a3d38e5f0f7579577c'
postgres_db = 'opscode_reporting'
org_id = '24c4023a9f182ab65fe822dbb778dd03'
node_id = '22dbb778dd033a1b09affb1d98a93031'
node_name = 'vagrant-ubuntu-trusty-64'
event_data = ''
updated_res_count = 39
total_res_count = 91
run_list = '[\"recipe[apache2]\"]'
start=0
stop=10000000
conn = PG.connect('user' => postgres_user,
'host' => '127.0.0.1',
'password' => postgres_pw,
'port' => 5432,
'dbname' => postgres_db)
conn.prepare('statement1', 'insert into node_run (run_id, org_id, node_id, node_name, status, start_time, end_time, duration, duration_id, event_data, run_list, updated_res_count, total_res_count) values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)')
conn.prepare('statement2', 'insert into node_run_detail (run_id, seq, duration, res_id, res_type, res_name, res_result, res_initial_state, res_final_state, start_time, delta, cookbook_name, cookbook_ver) values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)')
for i in start..stop
#puts "Row #{i}"
run_id = SecureRandom.uuid
year = '2016'
month = SecureRandom.random_number(7)+1
day = SecureRandom.random_number(27)+1
start_time = "#{year}-#{month}-#{day} 06:00:00+00"
end_time = "#{year}-#{month}-#{day} 06:00:00+00"
conn.exec_prepared('statement1', [ run_id, org_id, node_id, node_name, 'success', start_time, end_time, '0', '1', '', run_list, updated_res_count, total_res_count])
conn.exec_prepared('statement2', [ run_id, '0', '1', 'apache2', 'service', 'apache2', 'reload', '{\"enabled\":true,\"running\":true,\"masked\":null}', '{\"enabled\":true,\"running\":true,\"masked\":null}', start_time, '', 'apache2', '1.3.2'])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment