Created
May 3, 2013 07:23
-
-
Save kyzh/5507714 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
class SinatraApp < ::Sinatra::Base | |
def initialize(graphite_base, graph_templates, options = {}) | |
# where the whisper data is | |
@whisper_dir = options.delete(:whisper_dir) || "/var/lib/carbon/whisper" | |
# where graphite lives | |
@graphite_base = graphite_base | |
# where the graphite renderer is | |
@graphite_render = [@graphite_base, "/render/"].join | |
# where to find graph, dash etc templates | |
@graph_templates = graph_templates | |
# the dash site might have a prefix for its css etc | |
@prefix = options.delete(:prefix) || "" | |
# the page refresh rate | |
@refresh_rate = options.delete(:refresh_rate) || 60 | |
# how many columns of graphs do you want on a page | |
@graph_columns = options.delete(:graph_columns) || 2 | |
# how wide each graph should be | |
@graph_width = options.delete(:graph_width) | |
# how hight each graph sould be | |
@graph_height = options.delete(:graph_height) | |
# Dashboard title | |
@dash_title = options.delete(:title) || "Graphite Dashboard" | |
# Do we want to display the graphite source URL | |
@graphite_url_displayed = options.delete(:graphite_url_displayed) || true | |
# Time filters in interface | |
@interval_filters = options.delete(:interval_filters) || Array.new | |
@intervals = options.delete(:intervals) || [] | |
@top_level = Hash.new | |
Dir.entries(@graph_templates).each do |category| | |
if File.directory?("#{@graph_templates}/#{category}") | |
unless ("#{category}" =~ /^\./ ) | |
gdash = GDash.new(@graphite_base, "/render/", @graph_templates, category, {:width => @graph_width, :height => @graph_height}) | |
@top_level["#{category}"] = gdash unless gdash.dashboards.empty? | |
end | |
end | |
end | |
super() | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment