Created
February 16, 2012 14:35
-
-
Save knewter/1845317 to your computer and use it in GitHub Desktop.
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 'fnordmetric' | |
require 'fnordmetric/logger' | |
# This is a quickie ruby script to set up some base data for the dashboard | |
income_billing_keys = [:weekly_billing_external, :weekly_income_quickbooks, :weekly_break_even] | |
bank_account_keys = [:bank_account_checking, :bank_account_money_market, :bank_account_bonus_employee, :bank_account_bonus_boardmembers, :quickbooks_receivables, :quickbooks_payables] | |
website_traffic_keys = [:visitors_daily] | |
jenkins_keys = [:jenkins_build_success_daily, :jenkins_build_failure_daily] | |
demo_data = { | |
:income_billing => { | |
:weekly_billing_external => 24_560, | |
:weekly_income_quickbooks => 22_350, | |
:weekly_break_even => 22_000 | |
}, | |
:bank_account => { | |
:bank_account_checking => 23_550, | |
:bank_account_money_market => 60_000, | |
:bank_account_bonus_employee => 2_200, | |
:bank_account_bonus_boardmembers => 4_000, | |
:quickbooks_receivables => 96_000, | |
:quickbooks_payables => 2_400 | |
}, | |
:website_traffic => { | |
:visitors_daily => 567 | |
}, | |
:jenkins => { | |
:jenkins_build_success_daily => 220, | |
:jenkins_build_failure_daily => 22 | |
} | |
} | |
ticks = { | |
:income_billing => :weeks, | |
:bank_account => :days, | |
:website_traffic => :days, | |
:jenkins => :days | |
} | |
base_time = Time.now | |
filename = "/tmp/#{base_time.to_i}" | |
# Generate a log file | |
file = File.open(filename, "w") do |f| | |
(0..26).each do |i| | |
demo_data.each_pair do |tab, arr| | |
the_time = base_time - i.send(ticks[tab]) | |
arr.each_pair do |key, value| | |
jitter = (rand(10) / 20.0) + 0.5 | |
val = i == 0 ? value : value * jitter | |
h = {:_type => tab, key => val, :_time => the_time.to_i} | |
f << h.to_json | |
f << "\n" | |
end | |
end | |
end | |
f | |
end | |
puts File.open(filename, "r"){|f| f.read } | |
FnordMetric::Logger.import filename |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment