Skip to content

Commit a597023

Browse files
ROunofFmajormoses
authored andcommitted
Cleanup unused method (#51)
* Cleanup unused method * Added CHANGELOG
1 parent 62ea944 commit a597023

File tree

2 files changed

+2
-64
lines changed

2 files changed

+2
-64
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
1010
### Fixed
1111
- Error handling in graphite handlers
1212
- Duplicate short option in check-graphite.rb
13+
### Removed
14+
- Method retrieve_data in check-graphite-data since it's duplicate from graphite_proxy
1315

1416
## [2.0.0] - 2016-06-21
1517
### Added

bin/check-graphite-data.rb

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -84,70 +84,6 @@ def check_age
8484
end
8585
end
8686

87-
# grab data from graphite
88-
def retrieve_data
89-
unless @raw_data
90-
begin
91-
unless config[:server].start_with?('https://', 'http://')
92-
config[:server].prepend('http://')
93-
end
94-
95-
url = "#{config[:server]}/render?format=json&target=#{formatted_target}&from=#{config[:from]}&until=#{config[:until]}"
96-
97-
url_opts = {}
98-
99-
if config[:no_ssl_verify]
100-
url_opts[:ssl_verify_mode] = OpenSSL::SSL::VERIFY_NONE
101-
end
102-
103-
if config[:username] && (config[:password] || config[:passfile])
104-
if config[:passfile]
105-
pass = File.open(config[:passfile]).readline
106-
elsif config[:password]
107-
pass = config[:password]
108-
end
109-
110-
url_opts[:http_basic_authentication] = [config[:username], pass.chomp]
111-
end # we don't have both username and password trying without
112-
113-
handle = open(url, url_opts)
114-
115-
@raw_data = handle.gets
116-
if @raw_data == '[]'
117-
unknown 'Empty data received from Graphite - metric probably doesn\'t exist'
118-
else
119-
@json_data = JSON.parse(@raw_data)
120-
output = {}
121-
@json_data.each do |raw|
122-
raw['datapoints'].delete_if { |v| v.first.nil? }
123-
next if raw['datapoints'].empty?
124-
target = raw['target']
125-
data = raw['datapoints'].map(&:first)
126-
start = raw['datapoints'].first.last
127-
dend = raw['datapoints'].last.last
128-
step = ((dend - start) / raw['datapoints'].size.to_f).ceil
129-
output[target] = { 'target' => target, 'data' => data, 'start' => start, 'end' => dend, 'step' => step }
130-
end
131-
output
132-
end
133-
rescue SocketError
134-
unknown 'Failed to connect to graphite server'
135-
rescue OpenURI::HTTPError
136-
unknown 'Server error or invalid graphite expression'
137-
rescue NoMethodError
138-
unknown 'No data for time period and/or target'
139-
rescue Errno::ECONNREFUSED
140-
unknown 'Connection refused when connecting to Graphite server'
141-
rescue Errno::ECONNRESET
142-
unknown 'Connection reset by peer when connecting to Graphite server'
143-
rescue EOFError
144-
unknown 'End of file error when reading from Graphite server'
145-
rescue => e
146-
unknown "An unknown error occurred: #{e.inspect}"
147-
end
148-
end
149-
end
150-
15187
# type:: :warning or :critical
15288
# Return alert if required
15389
def check(type)

0 commit comments

Comments
 (0)