Last active
August 29, 2015 14:05
-
-
Save mikepea/19029ff5b944079c1b10 to your computer and use it in GitHub Desktop.
Graphite whisper file sizing calculator
This file contains hidden or 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
#!/usr/bin/env ruby | |
# | |
# eg: graphite-calc.rb 10s:10d,5m:400d,24h:20y 20 | |
# to calculate sizing for 20 hosts, 1000 metrics per host, 10s metric update interval | |
# | |
graphite_policy = ARGV.shift | |
num_hosts = ARGV.shift || 1 | |
num_metrics = ARGV.shift || 1000 | |
update_interval = ARGV.shift || 10 | |
update_interval = Integer(update_interval) | |
num_metrics = Integer(num_metrics) | |
num_hosts = Integer(num_hosts) | |
policy_fragments = graphite_policy.split(/,/) | |
total_datapoints = 0 | |
frag_datapoints = {} | |
def convert_to_seconds(time_spec) | |
case time_spec | |
when /^(\d+)$/ | |
return Integer($1) | |
when /^(\d+)s$/ | |
return Integer($1) | |
when /^(\d+)m$/ | |
return Integer($1) * 60 | |
when /^(\d+)h$/ | |
return Integer($1) * 60 * 60 | |
when /(\d+)d$/ | |
return Integer($1) * 60 * 60 * 24 | |
when /(\d+)y$/ | |
return Integer($1) * 60 * 60 * 24 * 365 | |
else | |
raise "Bogus value '#{time_spec}'" | |
end | |
end | |
policy_fragments.each do |frag| | |
(precision, duration) = frag.split(/:/) | |
precision_in_sec = convert_to_seconds(precision) | |
duration_in_sec = convert_to_seconds(duration) | |
frag_datapoints[frag] = (duration_in_sec / precision_in_sec) | |
total_datapoints += frag_datapoints[frag] | |
end | |
puts "Policy: #{graphite_policy}" | |
puts "Send frequency (s): #{update_interval}" | |
puts "Number of metrics: #{num_metrics}" | |
puts "Number of hosts: #{num_hosts}" | |
puts | |
puts "Total Datapoints per metric: #{total_datapoints}" | |
puts "Per-fragment Datapoints: #{frag_datapoints}" | |
puts "Size per metric: #{total_datapoints * 12 / 1024}KiB" | |
puts | |
puts "Datapoints recd per second: #{ num_metrics * num_hosts / update_interval }" | |
puts "Total disk space needed: #{ total_datapoints * 12 * num_hosts * num_metrics / ( 1024 * 1024 )}MiB" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment