Skip to content
This repository was archived by the owner on Dec 7, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
source 'http://rubygems.org'
gem 'sinatra'
gem 'redcarpet'
gem 'graphite_graph', "~>0.0.7"
#gem 'graphite_graph', "~>0.0.7"
gem 'graphite_graph', :github => "srgshames/graphite-graph-dsl"
3 changes: 2 additions & 1 deletion lib/gdash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class GDash
require 'gdash/monkey_patches'
require 'gdash/sinatra_app'
require 'graphite_graph'
require 'graphite_graph_gen'

attr_reader :graphite_base, :graphite_render, :dash_templates, :height, :width, :from, :until

Expand All @@ -30,7 +31,7 @@ def dashboard(name, options={})
options[:from] ||= @from
options[:until] ||= @until

Dashboard.new(name, dash_templates, options)
Dashboard.new(@graphite_base, name, dash_templates, options)
end

def list
Expand Down
15 changes: 13 additions & 2 deletions lib/gdash/dashboard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ class GDash
class Dashboard
attr_accessor :properties

def initialize(short_name, dir, options={})
def initialize(graphite_base, short_name, dir, options={})
raise "Cannot find dashboard directory #{dir}" unless File.directory?(dir)

@graphite_base = graphite_base

@properties = {:graph_width => nil,
:graph_height => nil,
:graph_from => nil,
Expand All @@ -30,8 +32,13 @@ def graphs(options={})
options[:height] ||= graph_height
options[:from] ||= graph_from
options[:until] ||= graph_until

graph_generators = files_with_extension("graph_gen")
graph_generators.each do |graph_generator|
GraphiteGraphGenerator.new(@graphite_base, directory, graph_generator)
end

graphs = Dir.entries(directory).select{|f| f.match(/\.graph$/)}
graphs = files_with_extension("graph")

overrides = options.reject { |k,v| v.nil? }

Expand All @@ -40,6 +47,10 @@ def graphs(options={})
end
end

def files_with_extension(extension)
Dir.entries(directory).select{|f| f.match(/\.#{extension}$/)}
end

def method_missing(method, *args)
if properties.include?(method)
properties[method]
Expand Down