spotdog 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +22 -1
- data/lib/spotdog/CHANGELOG.md +7 -0
- data/lib/spotdog/cli.rb +23 -2
- data/lib/spotdog/version.rb +1 -1
- data/spotdog.gemspec +1 -0
- metadata +16 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f8c1c054c0a2918c6edca2fd8c6b23c2988aa802
|
|
4
|
+
data.tar.gz: 8f939bfa50904bf4e344cb1c23f5bdad68aad028
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8a3c8714e6f188760a858b995ec3580c3633b3579a467b9185f15c66d5449b576393b310d2dbcce6c217f77155c71ccd69647fb1ce45110eaefc73affcfa6e5a
|
|
7
|
+
data.tar.gz: 213772f27bca9f06f57825c4486e2901a9c5a5e17910679b7b3edf02d0631b38ebede8a861f82065dc04fc62754d717f506753d60d032a3fa536b730b65440f5
|
data/README.md
CHANGED
|
@@ -3,12 +3,18 @@
|
|
|
3
3
|
[](https://travis-ci.org/dtan4/spotdog)
|
|
4
4
|
[](https://codeclimate.com/github/dtan4/spotdog)
|
|
5
5
|
[](https://codeclimate.com/github/dtan4/spotdog/coverage)
|
|
6
|
+
[](https://gemnasium.com/dtan4/spotdog)
|
|
7
|
+
[](http://badge.fury.io/rb/spotdog)
|
|
6
8
|
[](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`, `--
|
|
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
|
|
data/lib/spotdog/cli.rb
CHANGED
|
@@ -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:
|
|
16
|
-
end_time:
|
|
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
|
data/lib/spotdog/version.rb
CHANGED
data/spotdog.gemspec
CHANGED
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.
|
|
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
|