pingdom-to-graphite 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -2
- data/lib/pingdom-to-graphite/cli.rb +18 -11
- data/lib/pingdom-to-graphite/version.rb +2 -2
- metadata +2 -2
data/README.md
CHANGED
@@ -39,10 +39,10 @@ Don't worry scripters, this location can be overriden with the `-c` switch. Drop
|
|
39
39
|
your pingdom credentials and graphite settings into there to enable the script
|
40
40
|
to do any actual work.
|
41
41
|
|
42
|
-
% pingdom-to-graphite init_checks
|
42
|
+
% pingdom-to-graphite init_checks [regex]
|
43
43
|
|
44
44
|
This will pre-fill the pingdom->checks setting in your config file with a list
|
45
|
-
of all your available check ids. Since you're curious:
|
45
|
+
of all your available check ids. If you'd like to limit the list, you can supply an optional regular expression, and only the matching checks will be placed in your config. Since you're curious:
|
46
46
|
|
47
47
|
% pingdom-to-graphite list
|
48
48
|
|
@@ -48,7 +48,7 @@ class PingdomToGraphite::CLI < Thor
|
|
48
48
|
"host" => "YOUR_SERVER",
|
49
49
|
"port" => "2003",
|
50
50
|
"prefix" => "pingdom"
|
51
|
-
}
|
51
|
+
}
|
52
52
|
}
|
53
53
|
File.open(File.expand_path(options.config),"w",0600) do |f|
|
54
54
|
f.write(JSON.pretty_generate(settings))
|
@@ -58,8 +58,9 @@ class PingdomToGraphite::CLI < Thor
|
|
58
58
|
|
59
59
|
end
|
60
60
|
|
61
|
-
desc "init_checks", "Add
|
62
|
-
def init_checks
|
61
|
+
desc "init_checks <regex>", "Add your checks to your config. (Will overwrite existing list.) If regex is supplied will only add matching checks."
|
62
|
+
def init_checks(check_regex=nil)
|
63
|
+
@check_regex = check_regex
|
63
64
|
load_config!
|
64
65
|
load_check_list!
|
65
66
|
@config["pingdom"]["checks"] = @checks.keys
|
@@ -162,7 +163,7 @@ class PingdomToGraphite::CLI < Thor
|
|
162
163
|
# Check the state file
|
163
164
|
if @state.has_key?(check_id) && @state[check_id].has_key?("earliest_ts")
|
164
165
|
earliest_ts = @state[check_id.to_s]["earliest_ts"]
|
165
|
-
else
|
166
|
+
else
|
166
167
|
error("You can't backfill a check you've never run an update on.")
|
167
168
|
end
|
168
169
|
load_probe_list!
|
@@ -173,8 +174,8 @@ class PingdomToGraphite::CLI < Thor
|
|
173
174
|
limit = ask("You have #{datapull.effective_limit} API calls remaining. How many would you like to use?").to_i
|
174
175
|
end
|
175
176
|
created_ts = datapull.check(check_id).created
|
176
|
-
|
177
|
-
# Keep within the API limits
|
177
|
+
|
178
|
+
# Keep within the API limits
|
178
179
|
working_towards = (earliest_ts - created_ts) > 2678400 ? 31.days.ago.to_i : created_ts
|
179
180
|
puts "Backfilling from #{Time.at(earliest_ts)} working towards #{Time.at(working_towards)}. Check began on #{Time.at(created_ts)}"
|
180
181
|
# Break it into chunks
|
@@ -205,7 +206,7 @@ class PingdomToGraphite::CLI < Thor
|
|
205
206
|
def load_config!
|
206
207
|
if @config.nil?
|
207
208
|
config_file = File.expand_path(options.config)
|
208
|
-
unless File.exists?(config_file)
|
209
|
+
unless File.exists?(config_file)
|
209
210
|
error("Missing config file (#{options.config})")
|
210
211
|
end
|
211
212
|
|
@@ -250,16 +251,22 @@ class PingdomToGraphite::CLI < Thor
|
|
250
251
|
datapull = get_datapull
|
251
252
|
@checks = Hash.new
|
252
253
|
datapull.checks.each do |check|
|
253
|
-
# {"name"=>"Autocomplete", "id"=>259103, "type"=>"http", "lastresponsetime"=>203173,
|
254
|
+
# {"name"=>"Autocomplete", "id"=>259103, "type"=>"http", "lastresponsetime"=>203173,
|
254
255
|
# "status"=>"up", "lasttesttime"=>1298102416}
|
255
|
-
@
|
256
|
+
if @check_regex
|
257
|
+
if check.name =~ /#{@check_regex}/
|
258
|
+
@checks[check.id] = check
|
259
|
+
end
|
260
|
+
else
|
261
|
+
@checks[check.id] = check
|
262
|
+
end
|
256
263
|
end
|
257
264
|
end
|
258
265
|
|
259
266
|
# Take a pingdom check, and return an Array of metrics to be passed to graphite
|
260
267
|
def parse_result(check_id, result)
|
261
268
|
results = Array.new
|
262
|
-
prefix = "#{@config["graphite"]["prefix"]}.#{@checks[check_id.to_i].
|
269
|
+
prefix = "#{@config["graphite"]["prefix"]}.#{@checks[check_id.to_i].class}."
|
263
270
|
prefix += @checks[check_id.to_i].name.gsub(/ /,"_").gsub(/\./,"")
|
264
271
|
check_status = result.status.eql?("up") ? 1 : 0
|
265
272
|
check_time = Time.at(result.time).to_i
|
@@ -306,4 +313,4 @@ class PingdomToGraphite::CLI < Thor
|
|
306
313
|
options.verbose ? Logger::DEBUG : Logger::ERROR
|
307
314
|
end
|
308
315
|
|
309
|
-
end
|
316
|
+
end
|
@@ -1,3 +1,3 @@
|
|
1
1
|
module PingdomToGraphite
|
2
|
-
VERSION = "0.0.
|
3
|
-
end
|
2
|
+
VERSION = "0.0.7"
|
3
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pingdom-to-graphite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-10-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|