spotdog 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dbe35a6e83737b1cd1ef539a241445afb0fa3ecf
4
- data.tar.gz: 52b06d0a76b8dfd0a35b0d5673bc1b62fa26ddeb
3
+ metadata.gz: f8c1c054c0a2918c6edca2fd8c6b23c2988aa802
4
+ data.tar.gz: 8f939bfa50904bf4e344cb1c23f5bdad68aad028
5
5
  SHA512:
6
- metadata.gz: ab6233027f49c6e9ac3cc78664c8d6f272ea1c1c2e537ce5e6e8908f352f10c829166758be96f83ac63c4da3adf6d4e7387733cea798c2d090290ec002d75d53
7
- data.tar.gz: 27ce7e9dbd2fada291485494ef8276fd08bd4ed988df974fa444c4635fe3a149211f1dec15a46ec5497c839a43ce6998b73b28ec0058e92ca631f7994f960ac7
6
+ metadata.gz: 8a3c8714e6f188760a858b995ec3580c3633b3579a467b9185f15c66d5449b576393b310d2dbcce6c217f77155c71ccd69647fb1ce45110eaefc73affcfa6e5a
7
+ data.tar.gz: 213772f27bca9f06f57825c4486e2901a9c5a5e17910679b7b3edf02d0631b38ebede8a861f82065dc04fc62754d717f506753d60d032a3fa536b730b65440f5
data/README.md CHANGED
@@ -3,12 +3,18 @@
3
3
  [![Build Status](https://travis-ci.org/dtan4/spotdog.svg?branch=ec2-class)](https://travis-ci.org/dtan4/spotdog)
4
4
  [![Code Climate](https://codeclimate.com/github/dtan4/spotdog/badges/gpa.svg)](https://codeclimate.com/github/dtan4/spotdog)
5
5
  [![Test Coverage](https://codeclimate.com/github/dtan4/spotdog/badges/coverage.svg)](https://codeclimate.com/github/dtan4/spotdog/coverage)
6
+ [![Dependency Status](https://gemnasium.com/dtan4/spotdog.svg)](https://gemnasium.com/dtan4/spotdog)
7
+ [![Gem Version](https://badge.fury.io/rb/spotdog.svg)](http://badge.fury.io/rb/spotdog)
6
8
  [![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE)
7
9
 
8
10
  __Spotdog__ is a command line tool to send EC2 Spot Instance Pricing History to Datadog. Spotdog enables us to monitor pricing history on Datadog.
9
11
 
10
12
  (screenshot)
11
13
 
14
+ ## Supported Ruby version
15
+
16
+ Ruby 2.x
17
+
12
18
  ## Installation
13
19
 
14
20
  Add this line to your application's Gemfile:
@@ -25,6 +31,18 @@ Or install it yourself as:
25
31
 
26
32
  $ gem install spotdog
27
33
 
34
+ ## Prerequisites
35
+
36
+ You need to set __AWS credentials__ and __Datadog API key__ as environment variables.
37
+
38
+ ```bash
39
+ export AWS_ACCESS_KEY_ID=XXXXXXXXXXXXXXXXXXXX
40
+ export AWS_SECRET_ACCESS_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
41
+ export AWS_DEFAULT_REGION=xx-yyyy-0
42
+
43
+ export DATADOG_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
44
+ ```
45
+
28
46
  ## Usage
29
47
 
30
48
  ```bash
@@ -47,6 +65,7 @@ Options:
47
65
  p, [--product-descriptions=PRODUCT_DESCRIPTIONS] # List of product descriptions
48
66
  s, [--start-time=START_TIME] # The time which to start retriving the prices
49
67
  e, [--end-time=END_TIME] # The time which to stop retriving the prices
68
+ l, [--last-minutes=N] # The duration in minutes which to retrive the prices
50
69
  ```
51
70
 
52
71
  - `-i`, `--instance-type`
@@ -57,8 +76,10 @@ Options:
57
76
  - List of product descriptions, like `linux_vpc,suse_vpc`. These values are allowed: `linux_vpc`, `linux_classic`, `suse_vpc`, `suse_classic`, `windows_vpc` and `windows_classic`.
58
77
  - `-s`, `--start-time`
59
78
  - The time which to start retriving the prices, like `2015-10-06 18:00 JST`
60
- - `-e`, `--end_time`
79
+ - `-e`, `--end-time`
61
80
  - The time which to stop retriving the prices, like `2015-10-06 19:00 JST`
81
+ - `-l`, `--last-minutes`
82
+ - The duration in minutes which to retrive the prices.
62
83
 
63
84
  ## Development
64
85
 
@@ -0,0 +1,7 @@
1
+ # [v0.2.0](https://github.com/dtan4/spotdog/releases/tag/v0.2.0) (2015-10-06)
2
+
3
+ - Add CLI option `--last-minutes`
4
+
5
+ # [v0.1.0](https://github.com/dtan4/spotdog/releases/tag/v0.1.0) (2015-10-06)
6
+
7
+ - Initial release.
@@ -6,14 +6,15 @@ module Spotdog
6
6
  option :product_descriptions, type: :string, desc: "List of product descriptions", aliases: :p
7
7
  option :start_time, type: :string, desc: "The time which to start retriving the prices", aliases: :s
8
8
  option :end_time, type: :string, desc: "The time which to stop retriving the prices", aliases: :e
9
+ option :last_minutes, type: :numeric, desc: "The duration in minutes which to retrive the prices", aliases: :l
9
10
  def send
10
11
  spot_price_history = Spotdog::EC2.spot_price_history(
11
12
  instance_types: options[:instance_types] ? options[:instance_types].split(",") : nil,
12
13
  max_results: options[:max_results],
13
14
  product_descriptions: options[:product_descriptions] ?
14
15
  convert_product_descriptions(options[:product_descriptions].split(",")) : nil,
15
- start_time: options[:start_time] ? Time.parse(options[:start_time]): nil,
16
- end_time: options[:end_time] ? Time.parse(options[:end_time]) : nil,
16
+ start_time: parse_start_time(options),
17
+ end_time: parse_end_time(options),
17
18
  )
18
19
  Spotdog::Datadog.send_price_history(ENV["DATADOG_API_KEY"], spot_price_history)
19
20
  end
@@ -23,5 +24,25 @@ module Spotdog
23
24
  def convert_product_descriptions(product_descriptions)
24
25
  product_descriptions.map { |description| Spotdog::EC2::PRODUCT_DESCRIPTIONS[description.to_sym] }
25
26
  end
27
+
28
+ def current_time
29
+ @current_time ||= Time.now
30
+ end
31
+
32
+ def parse_start_time(options)
33
+ if options[:last_minutes]
34
+ current_time
35
+ else
36
+ options[:start_time] ? Time.parse(options[:start_time]) : nil
37
+ end
38
+ end
39
+
40
+ def parse_end_time(options)
41
+ if options[:last_minutes]
42
+ current_time - options[:last_minutes] * 60
43
+ else
44
+ options[:end_time] ? Time.parse(options[:end_time]) : nil
45
+ end
46
+ end
26
47
  end
27
48
  end
@@ -1,3 +1,3 @@
1
1
  module Spotdog
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -29,4 +29,5 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency "rake", "~> 10.0"
30
30
  spec.add_development_dependency "rspec"
31
31
  spec.add_development_dependency "terminal-notifier-guard"
32
+ spec.add_development_dependency "timecop"
32
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spotdog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daisuke Fujita
@@ -136,6 +136,20 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: timecop
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
139
153
  description: Send EC2 Spot Instance Price History to Datadog
140
154
  email:
141
155
  - dtanshi45@gmail.com
@@ -157,6 +171,7 @@ files:
157
171
  - bin/setup
158
172
  - exe/spotdog
159
173
  - lib/spotdog.rb
174
+ - lib/spotdog/CHANGELOG.md
160
175
  - lib/spotdog/cli.rb
161
176
  - lib/spotdog/datadog.rb
162
177
  - lib/spotdog/ec2.rb