Skip to content
This repository was archived by the owner on Dec 7, 2021. It is now read-only.

Commit 0f334f0

Browse files
committed
Merge pull request #119 from simonjohansson/add_monitoring_export
Export json for all templates that contains warning or critical
2 parents e040586 + 0bf59c3 commit 0f334f0

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

lib/gdash/sinatra_app.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,27 @@ def initialize(graphite_base, graph_templates, options = {})
8787
erb :index
8888
end
8989

90+
get '/monitoring_export' do
91+
content_type :json
92+
return_data = []
93+
@top_level.keys.each do |category|
94+
@top_level[category].dashboards.each do |dashboard_name|
95+
Dashboard.new(dashboard_name[:link], @graph_templates, dashboard_name[:category], {}, @graphite_render).graphs.each do |graph|
96+
graph_object = graph[:graphite]
97+
if graph_object.warning_threshold.any? or graph_object.critical_threshold.any?
98+
return_data << {
99+
:graphite_url => [@graphite_render, "?", graph_object.url].join,
100+
:warning => graph_object.warning_threshold,
101+
:critical => graph_object.critical_threshold,
102+
:graph_properties => graph_object.properties
103+
}
104+
end
105+
end
106+
end
107+
end
108+
return_data.to_json
109+
end
110+
90111
get '/search?*' do
91112
search_string = params['dashboard'] || ''
92113
d1,d2 = search_string.split('/', 2)

0 commit comments

Comments
 (0)