nat-monitor 3.0.6 → 4.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c2d895268e15e8f4652f7957bc640e433cce2e10
4
- data.tar.gz: 9f1091d77b11b1b4de113a34987a791bc0c55b24
3
+ metadata.gz: 3f3019dd6a06c41744e25d25878d8fc1743c027b
4
+ data.tar.gz: 4a2a3844adb2dbb5cb2d4dcbee79540df5e4fa50
5
5
  SHA512:
6
- metadata.gz: b65a92e8cb17fb483f02cbe521224902e9508d852e943923d6f8eb4cfac74bdb35e088d144a59b34692a513efc13adced47ebbb631bb5b6d57200728ccbd51c8
7
- data.tar.gz: b27966f54669bd1117ba155457cde5c798cbee858dc90b7e30f2b6cb342e1de1a38ab0941abaaae8608353c465f8681088c9a767797074b29e7a6a89eb185b8d
6
+ metadata.gz: ec75a2d9eb9e77f8ff85fec7a6496a9a8c48d3dfd843757e289d6b4d9840d4ee0801502b154649226136911c95c50b1a24958b23b4d162430959b36581839407
7
+ data.tar.gz: 9aee1e3836a53a2791567fe04e5b921c4afbe187e3290a9888c497e13c30e0958c39f2399ac2306f002eb99c5ce88d08b5e8baa24f1c3cc1dfcd41747bee7f33
data/README.md CHANGED
@@ -66,15 +66,37 @@ Note that:
66
66
 
67
67
  - If you don't specify the AWS credentials it will use the IAM role of the instance
68
68
 
69
- The NAT Monitor has the ability to report out, via a simple URL request, its start, success, and failures. This functionality is modeled after what [Cronitor.io](http://cronitor.io) expects.
69
+ The NAT Monitor has the ability to report out to [Cronitor.io](http://cronitor.io) its status. This comes courtesy of the [`cronitor`](https://github.com/evertrue/cronitor) gem.
70
70
 
71
- Requisite configuration needed:
71
+ You will need to set `monitor_enabled: true` and then supply either a Cronitor API token & monitor options:
72
72
 
73
73
  ```yaml
74
- monitor_urls:
75
- run: your.url/run
76
- complete: your.url/complete
77
- fail: your.url/fail
74
+ monitor_enabled: true
75
+ monitor_token: abcd
76
+ monitor_opts:
77
+ name: My Fancy Monitor
78
+ notifications:
79
+ emails:
80
+ - test@example.com
81
+ slack:
82
+ - https://url-to-slack.webhook
83
+ pagerduty:
84
+ - pagerduty-service-api-token
85
+ phones:
86
+ - +12345678900
87
+ webhooks:
88
+ - 'http://example.com'
89
+ rules:
90
+ - rule_type: 'not_run_in',
91
+ duration: 5,
92
+ time_unit: 'seconds'
93
+ ```
94
+
95
+ or the code for an existing Cronitor monitor:
96
+
97
+ ```yaml
98
+ monitor_enabled: true
99
+ monitor_code: abcd
78
100
  ```
79
101
 
80
102
  ## Contributing
data/Rakefile CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'rspec/core/rake_task'
3
+ require 'bump/tasks'
3
4
 
4
5
  desc 'Run RSpec unit tests'
5
6
  RSpec::Core::RakeTask.new do |t|
@@ -156,15 +156,26 @@ module EtTools
156
156
  current_master == node_id
157
157
  end
158
158
 
159
+ def monitor
160
+ return unless @conf['monitor_enabled']
161
+
162
+ if @conf['monitor_token']
163
+ @monitor ||= Cronitor.new(
164
+ token: @conf['monitor_token'],
165
+ opts: @conf['monitor_opts']
166
+ )
167
+ else
168
+ @monitor ||= Cronitor.new code: @conf['monitor_code']
169
+ end
170
+ end
171
+
159
172
  def notify_monitor(status, msg = nil)
160
173
  output msg unless msg.nil?
161
174
  return unless @conf['monitor_enabled']
162
- url = @conf['monitor_urls'][status]
163
- url += "?msg=#{URI.escape(msg)}" if status == 'fail' && !msg.nil?
164
175
 
165
- output 'Notifying external heartbeat monitor'
176
+ output 'Notifying Cronitor'
166
177
 
167
- Net::HTTP.get(URI url)
178
+ monitor.ping status, msg
168
179
  end
169
180
 
170
181
  private
@@ -1,5 +1,5 @@
1
1
  module EtTools
2
2
  class NatMonitor
3
- VERSION = '3.0.6'
3
+ VERSION = '4.0.0'
4
4
  end
5
5
  end
@@ -23,7 +23,9 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency 'byebug'
24
24
  spec.add_development_dependency 'bundler', '~> 1.7'
25
25
  spec.add_development_dependency 'rake', '~> 10.0'
26
+ spec.add_development_dependency 'bump', '~> 0.1'
26
27
 
27
28
  spec.add_runtime_dependency 'net-ping'
28
29
  spec.add_runtime_dependency 'fog', '~> 1.23', '>= 1.30'
30
+ spec.add_runtime_dependency 'cronitor', '~> 1.1'
29
31
  end
@@ -13,11 +13,7 @@ describe EtTools::NatMonitor do
13
13
  @yaml_conf = { 'route_table_id' => @route_table_id,
14
14
  'aws_access_key_id' => 'AWS_ACCESS_KEY_ID',
15
15
  'aws_secret_access_key' => 'AWS_SECRET_ACCESS_KEY',
16
- 'monitor_urls' => {
17
- 'run' => 'run',
18
- 'complete' => 'complete',
19
- 'fail' => 'fail'
20
- },
16
+ 'monitor_code' => 'abcd',
21
17
  'nodes' => (
22
18
  { @my_instance_id => '1.1.1.1' }
23
19
  ).merge(@other_nodes) }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nat-monitor
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.6
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Herot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-29 00:00:00.000000000 Z
11
+ date: 2015-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: bump
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.1'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.1'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: net-ping
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -114,6 +128,20 @@ dependencies:
114
128
  - - ">="
115
129
  - !ruby/object:Gem::Version
116
130
  version: '1.30'
131
+ - !ruby/object:Gem::Dependency
132
+ name: cronitor
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - "~>"
136
+ - !ruby/object:Gem::Version
137
+ version: '1.1'
138
+ type: :runtime
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - "~>"
143
+ - !ruby/object:Gem::Version
144
+ version: '1.1'
117
145
  description: A service for providing an HA NAT in EC2
118
146
  email:
119
147
  - eric.github@herot.com